summaryrefslogtreecommitdiff
path: root/tests/testcellarea.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-12 19:25:07 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-12 19:25:07 +0900
commit38666b406fe8b2f08e0d67014daea951c6efea73 (patch)
tree1a7e21c606b854a99258d5090c81e813517993d2 /tests/testcellarea.c
parent7e821aa980d7219741946195be38a99d75407264 (diff)
downloadgtk+-38666b406fe8b2f08e0d67014daea951c6efea73.tar.gz
Ironed out the kinks in editing apis for GtkCellArea
- Added gtk_cell_area_aligned_cell_area() to get the aligned internal area use by a cell (for focus painting and for event areas). - Provide the event area in "editing-started" signal - Fire "remove-editable" when editing is canceled by the user, an implementing layouting widget need only catch "editing-started" and "remove-editable" now. - CellAreaScaffold/testcellarea now edit textrenderers.
Diffstat (limited to 'tests/testcellarea.c')
-rw-r--r--tests/testcellarea.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/testcellarea.c b/tests/testcellarea.c
index 0acf2ebbb5..c6db6ae5e5 100644
--- a/tests/testcellarea.c
+++ b/tests/testcellarea.c
@@ -291,7 +291,7 @@ focus_list_model (void)
static void
cell_toggled (GtkCellRendererToggle *cell_renderer,
- gchar *path,
+ const gchar *path,
CellAreaScaffold *scaffold)
{
GtkTreeModel *model = cell_area_scaffold_get_model (scaffold);
@@ -307,6 +307,23 @@ cell_toggled (GtkCellRendererToggle *cell_renderer,
gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
}
+static void
+cell_edited (GtkCellRendererToggle *cell_renderer,
+ const gchar *path,
+ const gchar *new_text,
+ CellAreaScaffold *scaffold)
+{
+ GtkTreeModel *model = cell_area_scaffold_get_model (scaffold);
+ GtkTreeIter iter;
+
+ g_print ("Cell edited with new text '%s' !\n", new_text);
+
+ if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
+ return;
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_NAME, new_text, -1);
+}
+
static GtkWidget *
focus_scaffold (void)
{
@@ -329,7 +346,9 @@ focus_scaffold (void)
gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE);
gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_NAME);
- /* Catch signal ... */
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (cell_edited), scaffold);
+
focus_renderer = renderer = gtk_cell_renderer_toggle_new ();
g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL);
gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE);