diff options
author | Anders Carlsson <andersca@gnome.org> | 2003-08-13 09:02:57 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@src.gnome.org> | 2003-08-13 09:02:57 +0000 |
commit | 296c4b41bf8b791261feba1d2fed0d1bed319fbb (patch) | |
tree | 5439b2df6c8e596c8ea7788514790ea192a07a6f /tests/testtoolbar.c | |
parent | b3bafcf18016c3fb058916036c95857a27b8c4ca (diff) | |
download | gtk+-296c4b41bf8b791261feba1d2fed0d1bed319fbb.tar.gz |
Add an important column.
2003-08-13 Anders Carlsson <andersca@gnome.org>
* tests/testtoolbar.c: (set_important_func), (important_toggled),
(create_items_list):
Add an important column.
Diffstat (limited to 'tests/testtoolbar.c')
-rw-r--r-- | tests/testtoolbar.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c index 8d5fb7aa52..c633eedcc7 100644 --- a/tests/testtoolbar.c +++ b/tests/testtoolbar.c @@ -235,6 +235,38 @@ homogeneous_toggled(GtkCellRendererToggle *cell, const gchar *path_str, gtk_tree_path_free (path); } + +static void +set_important_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, + GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +{ + GtkToolItem *tool_item; + + gtk_tree_model_get (model, iter, 0, &tool_item, -1); + + g_object_set (G_OBJECT (cell), "active", gtk_tool_item_get_is_important (tool_item), NULL); + g_object_unref (tool_item); +} + +static void +important_toggled(GtkCellRendererToggle *cell, const gchar *path_str, + GtkTreeModel *model) +{ + GtkTreePath *path; + GtkTreeIter iter; + GtkToolItem *tool_item; + + path = gtk_tree_path_new_from_string (path_str); + gtk_tree_model_get_iter (model, &iter, path); + + gtk_tree_model_get (model, &iter, 0, &tool_item, -1); + gtk_tool_item_set_is_important (tool_item, !gtk_tool_item_get_is_important (tool_item)); + g_object_unref (tool_item); + + gtk_tree_model_row_changed (model, path, &iter); + gtk_tree_path_free (path); +} + static GtkListStore * create_items_list (GtkWidget **tree_view_p) { @@ -283,6 +315,14 @@ create_items_list (GtkWidget **tree_view_p) cell, set_homogeneous_func, NULL,NULL); + cell = gtk_cell_renderer_toggle_new (); + g_signal_connect (cell, "toggled", G_CALLBACK (important_toggled), + list_store); + gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view), + -1, "Important", + cell, + set_important_func, NULL,NULL); + g_object_unref (list_store); *tree_view_p = tree_view; |