Get row text from a treeview



I solved my problem, i thought i would send the code for it so it can be
found on the internet etc.


// If double clicked, get and show the selected text.
void
on_some_treeview_row_activated     (GtkTreeView     *treeview,
                                    GtkTreePath     *arg1,
                                    GtkTreeViewColumn *arg2,
                                    gpointer         user_data)
{
GtkTreeIter iter;
GtkTreeModel *list_store;
GtkTreeViewColumn *column;
GtkTreePath *path;
gchar *text;

list_store = gtk_tree_view_get_model(GTK_TREE_VIEW(some_treeview));

gtk_tree_view_get_cursor(GTK_TREE_VIEW(some_treeview), &path, &column);

gtk_tree_model_get_iter(list_store, &iter, path);

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

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

Greetz from: Magnus-swe





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