diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-02-19 13:27:51 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-02-19 13:27:51 -0500 |
commit | 84b259d0768e6fcccb5e5d2b0ed05c9bd3beaab1 (patch) | |
tree | fd3f474e2e7ce276ce3b242d9cc4321d8c9a0945 /gtk/gtkcomboboxtext.c | |
parent | 8d9144a0c4d4a8f8a997d439e4c0486718e04956 (diff) | |
download | gtk+-84b259d0768e6fcccb5e5d2b0ed05c9bd3beaab1.tar.gz |
Make gtk_combo_box_text_get_active_text() behave as documented
If there is an entry, it is supposed to return the contents
of the entry. Pointed out by Allin Cottrell,
https://bugzilla.gnome.org/show_bug.cgi?id=642681
Diffstat (limited to 'gtk/gtkcomboboxtext.c')
-rw-r--r-- | gtk/gtkcomboboxtext.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c index ba6c051179..f1102cb1af 100644 --- a/gtk/gtkcomboboxtext.c +++ b/gtk/gtkcomboboxtext.c @@ -563,12 +563,13 @@ gtk_combo_box_text_remove_all (GtkComboBoxText *combo_box) * gtk_combo_box_text_get_active_text: * @combo_box: A #GtkComboBoxText * - * Returns the currently active string in @combo_box, or %NULL if none - * is selected. If @combo_box contains an entry, this function will return - * its contents (which will not necessarily be an item from the list). + * Returns the currently active string in @combo_box, or %NULL + * if none is selected. If @combo_box contains an entry, this + * function will return its contents (which will not necessarily + * be an item from the list). * - * Returns: a newly allocated string containing the currently active text. - * Must be freed with g_free(). + * Returns: a newly allocated string containing the currently + * active text. Must be freed with g_free(). * * Since: 2.24 */ @@ -580,7 +581,14 @@ gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box) g_return_val_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box), NULL); - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) + if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (combo_box))) + { + GtkWidget *entry; + + entry = gtk_bin_get_child (GTK_BIN (combo_box)); + text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + } + else if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) { GtkTreeModel *model; gint text_column; |