Get row text from a treeview



Hi.

Im trying to get a selected rows text from a treeview / list_store
every time i click a row, but i cant get the values i need to
get the text from the place where i clicked.

Im looking for something like this:
path = gtk_tree_view_get_path(list_store, &iter);


This is what i have come up with so far:

gboolean
on_userlist_treeview_button_press_event (GtkWidget       *widget,
                                         GdkEventButton  *event,
                                         gpointer         user_data)
{
// if rightclick get username
GtkTreeIter iter;
GtkTreeModel *list_store;
GtkTreeViewColumn *user_column;
gchar *username;

GtkTreePath *path;
//GtkTreeSelection *selected;


  if (event->button == 3)
  {

list_store = gtk_tree_view_get_model(GTK_TREE_VIEW(userlist_treeview));

path = gtk_tree_path_new_from_string("1:1:1");
gtk_tree_model_get_iter(list_store, &iter, path);

gtk_tree_model_get(list_store, &iter, 0, &username, -1);

g_print("The username is: %s\n", username);
g_free(username);
gtk_tree_path_free(path);

  return;
}
  printf("\nNot right clicked\n");
  return FALSE;
}

// Magnus-swe <magnus-swe telia com>





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