RE: How to get a string from treeview



You should be able to:
(oh and have you looked at gtk-demo? - at run dialog, enter 'gtk-demo')


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

gchar *value = NULL;

selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));

/* this only works for GTK_SELECTION_SINGLE */
if(gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
        return; /* no selection */

gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, col, &value, -1);       

/* do something with value */

if(value != NULL) 
        g_free(value);

Regards,
Martyn


-----Original Message-----
From: David Goncalves [mailto:david goncalves genesys com]
Sent: 07 February 2003 13:32
To: gtk-app-devel-list
Subject: How to get a string from treeview


Hi,

I have a treeview with that kind of callback :

g_signal_connect( G_OBJECT(left_treeview), "button-press-event", 
G_CALLBACK(LP_GUI_TreeviewClicked), (gpointer)structure );


and the function :

gboolean LP_GUI_TreeviewClicked( GtkWidget *widget, 
GdkEventButton *event, 
gpointer data )
{
   ...
}


I would like to know how can i get the content of the row
clicked as a string ? Does someone have an example ?


i.e  :  Treeview :     Col1 | Col2         |
                         0   | foo          |
                         1   | bar          |
                         3   | faz          |

        If i click on row 1 i want to get "bar" in a gchar * ;)


Thanks in advance.
-- 
David Goncalves

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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