GNOME Bugzilla – Bug 135875
combobox doesn't support insensitive items
Last modified: 2011-02-04 16:17:01 UTC
another regression against GtkOptionMenu; I don't think GtkCombo supports this... gtk_tree_selection_set_select_function() may be relevant here
Hmm, the fact that the treeview is private (and the fact that we want to handle menu mode transparently) makes this an api bug. I think we need something like: gboolean (*GtkComboBoxSelectionFunc)(GtkTreeModel *model, GtkTreePath *path, gboolean currently_selected, gpointer data); void gtk_combo_box_set_select_function (GtkComboBoxSelectionFunc func, gpointer data, GtkDestroyNotify destroy); We have to omit the GtkTreeSelection argument from the corresponding GtkTreeSelection functionality, since we don't have a tree selection object in menu mode.
Created attachment 25614 [details] [review] patch adding selection_func support
Created attachment 25615 [details] [review] patch making some items in testcombo.c insensitive
The attached combobox patch adds the outlined support for a tree_view_selection-like selection function. It is not perfect: when moving the selection with up/down in the tree view, one still has to step over insensitive items. The patch to testcombo.c shows that this is not really a useable API yet; you basically have to code the "graying out" yourself. We should probably have a convenience api like gtk_combo_box_set_sensitive_column() which would take the index of a boolean column and set up selection function and cell data function for the text column automatically. What the patch currently doesn't cover is setting up the sensitivity of menuitems in menu mode. That should be a simple loop over all items before popping up the menu.
Created attachment 25617 [details] [review] new patch which also supports menu mode
*** Bug 138288 has been marked as a duplicate of this bug. ***
I just run into this problem while migrating GIMP to GtkComboBox. Would be nice to get it fixed as soon as possible (which means 2.6 probably).
*** Bug 137894 has been marked as a duplicate of this bug. ***
insensitive items are supported now, see testcombo.c for how.
That's a pretty evil hack, btw. If I call gtk_cell_layout_set_cell_data_func() on a combo-box, the GtkCellLayout which gets passed to the callback function is _not_ the combo-box but one the internal widgets which are supposed to be hidden in the combo :(
true, but it would be hard to avoid that. And we don't pass the internal widgets, just the cell layouts, if that makes any difference...