X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-value-entry.c;h=5ce18414bbb29a6d4ef7c4cec14ba8d0e5b5d9e3;hb=f2d4cc6e7a4d5948a2c0cf70883347000a79a2b0;hp=91dcdd47931e1c93e6ebdeee5fe0751f95f2c582;hpb=990ea46cc99059fae66736ece0c3fa1cf00cbda5;p=pspp diff --git a/src/ui/gui/psppire-value-entry.c b/src/ui/gui/psppire-value-entry.c index 91dcdd4793..5ce18414bb 100644 --- a/src/ui/gui/psppire-value-entry.c +++ b/src/ui/gui/psppire-value-entry.c @@ -28,7 +28,7 @@ static void psppire_value_entry_finalize (GObject *); G_DEFINE_TYPE (PsppireValueEntry, psppire_value_entry, - GTK_TYPE_COMBO_BOX_ENTRY); + GTK_TYPE_COMBO_BOX); enum { @@ -129,15 +129,40 @@ psppire_value_entry_get_property (GObject *object, } } +static void +psppire_value_entry_text_changed (GtkEntryBuffer *buffer, + GParamSpec *pspec, + PsppireValueEntry *obj) +{ + obj->cur_value = NULL; +} + + +static void +on_realize (GtkWidget *w) +{ + GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (w))); + GtkEntryBuffer *buffer = gtk_entry_get_buffer (entry); + + gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (w), COL_LABEL); + + g_signal_connect (buffer, "notify::text", + G_CALLBACK (psppire_value_entry_text_changed), w); + + GTK_WIDGET_CLASS (psppire_value_entry_parent_class)->realize (w); +} + static void psppire_value_entry_class_init (PsppireValueEntryClass *class) { - GObjectClass *gobject_class; - gobject_class = G_OBJECT_CLASS (class); + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); + gobject_class->finalize = psppire_value_entry_finalize; gobject_class->set_property = psppire_value_entry_set_property; gobject_class->get_property = psppire_value_entry_get_property; + widget_class->realize = on_realize; g_object_class_install_property ( gobject_class, PROP_SHOW_VALUE_LABEL, @@ -197,29 +222,14 @@ psppire_value_entry_class_init (PsppireValueEntryClass *class) G_PARAM_READABLE | G_PARAM_WRITABLE)); } -static void -psppire_value_entry_text_changed (GtkEntryBuffer *buffer, - GParamSpec *pspec, - PsppireValueEntry *obj) -{ - obj->cur_value = NULL; -} - static void psppire_value_entry_init (PsppireValueEntry *obj) { - GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (obj))); - GtkEntryBuffer *buffer = gtk_entry_get_buffer (entry); - obj->show_value_label = true; obj->val_labs = NULL; obj->format = F_8_0; obj->encoding = NULL; obj->cur_value = NULL; - gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (obj), COL_LABEL); - - g_signal_connect (buffer, "notify::text", - G_CALLBACK (psppire_value_entry_text_changed), obj); } static void @@ -236,7 +246,7 @@ psppire_value_entry_finalize (GObject *gobject) GtkWidget * psppire_value_entry_new (void) { - return GTK_WIDGET (g_object_new (PSPPIRE_TYPE_VALUE_ENTRY, NULL)); + return GTK_WIDGET (g_object_new (PSPPIRE_TYPE_VALUE_ENTRY, "has-entry", TRUE, NULL)); } static void @@ -280,7 +290,7 @@ psppire_value_entry_refresh_model (PsppireValueEntry *obj) } gtk_combo_box_set_model (GTK_COMBO_BOX (obj), model); - if ((model != NULL) && (model != old_model)) + if (model != NULL) g_object_unref (model); }