GNOME Bugzilla – Bug 631167
GtkComboBox with has-entry=true should not require a text column
Last modified: 2011-10-06 09:43:10 UTC
GtkComboBoxEntry currently requires its model to have a text columns. That's understandable because it's really more of a GtkEntry plus a drop-down than a GtkComboBox with an entry. However, this makes it awkward to use some models. It would be nice if we could specify the text representation of the model's values via a callback instead.
Do you have a patch to see how this would look ?
No, not yet, and I've worked around it (awkwardly) for now. But I'd like to keep this open in case I can get Tristan to do it.
Rough plan: Add a new signal gchar *get_active_text (GtkComboBox *combo) with an accumulator that only ever runs a single signal handler and returns its result. The default handler does what we currently do and uses text_column.
Sounds good to me, though I generally prefer a set_something_func() for these cases. Signals with non-simple return types are awkward for bindings because of the need to worry about ownership, and it feels odd to allow multiple signal handlers when just one result is used . But it's fine if you prefer that.
Created attachment 179371 [details] [review] Adds "format-entry-text" signal This patch takes mclasen's suggested approach which we also use for formatting the text displayed in a GtkScale.
Now that we have branched, is this OK to push to master?
Review of attachment 179371 [details] [review]: Feel free to commit with these two fixes. ::: gtk/gtkcombobox.c @@ +611,3 @@ + * + * Here's an example signal handler which fetches data from the model and + * displays it in the entry. The docs need to say what the default handler does. ::: gtk/gtkcombobox.h @@ +60,1 @@ Forgot to remove padding here ?
Pushed to master with those changes, and changing the since line to 3.4.