27 #include <goffice/goffice.h>
28 #include <gsf/gsf-impl-utils.h>
29 #include <glib/gi18n-lib.h>
31 struct _GcuComboPeriodic {
34 GtkWidget *periodic, *preview_button, *label;
41 } GcuComboPeriodicClass;
48 static guint go_combo_pixmaps_signals [LAST_SIGNAL] = { 0, };
51 cb_screen_changed (
GcuComboPeriodic *combo, G_GNUC_UNUSED GdkScreen *previous_screen)
53 GtkWidget *w = GTK_WIDGET (combo);
54 GdkScreen *screen = gtk_widget_has_screen (w)
55 ? gtk_widget_get_screen (w)
59 GtkWidget *toplevel = gtk_widget_get_toplevel (combo->periodic);
60 gtk_window_set_screen (GTK_WINDOW (toplevel), screen);
67 int newZ = gcu_periodic_get_element (
GCU_PERIODIC (combo->periodic));
69 if (_go_combo_is_updating (GO_COMBO_BOX (combo)))
71 g_signal_emit (combo, go_combo_pixmaps_signals [CHANGED], 0, newZ);
72 go_combo_box_popup_hide (GO_COMBO_BOX (combo));
78 combo->preview_button = gtk_toggle_button_new ();
79 combo->label = gtk_label_new (
"");
80 gtk_widget_show (combo->label);
81 gtk_container_add (GTK_CONTAINER (combo->preview_button),
82 GTK_WIDGET (combo->label));
84 g_signal_connect (G_OBJECT (combo),
86 G_CALLBACK (cb_screen_changed), NULL);
88 gtk_widget_show_all (combo->preview_button);
90 combo->handler_id = g_signal_connect_swapped (combo->periodic,
91 "element_changed", G_CALLBACK (element_changed_cb), combo);
92 gtk_widget_show_all (combo->periodic);
93 go_combo_box_construct (GO_COMBO_BOX (combo),
94 combo->preview_button, combo->periodic, combo->periodic);
95 go_combo_box_set_title(GO_COMBO_BOX (combo), _(
"Periodic table of the elements"));
96 gtk_widget_show_all (GTK_WIDGET (combo));
100 gcu_combo_periodic_class_init (GObjectClass *gobject_class)
102 go_combo_pixmaps_signals [CHANGED] =
103 g_signal_new (
"changed",
104 G_OBJECT_CLASS_TYPE (gobject_class),
106 G_STRUCT_OFFSET (GcuComboPeriodicClass, changed),
108 g_cclosure_marshal_VOID__INT,
109 G_TYPE_NONE, 1, G_TYPE_INT);
113 gcu_combo_periodic_class_init, gcu_combo_periodic_init,
123 return gcu_periodic_get_element (
GCU_PERIODIC (combo->periodic));
128 g_signal_handler_block (combo->periodic, combo->handler_id);
129 gcu_periodic_set_element (
GCU_PERIODIC (combo->periodic), element);
130 g_signal_handler_unblock (combo->periodic, combo->handler_id);