Commit a70e6664 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

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.
parent 3180e453
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.
2006-06-02 Kristian Rietveld <kris@imendio.com>
* gtk/gtktreemodelfilter.c
......
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.
2006-06-02 Kristian Rietveld <kris@imendio.com>
* gtk/gtktreemodelfilter.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,
......
......@@ -1231,44 +1231,11 @@ gtk_tree_selection_unselect_range (GtkTreeSelection *selection,
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
static gboolean
tree_column_is_sensitive (GtkTreeViewColumn *column,
GtkTreeModel *model,
GtkTreeIter *iter)
{
GList *cells, *list;
gboolean sensitive;
gboolean visible;
gtk_tree_view_column_cell_set_cell_data (column, model,
iter, FALSE, FALSE);
cells = gtk_tree_view_column_get_cell_renderers (column);
list = cells;
while (list)
{
g_object_get (list->data,
"sensitive", &sensitive,
"visible", &visible,
NULL);
if (visible && sensitive)
break;
list = list->next;
}
g_list_free (cells);
return sensitive;
}
gboolean
_gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
GtkRBNode *node,
GtkTreePath *path)
{
GList *list;
GtkTreeIter iter;
gboolean sensitive = FALSE;
......@@ -1284,19 +1251,6 @@ _gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
return FALSE;
}
for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
if (!column->visible)
continue;
sensitive = tree_column_is_sensitive (column, selection->tree_view->priv->model, &iter);
}
if (!sensitive)
return FALSE;
if (selection->user_func)
return (*selection->user_func) (selection, selection->tree_view->priv->model, path,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),
......@@ -1479,10 +1433,7 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
{
path = _gtk_tree_view_find_path (selection->tree_view, tree, node);
if (!select)
toggle = TRUE;
else
toggle = _gtk_tree_selection_row_is_selectable (selection, node, path);
toggle = _gtk_tree_selection_row_is_selectable (selection, node, path);
gtk_tree_path_free (path);
}
......
......@@ -7421,11 +7421,6 @@ gtk_tree_view_row_changed (GtkTreeModel *model,
if (tree == NULL)
goto done;
/* Check if the node became insensitive, and if so, unselect it */
if (!_gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
node, path))
gtk_tree_selection_unselect_path (tree_view->priv->selection, path);
if (tree_view->priv->fixed_height_mode
&& tree_view->priv->fixed_height >= 0)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment