summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-03-16 07:16:29 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-03-16 07:16:29 +0000
commiteebd4f1c4bba4d1a2b9a5e0cfd9fd34f318ee84d (patch)
tree91455a0e3e70fcaa066b6c9b5545fc329a22609e /demos
parentf0ce2b12a2aeceec86a04692365bb894bd4e9cb0 (diff)
downloadgtk+-eebd4f1c4bba4d1a2b9a5e0cfd9fd34f318ee84d.tar.gz
Also demonstrate GtkCellRenderer::editing-started and separators.
2005-03-16 Matthias Clasen <mclasen@redhat.com> * demos/gtk-demo/editable_cells.c: Also demonstrate GtkCellRenderer::editing-started and separators.
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/editable_cells.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/demos/gtk-demo/editable_cells.c b/demos/gtk-demo/editable_cells.c
index 4328134382..524b1e8c2b 100644
--- a/demos/gtk-demo/editable_cells.c
+++ b/demos/gtk-demo/editable_cells.c
@@ -2,7 +2,9 @@
*
* This demo demonstrates the use of editable cells in a GtkTreeView. If
* you're new to the GtkTreeView widgets and associates, look into
- * the GtkListStore example first.
+ * the GtkListStore example first. It also shows how to use the
+ * GtkCellRenderer::editing-started signal to do custom setup of the
+ * editable widget.
*
* The cell renderers used in this demo are GtkCellRendererText and
* GtkCellRendererCombo.
@@ -100,7 +102,6 @@ static GtkTreeModel *
create_numbers_model (void)
{
#define N_NUMBERS 10
-
gint i = 0;
GtkListStore *model;
GtkTreeIter iter;
@@ -168,6 +169,32 @@ remove_item (GtkWidget *widget, gpointer data)
}
}
+static gboolean
+separator_row (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ GtkTreePath *path;
+ gint idx;
+
+ path = gtk_tree_model_get_path (model, iter);
+ idx = gtk_tree_path_get_indices (path)[0];
+
+ gtk_tree_path_free (path);
+
+ return idx == 5;
+}
+
+static void
+editing_started (GtkCellRenderer *cell,
+ GtkCellEditable *editable,
+ const gchar *path,
+ gpointer data)
+{
+ gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (editable),
+ separator_row, NULL, NULL);
+}
+
static void
cell_edited (GtkCellRendererText *cell,
const gchar *path_string,
@@ -234,6 +261,8 @@ add_columns (GtkTreeView *treeview,
NULL);
g_signal_connect (renderer, "edited",
G_CALLBACK (cell_edited), items_model);
+ g_signal_connect (renderer, "editing-started",
+ G_CALLBACK (editing_started), NULL);
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_ITEM_NUMBER));
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),