Re: Getting row numbers

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

 



David Nečas (Yeti) wrote:
>On Wed, May 09, 2007 at 07:23:18AM -0400, tj wrote:>  >>>I am having a terrible time trying to get the selected row number from a tree view, and it seems so easy using gtk_tree_selection_get_selected_rows();>>>>Snippet of code:>>>>    const gchar* txt;>>    GtkTreeSelection  *selection;>>    GtkTreeModel     *model;>>    GtkTreeIter       iter;>>    GtkTreeView* list = GTK_TREE_VIEW(lookup_widget(myWidget,>>							"theList"));>>    >>    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));>>    if (gtk_tree_selection_get_selected(selection, &model, &iter)){>>      gchar *name;>>      >>      gtk_tree_model_get (model, &iter, 1, &name, -1);>>      >>      g_print ("selected row is: %s\n", name);>>      >>      g_free(name);>>    }>>    else{>>      g_print ("no row selected.\n");>>    }>>    g_print("Number of selected rows = %d\n",>>	    gtk_tree_selection_count_selected_rows(selection))>>;>>    GList *rows = gtk_tree_selection_get_selected_rows(selection,>>						       &model);>>    GList *first = g_list_first (rows); >>    g_print("Selected row is %d\n", (gint *)first->data);>>>>Select row one anbd this is the output of the above:>>selected row is:  This is row 1>>Number of selected rows = 1>>Selected row is 947368>>    >>>>Citing http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeSelection.html#gtk-tree-selection-get-selected-rows:>>    Returns: A GList containing a GtkTreePath for each selected row.>>In other words, the list consists of GtkTreePaths, not>ints, so you print the pointer to the GtkTreePath (casted to>an int) instead of the row number.  The reference also>describes how to free the returned list properly.>>Yeti>>-->http://gwyddion.net/>_______________________________________________>gtk-list mailing list>gtk-list@xxxxxxxxx>http://mail.gnome.org/mailman/listinfo/gtk-list>>  >Ok, so how do I get the row number, from GtkTreePath, from GtkTreeRowReference? Where is it one of those. In fact, where are their struct defs? I look in /usr/include/gtk+-2.0 and All I find is thhe type def to it preceded by the '_'. But, no struct definition of _GtkTreeRowReference, etc.
tj
_______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux