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 631167 - GtkComboBox with has-entry=true should not require a text column
GtkComboBox with has-entry=true should not require a text column
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkComboBox
unspecified
Other Linux
: Normal normal
: 3.2
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2010-10-02 12:39 UTC by Murray Cumming
Modified: 2011-10-06 09:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Adds "format-entry-text" signal (9.16 KB, patch)
2011-01-26 14:40 UTC, Tristan Van Berkom
accepted-commit_now Details | Review

Description Murray Cumming 2010-10-02 12:39:56 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.
Comment 1 Matthias Clasen 2010-10-04 14:25:50 UTC
Do you have a patch to see how this would look ?
Comment 2 Murray Cumming 2010-10-05 10:29:39 UTC
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.
Comment 3 Matthias Clasen 2010-10-13 18:50:36 UTC
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.
Comment 4 Murray Cumming 2010-10-13 19:57:51 UTC
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.
Comment 5 Tristan Van Berkom 2011-01-26 14:40:20 UTC
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.
Comment 6 Murray Cumming 2011-03-12 15:19:14 UTC
Now that we have branched, is this OK to push to master?
Comment 7 Matthias Clasen 2011-05-01 01:22:06 UTC
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 ?
Comment 8 Murray Cumming 2011-10-06 09:43:10 UTC
Pushed to master with those changes, and changing the since line to 3.4.