GtkTree, cell with toggle
- From: p s <tuxnduke welho com>
- To: gtk-app-devel-list gnome org
- Subject: GtkTree, cell with toggle
- Date: Sun, 13 Jun 2004 16:02:52 +0300
I have created a table with GtkTree and on one colums I have a chechbox
to indicate certain boolean value... All in all the tree works ok,
renders properly and I have sortable/clickable headers in the table and
that too works. I experience a problem on a callback where the checkbox
is clicked..
currently I have:
static GtkTreeView * tree;
static GtkTreeStore *store;
...
store = gtk_tree_store_new (N_COLUMNS,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_BOOLEAN, //THE PROBLEM COLUMN
G_TYPE_STRING);
GtkTreeModel * sort_model;
sort_model = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(store));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
ID_COLUMN, GTK_SORT_ASCENDING );
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sort_model));
....
renderer = gtk_cell_renderer_toggle_new ();
column = gtk_tree_view_column_new_with_attributes ("Loaned",
renderer,"active",
LOANED_CHECK_COLUMN, NULL);
g_signal_connect_swapped(G_OBJECT(column),"clicked",G_CALLBACK(sort),(int
*)LOANED_CHECK_COLUMN);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
....
then I have the callBack:
static void cell_toggled_callback (GtkCellRendererToggle *cell, gchar *
path_string, gpointer user_data)
{
GtkTreeIter iter;
GtkTreeModel * sort_model;
GtkTreeModel * model;
// tree is static so I get the model out of it..
model = gtk_tree_view_get_model (tree);
if(gtk_tree_model_get_iter_from_string(model, &iter, path_string))
{
gtk_tree_store_set_value (store, &iter, LOANED_CHECK_COLUMN, TRUE );
}
}
I get:
(moviecatalog:21175): Gtk-CRITICAL **: file gtktreestore.c: line 912
(gtk_tree_store_set_value): assertion `VALID_ITER (iter, tree_store)' failed
ANd the toggle is not updated to checked..
Any clues any one ?
TIA,
P_s
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]