summaryrefslogtreecommitdiff
path: root/tests/testcellarea.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-10 22:25:13 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-10 22:25:13 +0900
commit524110f9025b149241747979003a3f243e907891 (patch)
tree5bc0d8048a88a3851f0d86cd8c152a84145e5880 /tests/testcellarea.c
parent4643d90c5faaeacbd099359082b366e86e8d6de2 (diff)
downloadgtk+-524110f9025b149241747979003a3f243e907891.tar.gz
Focus driving in GtkCellArea now works.
- Fixed focus driving in GtkCellArea with refined apis - Added gtk_cell_area_activate() to be called when the area has focus (to activate or start editing the focused cell) - Added support for this in cellareascaffold - testcellarea now watches the "toggled" signal for a toggle renderer and updates the model state accordingly, this currently works with keyboard navigation, however focus is still not painted on cells.
Diffstat (limited to 'tests/testcellarea.c')
-rw-r--r--tests/testcellarea.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/testcellarea.c b/tests/testcellarea.c
index b501135f6c..d547f71e3b 100644
--- a/tests/testcellarea.c
+++ b/tests/testcellarea.c
@@ -287,6 +287,24 @@ focus_list_model (void)
return (GtkTreeModel *)store;
}
+static void
+cell_toggled (GtkCellRendererToggle *cell_renderer,
+ gchar *path,
+ CellAreaScaffold *scaffold)
+{
+ GtkTreeModel *model = cell_area_scaffold_get_model (scaffold);
+ GtkTreeIter iter;
+ gboolean active;
+
+ g_print ("Cell toggled !\n");
+
+ if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
+ return;
+
+ gtk_tree_model_get (model, &iter, FOCUS_COLUMN_CHECK, &active, -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
+}
+
static GtkWidget *
focus_scaffold (void)
{
@@ -315,6 +333,9 @@ focus_scaffold (void)
gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE);
gtk_cell_area_attribute_connect (area, renderer, "active", FOCUS_COLUMN_CHECK);
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (cell_toggled), scaffold);
+
renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (renderer),
"wrap-mode", PANGO_WRAP_WORD,
@@ -334,6 +355,8 @@ focus_cell_area (void)
GtkWidget *scaffold, *frame, *vbox, *hbox;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ hbox = gtk_hbox_new (FALSE, 4);
+ gtk_widget_show (hbox);
scaffold = focus_scaffold ();
@@ -345,7 +368,18 @@ focus_cell_area (void)
gtk_container_add (GTK_CONTAINER (frame), scaffold);
- gtk_container_add (GTK_CONTAINER (window), frame);
+ gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+
+ /* Now add some controls */
+ vbox = gtk_vbox_new (FALSE, 4);
+ gtk_widget_show (vbox);
+ gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ widget = gtk_check_button_new_with_label ("check button");
+ gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), hbox);
gtk_widget_show (window);
}