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 382291 - Automatically dim the combobox when the model is empty
Automatically dim the combobox when the model is empty
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkComboBox
2.10.x
Other All
: Normal normal
: ---
Assigned To: Sven Herzberg
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-12-04 16:04 UTC by Tommi Komulainen
Modified: 2017-03-03 14:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (5.97 KB, patch)
2007-04-12 14:20 UTC, Carlos Garnacho
none Details | Review
Updated Patch (8.31 KB, patch)
2008-05-13 08:57 UTC, Sven Herzberg
none Details | Review
Updated Patch (8.84 KB, patch)
2008-05-13 10:28 UTC, Sven Herzberg
none Details | Review
Final Version (8.84 KB, patch)
2008-05-13 11:43 UTC, Sven Herzberg
none Details | Review
Updated according to comments (7.38 KB, patch)
2008-06-04 12:42 UTC, Christian Dywan
none Details | Review
Correct patch this time (7.37 KB, patch)
2008-06-06 09:15 UTC, Christian Dywan
none Details | Review
Implement button-sensitivity, default to _AUTO (7.55 KB, patch)
2008-06-19 13:31 UTC, Christian Dywan
committed Details | Review
Migration hint for README (696 bytes, patch)
2008-08-04 12:56 UTC, Christian Dywan
committed Details | Review

Description Tommi Komulainen 2006-12-04 16:04:27 UTC
When the combobox model is empty there's little sense in inviting the user to pop up the list, only to notice it is empty. To avoid this the combobox could make the button insensitive when the model is empty. Especially with comboboxentry (like search history) where the developer has no access to the popdown button, this would be most convenient as the combobox already has all the information.

Since there is the valid use case for populating the list from a database just before displaying it, this would probably need to be a boolean property.
Comment 1 Carlos Garnacho 2007-04-12 14:20:06 UTC
Created attachment 86237 [details] [review]
patch

"empty-sensitive" is the best property name I could find, please feel free anybody to suggest a better name
Comment 2 Murray Cumming 2007-05-04 20:52:43 UTC
Bug #145904 is also relevant.
Comment 3 Christian Persch 2007-08-19 20:36:47 UTC

