Avoid use of deprecated GtkComboBoxEntry
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 20 May 2013 04:42:43 +0000 (06:42 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 28 May 2013 14:03:19 +0000 (16:03 +0200)
src/ui/gui/indep-samples.ui
src/ui/gui/page-separators.c
src/ui/gui/psppire-data-editor.h
src/ui/gui/psppire-value-entry.c
src/ui/gui/psppire-value-entry.h
src/ui/gui/roc.ui
src/ui/gui/text-data-import.ui

index 288a41b719cd3bce49db94132c6d802dd12a0a9f..2251d0dcdaf23afed048bf5db76094b1c1920ec2 100644 (file)
                 </child>
                 <child>
                   <object class="PsppireValueEntry" id="group2-entry">
+                    <property name="has-entry">True</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 </child>
                 <child>
                   <object class="PsppireValueEntry" id="group1-entry">
+                    <property name="has-entry">True</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 </child>
                 <child>
                   <object class="PsppireValueEntry" id="cut-point-entry">
+                    <property name="has-entry">True</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index f1e08a6b594b3e74731faa51fbb5d5acc80432a2..4b9f184be7c81d0a57a23134c071ff18cd694ee0 100644 (file)
@@ -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);
index 35666600decca02e6f3b06e471ff79422f974a3e..81495d51207ecd66c1dc836cb45fae7bc42629c8 100644 (file)
@@ -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. */
index a55a50465c66aea9d916ef2240ae039cf90794ff..5ce18414bbb29a6d4ef7c4cec14ba8d0e5b5d9e3 100644 (file)
@@ -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
index d17d5ad1ea98962ff21dee6c7d3c9e3337eafe7b..73fe14c3b9b1dbff231bf6b914d2c13935a8e15f 100644 (file)
@@ -20,7 +20,7 @@
 #include <gtk/gtk.h>
 #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);
index 1b7052a4fa6cdd69f4f1621cc34a1ad0dac437c4..92fd89b370f8dc5f8579ca013c4d5b45075d3d7b 100644 (file)
                     </child>
                     <child>
                       <object class="PsppireValueEntry" id="entry2">
+                       <property name="has-entry">True</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </object>
index fc886c2a003ced420c321c1c96d94198b52fa6df..1d532fb00ce8be08d7aa7bb8d71fdc0f57beb676 100644 (file)
@@ -440,7 +440,8 @@ The selected file contains N lines of text.  Only the first M of these will be s
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBoxEntry" id="quote-combo">
+                          <object class="GtkComboBox" id="quote-combo">
+                            <property name="has-entry">True</property>
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="has_frame">False</property>