After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 149248 - gtk_combo_box_set_active_text()
gtk_combo_box_set_active_text()
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkComboBox
2.5.x
Other Linux
: Normal enhancement
: Small API
Assigned To: gtk-bugs
gtk-bugs
Obsolete patch
Depends on:
Blocks:
 
 
Reported: 2004-08-04 07:59 UTC by Steve Chaplin
Modified: 2013-08-14 01:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (4.13 KB, patch)
2005-04-08 00:54 UTC, Jim Evins
none Details | Review
patch against current 2.10 branch (3.16 KB, patch)
2006-12-26 14:10 UTC, Kjartan Maraas
none Details | Review
missed the header (4.22 KB, patch)
2006-12-26 14:13 UTC, Kjartan Maraas
none Details | Review
Updated to trunk (4.70 KB, patch)
2008-06-16 15:20 UTC, Christian Dywan
none Details | Review

Description Steve Chaplin 2004-08-04 07:59:34 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.
Comment 1 Matthias Clasen 2004-08-12 13:42:02 UTC
How would that work ? Iterate over the model to find a match for the text ?
Comment 2 Steve Chaplin 2004-08-21 08:15:15 UTC
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.
Comment 3 Daniel Kasak 2004-10-21 03:42:00 UTC
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...
Comment 4 Jim Evins 2005-04-08 00:54:47 UTC
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.
Comment 5 Kjartan Maraas 2006-12-26 14:10:19 UTC
Created attachment 78903 [details] [review]
patch against current 2.10 branch

Updated against the current 2.10 source to avoid bitrot
Comment 6 Kjartan Maraas 2006-12-26 14:13:49 UTC
Created attachment 78904 [details] [review]
missed the header

Bah, I missed the header changes.
Comment 7 makuchaku (Mayank) 2007-03-22 16:21:06 UTC
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
Comment 8 Christian Dywan 2008-06-16 15:20:34 UTC
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.
Comment 9 Murray Cumming 2010-10-02 12:32:01 UTC
Can we commit this? And/or the derived class in bug #612396 ?
Comment 10 Matthias Clasen 2013-08-14 01:45:08 UTC
we do have GtkComboBoxText, and gtk_combo_box_set_active_id, which is similar to what you want