Re: get selection and do something



Hallo Rupert,

The first thing you should do when you start developing under gtk is
to install devhelp and the gtk documentation. It is of course also
online.

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeSelection.html#GtkTreeSelection-changed

The function you connect to the "changed" signal should look like this:

void  user_function   (GtkTreeSelection *treeselection,  gpointer  user_data)

so you always get the selection. You could add more data passing a
pointer when you connect the signal.

Then, inside that function you use this function to get the iter to
the selected row.

gboolean    gtk_tree_selection_get_selected (GtkTreeSelection *selection,
                                             GtkTreeModel **model,
                                             GtkTreeIter *iter);

This doesn't work if you enable multiple selection. You should use this instead

GList*      gtk_tree_selection_get_selected_rows
                                            (GtkTreeSelection *selection,
                                             GtkTreeModel **model);

I hope this answers your question.

Grüße,

Ignacio

2006/3/3, rupert <rupertt gmail com>:
Hi,
im bloody new to GTK Programming and working on an example from my book.
I wanna select a row from a gtk_tree_view and show a different picture for
each selected row.
I found the command to get the selection and know how to do an action if one
is selected,
so my question is how can I pass the selected row to my function(simple
output)?
I think the info is in "selected" itself, but i havent been able to extract
it.

selected = gtk_tree_view_get_selection(GTK_TREE_VIEW(ansicht));

    if(selected)
    g_signal_connect(G_OBJECT(selected), "changed",G_CALLBACK(sagwas),
NULL);


void sagwas(GtkWidget *widget, gpointer daten){

g_print("Hallo\n");
}

thx
_______________________________________________
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]