Editable toggle (checkbox) in a GtkTreeView?



Hi.  I want a GtkTreeView with an editable text column and an
editable "toggle" (checkbox) column.  My current code has the former,
but the latter does not work yet.  Here is how the two columns are
added to the view:

  renderer = gtk_cell_renderer_text_new();
  column = gtk_tree_view_column_new_with_attributes(
                  _("Regular expression"),
                  renderer,
                  "text", COLUMN_REGEX,
                  "editable", COLUMN_EDITABLE,
                  NULL);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);

  renderer = gtk_cell_renderer_toggle_new();
  column = gtk_tree_view_column_new_with_attributes(
                  _("Negate"),
                  renderer,
                  "active", COLUMN_NEGATE,
                  "activatable", COLUMN_EDITABLE,
                  NULL);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);


The only row in the store is added with this:

  gtk_tree_store_append(store, &iter, NULL);
  gtk_tree_store_set(store, &iter,
                  COLUMN_REGEX, "foo",
                  COLUMN_NEGATE, FALSE,
                  COLUMN_EDITABLE, TRUE,
                  -1);

The store was created with this:

  GtkTreeStore *store = gtk_tree_store_new(3,
                G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);


When I click on a the text field, I can edit it.  When I click on the
checkbox, it does not change.

I've looked at the "Editable Cells" demo in gtk-demo (from the
gtk2-2.2.2-0.ximian.5.3 RPM), but it does not use "toggle" columns.

Has anyone successfully created an editable checkbox in a GtkTreeView?

-- 
Pierre Sarrazin <sarrazip at sympatico dot ca>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]