GNOME Bugzilla – Bug 149248
gtk_combo_box_set_active_text()
Last modified: 2013-08-14 01:45:08 UTC
I think there should be a "gtk_combo_box_set_active_text()" function to complement gtk_combo_box_get_active_text() to allow the text-only combobox the equivalent get/set functionality as gtk_combo_box_get_active_iter() gtk_combo_box_set_active_iter() from the combobox model interface.
How would that work ? Iterate over the model to find a match for the text ?
Yes, search the model to get the index for the text. gtk_combo_box_set_active (combo_box, index) Return an error if no match is found.
I agree with this feature request, and have to do the above solution ( loop through the model, test for a match, select if matched ) in many places in our database apps. It would be great to have a function to automate this. I'm programming in Perl-Gtk. If I knew some C I'd fix it myself, but I unfortunately can't...
Created attachment 39825 [details] [review] Proposed patch Here is a quick patch that adds a gtk_combo_box_set_active_text() method to the gtkcombo box. This is based on the gtk-2-6 branch.
Created attachment 78903 [details] [review] patch against current 2.10 branch Updated against the current 2.10 source to avoid bitrot
Created attachment 78904 [details] [review] missed the header Bah, I missed the header changes.
Tested on revision 17552 Kjartan, can you please update the patch? root@makuchaku:~/gtk/trunk# patch --dry-run --verbose -p0 < patches/gtkcombobox-set-active-text.patch Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Index: gtk/gtkcombobox.c |=================================================================== |RCS file: /cvs/gnome/gtk+/gtk/gtkcombobox.c,v |retrieving revision 1.182 |diff -u -p -r1.182 gtkcombobox.c |--- gtk/gtkcombobox.c 14 Aug 2006 20:12:10 -0000 1.182 |+++ gtk/gtkcombobox.c 26 Dec 2006 14:13:05 -0000 -------------------------- Patching file gtk/gtkcombobox.c using Plan A... Hunk #1 FAILED at 291. Hunk #2 succeeded at 464 with fuzz 1 (offset 4 lines). Hunk #3 succeeded at 5043 with fuzz 1 (offset 107 lines). 1 out of 3 hunks FAILED -- saving rejects to file gtk/gtkcombobox.c.rej Hmm... The next patch looks like a unified diff to me... The text leading up to this was: -------------------------- |Index: gtk/gtkcombobox.h |=================================================================== |RCS file: /cvs/gnome/gtk+/gtk/gtkcombobox.h,v |retrieving revision 1.26 |diff -u -p -r1.26 gtkcombobox.h |--- gtk/gtkcombobox.h 21 Nov 2005 16:01:49 -0000 1.26 |+++ gtk/gtkcombobox.h 26 Dec 2006 14:13:05 -0000 -------------------------- Patching file gtk/gtkcombobox.h using Plan A... Hunk #1 succeeded at 54. Hunk #2 succeeded at 124. done
Created attachment 112843 [details] [review] Updated to trunk This looks like a useful addition, what a shame this bug has become so old already and hardly received much attention. I updated the patch to trunk, added #GtkComboBoxEntry in the documentaiotn, updated the Since tag, corrected the placement and indentation of curly brackets and finally added an entry to gtk.symbols.
Can we commit this? And/or the derived class in bug #612396 ?
we do have GtkComboBoxText, and gtk_combo_box_set_active_id, which is similar to what you want