Getting row numbers
- From: tj <999alfred comcast net>
- To: gtk-list gnome org
- Subject: Getting row numbers
- Date: Wed, 09 May 2007 07:23:18 -0400
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
I have tries everything I can think of, but I cannot get the row number.
I am a newbie to gtk.
tj
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]