GNOME Bugzilla – Bug 382291
Automatically dim the combobox when the model is empty
Last modified: 2017-03-03 14:30:44 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.
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
Bug #145904 is also relevant.
*** This bug has been marked as a duplicate of 129463 ***
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.
(Yes, I'm sorry, I duped this bug instead in error.)
(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"?
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?
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?
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
After fixing the two tiny things we chatted about, this patch looks fine to me to commit.
Created attachment 110847 [details] [review] Final Version Final version, awaiting kris' approval…
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.
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.
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.
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.
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.
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 ;)
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.
thanks, very good, please apply. ;)
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.