On Mon, 2005-11-21 at 10:54 +0000, Axel Simon wrote: > On Mon, 2005-11-21 at 21:31 +1100, ashley maher wrote: > > G'day, > > > > I have followed the gtk tree view tutorial at: > > > > http://scentric.net/tutorial/. > > > > The tutorial is very good. However section: 3.5 deals with Retrieving > > row data. > > > > This works well for data to stdout. > > > > However I can't see in the tutorial, nor has google helped, where to > > find an example where the callback function does not deal with the data > > directly but passes the data retrieved back to the main programme. > > The example shows the "advanced" version of retrieving data, namely by > using a call back function. There is nothing that prevents you from > iterating through the model (with a GtkTreeIter) and call > gtk_tree_model_get directly on the model. That way you have the data > where you want it: in your main program. > > I hope this is what you've asked for, > Axel. > > > Thanks Alex,
It did give me a direction. I think you got two different tutorials confused. I was referring to gtktree tutorial the advanced data retrieval is in the gtk tutorial. Specifically I need to return the value of a cell if and only if a row has been double clicked. Hence I've persevered with the call-back functions as suggested by the gtktree-view tutorial. So it occurred to me that a properly written c_handler should return the data required. This has proven not so. Specifically my attempt: #define STRCPY(x) strcpy(malloc(strlen(x)+1), x) ......... ......... ......... ......... unsigned char *s1; ......... ......... ......... ......... g_signal_connect(treeview, "row-activated", G_CALLBACK(gtree_onSelection), &s1); return s1; } static void gtree_onSelection (GtkTreeView *treeview, gpointer *data) { GtkTreeSelection *sel; GtkTreeIter selected_row; /* the iter I've been looking at */ GtkTreeModel *model; gchar *key; sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); g_assert(gtk_tree_selection_get_mode(sel) == GTK_SELECTION_SINGLE); /* Check if a row is selected or not */ /* This will only work in SINGLE or BROWSE mode! */ if (gtk_tree_selection_get_selected(sel, &model, &selected_row)) { gtk_tree_model_get (model, &selected_row, 0, &key, -1); *data = STRCPY(key); g_free(key); } else { printf ("Something\n\n"); } gtk_main_quit(); } Just is not getting me anywhere. Hence my question if somebody had a working example somewhere as I expected it to be a common problem to solve. I just hadn't come across a working example anywhere. Of course if I've totally missed the point please feel free to be blunt. Regards, Ashley _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list