Commit 1aa00e52 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Support separators in combo boxes and more generally in tree views

2004-07-07  Matthias Clasen  <mclasen@redhat.com>

	Support separators in combo boxes and more generally in tree
	views  (#135873):

	* gtk/gtkcombobox.h:
	* gtk/gtkcombobox.c (gtk_combo_box_get_row_separator_column):
	* gtk/gtkcombobox.c (gtk_combo_box_set_row_separator_column):
	Add a ::row-separator-column property with getter and setter,
	which can indicate a boolean model column to determine which
	rows are separators.

	* gtk/gtkcombobox.c: Display separator rows as separator menu
	items in menu mode, and by using the new treeview separator
	functionality in list mode.

	* gtk/gtktreeview.h:
	* gtk/gtktreeview.c (gtk_tree_view_get_row_separator_func):
	* gtk/gtktreeview.c (gtk_tree_view_set_row_separator_func):
	Add a callback to determine whether a row is a separator.

	* gtk/gtktreeview.c (gtk_tree_view_bin_expose):
	* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
	* gtk/gtktreeview.c (validate_row): Use the new callback
	to determine whether a row is a separator, and draw it
	as a separator then. Since separators should take up less
	vertical space than regular rows, this requires removing
	the redundant MAX(...,expander_size) calls which appear in
	many places. Instead, the MAX() is now only done in
	validate_row(), and only if the row is not a separator.
	To catch possible side effects of this intrusive change,
	I have left EXPANDER_MAX() calls in place of the MAX() calls
	which will emit a warning if something breaks. They should
	be removed before 2.6.

	* gtk/gtktreeselection.c (row_is_selectable): Don't let
	separator rows be selected.

	* tests/testcombo.c (create_blaat): Add a separator column.
parent a346f4a8
2004-07-07 Matthias Clasen <mclasen@redhat.com>
Support separators in combo boxes and more generally in tree
views (#135873):
* gtk/gtkcombobox.h:
* gtk/gtkcombobox.c (gtk_combo_box_get_row_separator_column):
* gtk/gtkcombobox.c (gtk_combo_box_set_row_separator_column):
Add a ::row-separator-column property with getter and setter,
which can indicate a boolean model column to determine which
rows are separators.
* gtk/gtkcombobox.c: Display separator rows as separator menu
items in menu mode, and by using the new treeview separator
functionality in list mode.
* gtk/gtktreeview.h:
* gtk/gtktreeview.c (gtk_tree_view_get_row_separator_func):
* gtk/gtktreeview.c (gtk_tree_view_set_row_separator_func):
Add a callback to determine whether a row is a separator.
* gtk/gtktreeview.c (gtk_tree_view_bin_expose):
* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
* gtk/gtktreeview.c (validate_row): Use the new callback
to determine whether a row is a separator, and draw it
as a separator then. Since separators should take up less
vertical space than regular rows, this requires removing
the redundant MAX(...,expander_size) calls which appear in
many places. Instead, the MAX() is now only done in
validate_row(), and only if the row is not a separator.
To catch possible side effects of this intrusive change,
I have left EXPANDER_MAX() calls in place of the MAX() calls
which will emit a warning if something breaks. They should
be removed before 2.6.
* gtk/gtktreeselection.c (row_is_selectable): Don't let
separator rows be selected.
* tests/testcombo.c (create_blaat): Add a separator column.
Tue Jul 6 22:58:00 2004 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkwindow-x11.c (gdk_x11_window_set_user_time): Fix
......
2004-07-07 Matthias Clasen <mclasen@redhat.com>
Support separators in combo boxes and more generally in tree
views (#135873):
* gtk/gtkcombobox.h:
* gtk/gtkcombobox.c (gtk_combo_box_get_row_separator_column):
* gtk/gtkcombobox.c (gtk_combo_box_set_row_separator_column):
Add a ::row-separator-column property with getter and setter,
which can indicate a boolean model column to determine which
rows are separators.
* gtk/gtkcombobox.c: Display separator rows as separator menu
items in menu mode, and by using the new treeview separator
functionality in list mode.
* gtk/gtktreeview.h:
* gtk/gtktreeview.c (gtk_tree_view_get_row_separator_func):
* gtk/gtktreeview.c (gtk_tree_view_set_row_separator_func):
Add a callback to determine whether a row is a separator.
* gtk/gtktreeview.c (gtk_tree_view_bin_expose):
* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
* gtk/gtktreeview.c (validate_row): Use the new callback
to determine whether a row is a separator, and draw it
as a separator then. Since separators should take up less
vertical space than regular rows, this requires removing
the redundant MAX(...,expander_size) calls which appear in
many places. Instead, the MAX() is now only done in
validate_row(), and only if the row is not a separator.
To catch possible side effects of this intrusive change,
I have left EXPANDER_MAX() calls in place of the MAX() calls
which will emit a warning if something breaks. They should
be removed before 2.6.
* gtk/gtktreeselection.c (row_is_selectable): Don't let
separator rows be selected.
* tests/testcombo.c (create_blaat): Add a separator column.
Tue Jul 6 22:58:00 2004 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkwindow-x11.c (gdk_x11_window_set_user_time): Fix
......
2004-07-07 Matthias Clasen <mclasen@redhat.com>
Support separators in combo boxes and more generally in tree
views (#135873):
* gtk/gtkcombobox.h:
* gtk/gtkcombobox.c (gtk_combo_box_get_row_separator_column):
* gtk/gtkcombobox.c (gtk_combo_box_set_row_separator_column):
Add a ::row-separator-column property with getter and setter,
which can indicate a boolean model column to determine which
rows are separators.
* gtk/gtkcombobox.c: Display separator rows as separator menu
items in menu mode, and by using the new treeview separator
functionality in list mode.
* gtk/gtktreeview.h:
* gtk/gtktreeview.c (gtk_tree_view_get_row_separator_func):
* gtk/gtktreeview.c (gtk_tree_view_set_row_separator_func):
Add a callback to determine whether a row is a separator.
* gtk/gtktreeview.c (gtk_tree_view_bin_expose):
* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
* gtk/gtktreeview.c (validate_row): Use the new callback
to determine whether a row is a separator, and draw it
as a separator then. Since separators should take up less
vertical space than regular rows, this requires removing
the redundant MAX(...,expander_size) calls which appear in
many places. Instead, the MAX() is now only done in
validate_row(), and only if the row is not a separator.
To catch possible side effects of this intrusive change,
I have left EXPANDER_MAX() calls in place of the MAX() calls
which will emit a warning if something breaks. They should
be removed before 2.6.
* gtk/gtktreeselection.c (row_is_selectable): Don't let
separator rows be selected.
* tests/testcombo.c (create_blaat): Add a separator column.
Tue Jul 6 22:58:00 2004 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkwindow-x11.c (gdk_x11_window_set_user_time): Fix
......
2004-07-07 Matthias Clasen <mclasen@redhat.com>
Support separators in combo boxes and more generally in tree
views (#135873):
* gtk/gtkcombobox.h:
* gtk/gtkcombobox.c (gtk_combo_box_get_row_separator_column):
* gtk/gtkcombobox.c (gtk_combo_box_set_row_separator_column):
Add a ::row-separator-column property with getter and setter,
which can indicate a boolean model column to determine which
rows are separators.
* gtk/gtkcombobox.c: Display separator rows as separator menu
items in menu mode, and by using the new treeview separator
functionality in list mode.
* gtk/gtktreeview.h:
* gtk/gtktreeview.c (gtk_tree_view_get_row_separator_func):
* gtk/gtktreeview.c (gtk_tree_view_set_row_separator_func):
Add a callback to determine whether a row is a separator.
* gtk/gtktreeview.c (gtk_tree_view_bin_expose):
* gtk/gtktreeview.c (gtk_tree_view_create_row_drag_icon):
* gtk/gtktreeview.c (validate_row): Use the new callback
to determine whether a row is a separator, and draw it
as a separator then. Since separators should take up less
vertical space than regular rows, this requires removing
the redundant MAX(...,expander_size) calls which appear in
many places. Instead, the MAX() is now only done in
validate_row(), and only if the row is not a separator.
To catch possible side effects of this intrusive change,
I have left EXPANDER_MAX() calls in place of the MAX() calls
which will emit a warning if something breaks. They should
be removed before 2.6.
* gtk/gtktreeselection.c (row_is_selectable): Don't let
separator rows be selected.
* tests/testcombo.c (create_blaat): Add a separator column.
Tue Jul 6 22:58:00 2004 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkwindow-x11.c (gdk_x11_window_set_user_time): Fix
......
This diff is collapsed.
......@@ -94,6 +94,10 @@ void gtk_combo_box_set_model (GtkComboBox *combo_box,
GtkTreeModel *model);
GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box);
void gtk_combo_box_set_row_separator_column (GtkComboBox *combo_box,
gint column);
gint gtk_combo_box_get_row_separator_column (GtkComboBox *combo_box);
/* convenience -- text */
GtkWidget *gtk_combo_box_new_text (void);
void gtk_combo_box_append_text (GtkComboBox *combo_box,
......
......@@ -1319,21 +1319,29 @@ row_is_selectable (GtkTreeSelection *selection,
GtkTreePath *path)
{
GList *list;
gboolean sensitive;
sensitive = FALSE;
GtkTreeIter iter;
gboolean sensitive = FALSE;
if (!gtk_tree_model_get_iter (selection->tree_view->priv->model, &iter, path))
sensitive = TRUE;
if (!sensitive && selection->tree_view->priv->row_separator_func)
{
/* never allow separators to be selected */
if ((* selection->tree_view->priv->row_separator_func) (selection->tree_view->priv->model,
&iter,
selection->tree_view->priv->row_separator_data))
return FALSE;
}
for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
GtkTreeIter iter;
if (!column->visible)
continue;
if (gtk_tree_model_get_iter (selection->tree_view->priv->model, &iter, path))
sensitive = tree_column_is_sensitive (column, selection->tree_view->priv->model, &iter);
else
sensitive = TRUE;
sensitive = tree_column_is_sensitive (column, selection->tree_view->priv->model, &iter);
}
if (!sensitive)
......
This diff is collapsed.
......@@ -124,6 +124,9 @@ typedef gboolean (*GtkTreeViewSearchEqualFunc) (GtkTreeModel *model,
const gchar *key,
GtkTreeIter *iter,
gpointer search_data);
typedef gboolean (*GtkTreeViewRowSeparatorFunc) (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
/* Creators */
......@@ -320,6 +323,12 @@ void gtk_tree_view_set_hover_selection (GtkTreeView *tree_view,
gboolean hover);
gboolean gtk_tree_view_get_hover_selection (GtkTreeView *tree_view);
GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func (GtkTreeView *tree_view);
void gtk_tree_view_set_row_separator_func (GtkTreeView *tree_view,
GtkTreeViewRowSeparatorFunc func,
gpointer data,
GtkDestroyNotify destroy);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
......@@ -127,7 +127,7 @@ create_blaat ()
cellview = gtk_cell_view_new ();
store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING,
GTK_ICON_SIZE_BUTTON, NULL);
......@@ -135,6 +135,7 @@ create_blaat ()
gtk_list_store_set (store, &iter,
0, pixbuf,
1, "gtk-stock-dialog-warning",
2, FALSE,
-1);
pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_STOP,
......@@ -143,6 +144,7 @@ create_blaat ()
gtk_list_store_set (store, &iter,
0, pixbuf,
1, "gtk-stock-stop",
2, FALSE,
-1);
pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_NEW,
......@@ -151,6 +153,7 @@ create_blaat ()
gtk_list_store_set (store, &iter,
0, pixbuf,
1, "gtk-stock-new",
2, FALSE,
-1);
pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_CLEAR,
......@@ -159,6 +162,23 @@ create_blaat ()
gtk_list_store_set (store, &iter,
0, pixbuf,
1, "gtk-stock-clear",
2, FALSE,
-1);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, NULL,
1, "separator",
2, TRUE,
-1);
pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_OPEN,
GTK_ICON_SIZE_BUTTON, NULL);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
1, "gtk-stock-open",
2, FALSE,
-1);
gtk_widget_destroy (cellview);
......@@ -196,8 +216,7 @@ set_sensitive (GtkCellLayout *cell_layout,
path = gtk_tree_model_get_path (tree_model, iter);
indices = gtk_tree_path_get_indices (path);
sensitive = indices[0] % 2;
sensitive = indices[0] != 1;
gtk_tree_path_free (path);
g_object_set (cell, "sensitive", sensitive, NULL);
......@@ -295,7 +314,9 @@ main (int argc, char **argv)
renderer,
set_sensitive,
NULL, NULL);
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 1);
gtk_combo_box_set_row_separator_column (GTK_COMBO_BOX (combobox), 2);
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
/* GtkComboBox (grid mode) */
......
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