From 34f161d3c9808885aa496f5c0145e6079ec56c4a Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 20 May 2013 06:42:43 +0200 Subject: [PATCH] Avoid use of deprecated GtkComboBoxEntry --- src/ui/gui/indep-samples.ui | 3 ++ src/ui/gui/page-separators.c | 10 +++---- src/ui/gui/psppire-data-editor.h | 2 +- src/ui/gui/psppire-value-entry.c | 48 +++++++++++++++++++------------- src/ui/gui/psppire-value-entry.h | 6 ++-- src/ui/gui/roc.ui | 1 + src/ui/gui/text-data-import.ui | 3 +- 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/ui/gui/indep-samples.ui b/src/ui/gui/indep-samples.ui index 288a41b719..2251d0dcda 100644 --- a/src/ui/gui/indep-samples.ui +++ b/src/ui/gui/indep-samples.ui @@ -299,6 +299,7 @@ + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -312,6 +313,7 @@ + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -349,6 +351,7 @@ + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index f1e08a6b59..4b9f184be7 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -121,7 +121,7 @@ static const struct separator separators[] = #define SEPARATOR_CNT (sizeof separators / sizeof *separators) static void -set_quote_list (GtkComboBoxEntry *cb) +set_quote_list (GtkComboBox *cb) { GtkListStore *list = gtk_list_store_new (1, G_TYPE_STRING); GtkTreeIter iter; @@ -143,7 +143,7 @@ set_quote_list (GtkComboBoxEntry *cb) gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list)); g_object_unref (list); - gtk_combo_box_entry_set_text_column (cb, 0); + gtk_combo_box_set_entry_text_column (cb, 0); } /* Initializes IA's separators substructure. */ @@ -167,7 +167,7 @@ separators_page_create (struct import_assistant *ia) p->quote_cb = get_widget_assert (builder, "quote-cb"); p->escape_cb = get_widget_assert (builder, "escape"); - set_quote_list (GTK_COMBO_BOX_ENTRY (p->quote_combo)); + set_quote_list (GTK_COMBO_BOX (p->quote_combo)); p->fields_tree_view = PSPP_SHEET_VIEW (get_widget_assert (builder, "fields")); g_signal_connect (p->quote_combo, "changed", G_CALLBACK (on_quote_combo_change), ia); @@ -528,10 +528,8 @@ get_separators (struct import_assistant *ia) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (s->quote_cb))) { - gchar *text = gtk_combo_box_get_active_text ( - GTK_COMBO_BOX (s->quote_combo)); + const gchar *text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (s->quote_combo)))); ds_assign_cstr (&s->quotes, text); - g_free (text); } else ds_clear (&s->quotes); diff --git a/src/ui/gui/psppire-data-editor.h b/src/ui/gui/psppire-data-editor.h index 35666600de..81495d5120 100644 --- a/src/ui/gui/psppire-data-editor.h +++ b/src/ui/gui/psppire-data-editor.h @@ -65,7 +65,7 @@ struct _PsppireDataEditor /* Data sheet tab. */ GtkWidget *vbox; /* Top-level widget in tab. */ GtkWidget *cell_ref_label; /* GtkLabel that shows selected case and var. */ - GtkWidget *datum_entry; /* GtkComboBoxEntry for editing current cell. */ + GtkWidget *datum_entry; /* PsppireValueEntry for editing current cell. */ GtkWidget *datasheet_vbox_widget; /* ->vbox child that holds data sheets. */ GtkWidget *data_sheets[4]; /* Normally one data sheet; four, if split. */ gboolean split; /* True if data sheets are split. */ diff --git a/src/ui/gui/psppire-value-entry.c b/src/ui/gui/psppire-value-entry.c index a55a50465c..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 diff --git a/src/ui/gui/psppire-value-entry.h b/src/ui/gui/psppire-value-entry.h index d17d5ad1ea..73fe14c3b9 100644 --- a/src/ui/gui/psppire-value-entry.h +++ b/src/ui/gui/psppire-value-entry.h @@ -20,7 +20,7 @@ #include #include "data/format.h" -/* PsppireValueEntry is a subclass of GtkComboBoxEntry that is specialized for +/* PsppireValueEntry is a subclass of GtkComboBox that is specialized for displaying and entering "union value"s. Its main advantage over a plain GtkEntry is that, when value labels are supplied, it (optionally) displays the value label instead of the value. It also allows the user to choose a @@ -52,7 +52,7 @@ typedef struct _PsppireValueEntryClass PsppireValueEntryClass; struct _PsppireValueEntry { - GtkComboBoxEntry parent; + GtkComboBox parent; gboolean show_value_label; @@ -65,7 +65,7 @@ struct _PsppireValueEntry struct _PsppireValueEntryClass { - GtkComboBoxEntryClass parent_class; + GtkComboBoxClass parent_class; }; GType psppire_value_entry_get_type (void); diff --git a/src/ui/gui/roc.ui b/src/ui/gui/roc.ui index 1b7052a4fa..92fd89b370 100644 --- a/src/ui/gui/roc.ui +++ b/src/ui/gui/roc.ui @@ -181,6 +181,7 @@ + True True True diff --git a/src/ui/gui/text-data-import.ui b/src/ui/gui/text-data-import.ui index fc886c2a00..1d532fb00c 100644 --- a/src/ui/gui/text-data-import.ui +++ b/src/ui/gui/text-data-import.ui @@ -440,7 +440,8 @@ The selected file contains N lines of text. Only the first M of these will be s - + + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK False -- 2.30.2