From 070daa3e8b889e121aef9799a564198265349474 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 1 Apr 2005 20:57:20 +0000 Subject: [PATCH] Make gtk_combo_box_get_active_text do the right thing for GtkComboBoxEntry 2005-04-01 Matthias Clasen Make gtk_combo_box_get_active_text do the right thing for GtkComboBoxEntry (#171373, Robert Staudinger) * gtk/gtkcombobox.h: Add a get_active_text vfunc. * gtk/gtkcombobox.c (gtk_combo_box_real_get_active_text): And implement it here. * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_get_active_text): Implement get_active_text by always returning the content of the entry. --- ChangeLog | 14 ++++++++++++++ ChangeLog.pre-2-10 | 14 ++++++++++++++ ChangeLog.pre-2-8 | 14 ++++++++++++++ gtk/gtkcombobox.c | 19 ++++++++++++++++++- gtk/gtkcombobox.h | 4 +++- gtk/gtkcomboboxentry.c | 16 ++++++++++++++++ 6 files changed, 79 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc2247bc66..00676215a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-04-01 Matthias Clasen + + Make gtk_combo_box_get_active_text do the right thing for + GtkComboBoxEntry (#171373, Robert Staudinger) + + * gtk/gtkcombobox.h: Add a get_active_text vfunc. + + * gtk/gtkcombobox.c (gtk_combo_box_real_get_active_text): And + implement it here. + + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_get_active_text): + Implement get_active_text by always returning the content of + the entry. + 2005-03-31 Sven Neumann * gtk/gtkbutton.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index dc2247bc66..00676215a5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +2005-04-01 Matthias Clasen + + Make gtk_combo_box_get_active_text do the right thing for + GtkComboBoxEntry (#171373, Robert Staudinger) + + * gtk/gtkcombobox.h: Add a get_active_text vfunc. + + * gtk/gtkcombobox.c (gtk_combo_box_real_get_active_text): And + implement it here. + + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_get_active_text): + Implement get_active_text by always returning the content of + the entry. + 2005-03-31 Sven Neumann * gtk/gtkbutton.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index dc2247bc66..00676215a5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +2005-04-01 Matthias Clasen + + Make gtk_combo_box_get_active_text do the right thing for + GtkComboBoxEntry (#171373, Robert Staudinger) + + * gtk/gtkcombobox.h: Add a get_active_text vfunc. + + * gtk/gtkcombobox.c (gtk_combo_box_real_get_active_text): And + implement it here. + + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_get_active_text): + Implement get_active_text by always returning the content of + the entry. + 2005-03-31 Sven Neumann * gtk/gtkbutton.c diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index d1e83bb68c..6b775479db 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -284,6 +284,7 @@ static gboolean gtk_combo_box_key_press (GtkWidget *widget, gpointer data); static void gtk_combo_box_check_appearance (GtkComboBox *combo_box); +static gchar * gtk_combo_box_real_get_active_text (GtkComboBox *combo_box); /* listening to the model */ static void gtk_combo_box_model_row_inserted (GtkTreeModel *model, @@ -491,6 +492,8 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) binding_set = gtk_binding_set_by_class (klass); + klass->get_active_text = gtk_combo_box_real_get_active_text; + container_class = (GtkContainerClass *)klass; container_class->forall = gtk_combo_box_forall; container_class->add = gtk_combo_box_add; @@ -4750,11 +4753,25 @@ gtk_combo_box_remove_text (GtkComboBox *combo_box, */ gchar * gtk_combo_box_get_active_text (GtkComboBox *combo_box) +{ + GtkComboBoxClass *class; + + g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL); + + class = GTK_COMBO_BOX_GET_CLASS (combo_box); + + if (class->get_active_text) + return (* class->get_active_text) (combo_box); + + return NULL; +} + +static gchar * +gtk_combo_box_real_get_active_text (GtkComboBox *combo_box) { GtkTreeIter iter; gchar *text = NULL; - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL); g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); if (gtk_combo_box_get_active_iter (combo_box, &iter)) diff --git a/gtk/gtkcombobox.h b/gtk/gtkcombobox.h index 79c675837a..e8b2a46cc4 100644 --- a/gtk/gtkcombobox.h +++ b/gtk/gtkcombobox.h @@ -52,11 +52,13 @@ struct _GtkComboBoxClass /* signals */ void (* changed) (GtkComboBox *combo_box); + /* vfuncs */ + gchar * (* get_active_text) (GtkComboBox *combo_box); + /* Padding for future expansion */ void (*_gtk_reserved0) (void); void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); }; diff --git a/gtk/gtkcomboboxentry.c b/gtk/gtkcomboboxentry.c index e8f9f29b7e..6861a67000 100644 --- a/gtk/gtkcomboboxentry.c +++ b/gtk/gtkcomboboxentry.c @@ -49,6 +49,7 @@ static void gtk_combo_box_entry_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static gchar *gtk_combo_box_entry_get_active_text (GtkComboBox *combo_box); static void gtk_combo_box_entry_active_changed (GtkComboBox *combo_box, gpointer user_data); static void gtk_combo_box_entry_contents_changed (GtkEntry *entry, @@ -100,6 +101,7 @@ gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass) { GObjectClass *object_class; GtkWidgetClass *widget_class; + GtkComboBoxClass *combo_class; object_class = (GObjectClass *)klass; object_class->set_property = gtk_combo_box_entry_set_property; @@ -108,6 +110,9 @@ gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass) widget_class = (GtkWidgetClass *)klass; widget_class->mnemonic_activate = gtk_combo_box_entry_mnemonic_activate; + combo_class = (GtkComboBoxClass *)klass; + combo_class->get_active_text = gtk_combo_box_entry_get_active_text; + g_object_class_install_property (object_class, PROP_TEXT_COLUMN, g_param_spec_int ("text_column", @@ -383,5 +388,16 @@ gtk_combo_box_entry_new_text (void) return entry_box; } +static gchar * +gtk_combo_box_entry_get_active_text (GtkComboBox *combo_box) +{ + GtkComboBoxEntry *combo = GTK_COMBO_BOX_ENTRY (combo_box); + + if (combo->priv->entry) + return g_strdup (gtk_entry_get_text (combo->priv->entry)); + + return NULL; +} + #define __GTK_COMBO_BOX_ENTRY_C__ #include "gtkaliasdef.c"