Bug in tree selection behavior?



Hi.  I've just built the following from CVS/HEAD: esound, gnome-xml,
libxslt, gtk-doc, glib, gob, linc, atk, gnome-common, pango, libIDL,
ORBit2, intltool, bonobo-activation and gtk+ so that I can see if the
behavior has been changed.  It hasn't changed from the version that
comes stock with RedHat 8, so I'm wondering if anyone else things the
following is a bug.

PROBLEM:  selection changed signal handler called twice during initial
tree selection.

I added the following to testtreeview.c to see what the current behavior
was:

diff -r1.33 testtreeview.c
4c4
< 
---
> #include <stdio.h>
599a600,614
> static void
> sel_foreach (GtkTreeModel *model, GtkTreePath *path, 
>               GtkTreeIter *iter, gpointer data)
> {
>       gchar* s = gtk_tree_model_get_string_from_iter(model, iter);
>       printf ("iter = '%s'\n", s);
>       g_free (s);
> }
> 
> static void
> selection_changed (GtkTreeSelection *treeselection, gpointer data)
> {
>       gtk_tree_selection_selected_foreach(treeselection,
>               sel_foreach, NULL);
> }
621a637
>   GtkTreeSelection *sel;
760c776,781
<   
---
>  
>   sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
>   g_signal_connect (sel, 
>               "changed", 
>               G_CALLBACK (selection_changed),
>               tv);

Basically, it just prints the selection path each time the "changed"
signal is fired.  However, when running this program and selecting row 6
followed by row 4, I get the following output:

linna$ ./testtreeview
Running automated tests...
Passed.
iter = '0'
iter = '6'
iter = '4'

Since there are no rows visibly selected in the tree view, I would
expect the changed signal to be fired exactly twice, but it is *always*
fired for row 0 with the first selection in the tree.  This makes it
very difficult to write handlers for selection events when you actually
want some sort of processing to occur with the data in a specific row.

If other people think this is a bug, I'll enter it in bugzilla.

Thanks in advance for any comments/information,

ast
-- 
Andrew S. Townley <atownley eircom net>

Attachment: signature.asc
Description: This is a digitally signed message part



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