RE: gtk_selection_get_selected()



On Tue, 2003-04-08 at 10:44, martyn 2 russell bt com wrote:
GtkListStore *list;

NOTE - this is a LIST not a TREE.
ListStores are TreeModels in Gtk+
selection = gtk_tree_view_get_selection(view);
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
if((gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection),
                  GTK_TREE_MODEL(&list),
                  &iter))

This should be GTK_LIST_MODEL(&list)
GTK_TREE_MODEL is correct.  I don't think there is a GTK_LIST_MODEL. 
GtkListStores implement the GtkTreeModel interface which allows
GtkTreeViews to display them.   The whole new GtkTree code is 
very well
thought out and very flexable.

Yes you are right... sorry, Doh :)

But as Owen points out, do it the way he suggests, generally I would use:

        GtkTreeSelection *selection = NULL;
        GtkTreeModel *model = NULL;
        GtkTreeIter iter;

        if((selection =
GTK_TREE_SELECTION(gtk_tree_view_get_selection(mytreeview))) == NULL)
        {
                g_warning("selection is NULL");
                return FALSE;
        }       

        gtk_tree_selection_get_selected(selection, &model, &iter);

        .
        .
        .

Regards,
Martyn



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