diff options
author | Kristian Rietveld <kris@imendio.com> | 2006-06-02 18:55:59 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2006-06-02 18:55:59 +0000 |
commit | a70e666423928276c87632e7aef594ff68b6abfa (patch) | |
tree | 8da974f9ab6f78565b7fa33ee9d88b0617a5c6c7 /gtk/gtkcombobox.c | |
parent | 3180e4535629b9872819923bf59f2f97f17217ac (diff) | |
download | gdk-pixbuf-a70e666423928276c87632e7aef594ff68b6abfa.tar.gz |
Separate sensitive/selectable properties.
2006-06-02 Kristian Rietveld <kris@imendio.com>
Separate sensitive/selectable properties.
* gtk/gtktreeselection.c (tree_column_is_sensitive): remove,
(_gtk_tree_selection_row_is_selectable): remove checks to see if at
least one column is sensitive,
(gtk_tree_selection_real_select_node): remove code which enables
insensitive rows to always be unselected.
* gtk/gtktreeview.c (gtk_tree_view_row_changed): remove code
that unselects a node if it just became insensitive.
* gtk/gtkcombobox.c (gtkcombo_box_list_select_func): new function,
based on the at least one column sensitive check from
_gtk_tree_selection_row_is_selectable(),
(gtk_combo_box_list_setup): set selection function on tree selection.
Diffstat (limited to 'gtk/gtkcombobox.c')
-rw-r--r-- | gtk/gtkcombobox.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 35f2e1360..46258acff 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -339,6 +339,12 @@ static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget, GdkEventButton *event, gpointer data); +static gboolean gtk_combo_box_list_select_func (GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_currently_selected, + gpointer data); + static void gtk_combo_box_list_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, @@ -3291,6 +3297,9 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box) combo_box->priv->tree_view = gtk_tree_view_new (); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); + gtk_tree_selection_set_select_function (sel, + gtk_combo_box_list_select_func, + NULL, NULL); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (combo_box->priv->tree_view), FALSE); gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view), @@ -3746,6 +3755,50 @@ gtk_combo_box_list_enter_notify (GtkWidget *widget, return TRUE; } +static gboolean +gtk_combo_box_list_select_func (GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_currently_selected, + gpointer data) +{ + GList *list; + gboolean sensitive = FALSE; + + for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next) + { + GList *cells, *cell; + gboolean cell_sensitive, cell_visible; + GtkTreeIter iter; + GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data); + + if (!column->visible) + continue; + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_view_column_cell_set_cell_data (column, model, &iter, + FALSE, FALSE); + + cell = cells = gtk_tree_view_column_get_cell_renderers (column); + while (cell) + { + g_object_get (cell->data, + "sensitive", &cell_sensitive, + "visible", &cell_visible, + NULL); + + if (cell_visible && cell_sensitive) + break; + + cell = cell->next; + } + g_list_free (cells); + + sensitive = cell_sensitive; + } + + return sensitive; +} static void gtk_combo_box_list_row_changed (GtkTreeModel *model, |