Re: GtkTree, cell with toggle
- From: Todd Fisher <taf2 lehigh edu>
- To: p s <tuxnduke welho com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GtkTree, cell with toggle
- Date: Sun, 13 Jun 2004 23:09:20 -0700
P s
// setup the toggle column
gtk_tree_view_column_add_attribute( column, cell, "active", COL_ID );
g_signal_connect( cell, "toggled", G_CALLBACK( check_toggled ), treeview );
// an example toggle callback:
void check_toggled( GtkCellRendererToggle *cell, gchar *path_str,
GtkTreeView *view )
{
gboolean value;
guint column_number = GPOINTER_TO_UINT( g_object_get_data( G_OBJECT(
cell ), "column_number" ) );
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model( view );
GtkTreePath *path = gtk_tree_path_new_from_string( path_str );
if( gtk_tree_model_get_iter( model, &iter, path ) ){
gtk_tree_model_get( model, &iter, column_number, &value, -1 );
if( value ){
value = FALSE;
}
else{
value = TRUE;
}
// value = !value;
gtk_tree_store_set( GTK_TREE_STORE( model ), &iter, column_number,
value, -1 );
}
gtk_tree_path_free( path );
}
-todd
p s wrote:
Guess what, that's exactly where I took the example when beginning
this one, but just can't get past this issue with the hints hidden
there. But thanks for the huge efford any way tod.
P_s
Todd Fisher wrote:
you should have a look at this tutorial:
http://scentric.net/tutorial/sec-editable-cells.html
p s wrote:
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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]