*** This bug has been marked as a duplicate of 129463 ***
Comment 4 Tommi Komulainen 2007-08-20 08:01:40 UTC
Christian, this bug is about preventing popping up an empty list/menu, whereas bug 129463 is about the looks of the popup. Not the same thing.
Comment 5 Christian Persch 2007-08-20 22:00:54 UTC
(Yes, I'm sorry, I duped this bug instead in error.)
Comment 6 Sven Herzberg 2008-02-11 14:43:25 UTC
(In reply to comment #1)
> Created an attachment (id=86237) [edit]
> patch
> 
> "empty-sensitive" is the best property name I could find, please feel free
> anybody to suggest a better name

What about the opposite? "always-sensitive"?
Comment 7 Björn Lindqvist 2008-04-08 14:19:15 UTC
Is this report mutually exclusive with bug 145904? Otherwise making the combo box insensitive when the model is empty seem better than the status quo. And Carlos patch is quite nice. Also, maybe the default setting should be to make the combo box insensitive when empty?
Comment 8 Sven Herzberg 2008-05-13 08:57:28 UTC
Created attachment 110834 [details] [review]
Updated Patch

Updated the patch:
* added ChangeLog entry
* added prototypes to gtk/gtkcombobox.h
* changed the property name to "always-sensitive" (discussed with carlos, seems
  to be easier to understand)
* default to insensitive buttons
* negated the if-condition in update_always_sensitive() to apply DeMorgan rules
  to get rid of all the negations in the condition, seems to be easier to
  understand now

Comments?
Comment 9 Sven Herzberg 2008-05-13 10:28:01 UTC
Created attachment 110842 [details] [review]
Updated Patch

Changes to the last version:
* use "sensitivity" in the same way as it is used in GtkRange
* fix the ChangeLog message
Comment 10 Michael Natterer 2008-05-13 11:29:36 UTC
After fixing the two tiny things we chatted about, this patch
looks fine to me to commit.
Comment 11 Sven Herzberg 2008-05-13 11:43:27 UTC
Created attachment 110847 [details] [review]
Final Version

Final version, awaiting kris' approval…
Comment 12 Kristian Rietveld 2008-05-19 10:16:44 UTC
Apparently one of the problems I/we had with the change is already mentioned in the opening comment of this bug and this has been changed into a property-controlled feature instead.  Should be good to go in IMHO.

Couple of comments on the patch:
 - You probably also want to call gtk_combo_box_update_sensitivity() from  gtk_combo_box_set_model().

 - The documentation for gtk_combo_box_set_sensitivity() talks about "menu items", this is better worded as "items" since the combo box can do both menus and lists. (Total nitpick, I know ;)

 - I am not at all sure if "AUTO" is a good default for this property; there is a very good chance that existing subclasses of GtkComboBox already depend on the fact that the arrow is always sensitive -- this would be broken by this change.
Comment 13 Christian Dywan 2008-06-04 12:42:50 UTC
Created attachment 112121 [details] [review]
Updated according to comments

I updated the patch according to the above comments and also confirmed with Sven to change the default sensitivity to On instead of Auto.
Comment 14 Christian Dywan 2008-06-06 09:15:02 UTC
Created attachment 112265 [details] [review]
Correct patch this time

I'm sorry, I attached the wrong (old) patch before, this is the right one. The default value is actually _ON now.
Comment 15 Tim Janik 2008-06-19 11:25:59 UTC
I think the property should better be named ::button-sensitivity, it's not inconceivable that combobox sensitivity itself should also be altered in the future.

(In reply to comment #12)
>  - I am not at all sure if "AUTO" is a good default for this property; there is
> a very good chance that existing subclasses of GtkComboBox already depend on
> the fact that the arrow is always sensitive -- this would be broken by this
> change.

I agree with Kris in theory, but think this feature is going to be rather unused if not enabled by default. And for the vast majority of comboboxes, AUTO is going to be a beneficial default in terms of usability. We had the same consideration with GtkRange stepper sensitivity, and also dared to choose AUTO there for the better. The only use case that was broken there was Gnumeric and that was quickly fixed after we provided migration instructions.

Bottom line, we should pick AUTO here and add an entry to the release notes in Gtk's README that shows how to readjust a combobox for the old behavior.
Comment 16 Christian Dywan 2008-06-19 13:31:26 UTC
Created attachment 113041 [details] [review]
Implement button-sensitivity, default to _AUTO

I agree since the property actually only referes to the button, it's probably the better idea to name it accordingly.

So I updated the patch and renamed the property to button-sensitivity.
Comment 17 Tim Janik 2008-07-24 13:34:01 UTC
Thanks the last patch looks good and can go in. However i still miss an addition to README along the lines of the GtkRange migration instructions ;)
Comment 18 Christian Dywan 2008-08-04 12:56:35 UTC
Created attachment 115824 [details] [review]
Migration hint for README

This is the migration hint for the README file, pointing out the new behaviour and how to manipulate it if needed.
Comment 19 Tim Janik 2008-08-04 14:00:29 UTC
thanks, very good, please apply. ;)
Comment 20 Matthias Clasen 2008-08-04 23:19:44 UTC
2008-08-04  Matthias Clasen  <mclasen@redhat.com>

        Bug 382291 – Automatically dim the combobox when the model is empty

        * gtk/gtk.symbols:
        * gtkcombobox.[hc]: Add a GtkComboBox::button-sensitivity
        property with getter and setter to control the sensitity of
        empty combo boxes. Patch by Carlos Garnacho, Sven Herzberg,
        Christian Dywan and others.

        * README.in: Add a note about automatic combobox sensitivity.