TreeView row reordering with DND?



Hi all,

I'm having some trouble understanding how reordering TreeView rows works with
drag and drop.  I tried searching through the list archives, but didn't find
anything that answered my question; if it's been answered before and I missed
it, just point me towards that answer :o)

We've got a TreeView (using TreeStore as the model), and we've enabled
reordering with $treeview->set_reorderable(1).  This works just fine: it allows
us to drag the rows around wherever we want.  We'd like to execute a callback
whenever this happens to update the tree structure on disk so that the rows
will stay in the same order between executions of the program.  In order to do
this, we've connected to the 'row-inserted' signal.  Our callback gets called
at the right time, but it doesn't do what we expect. Here's a small example
that has the same problem:

sub row_moved {
        my ($model, $path, $iter) = @_;
        my $name = $model->get($iter, 0); # $name is undefined!
        print "Updated location of row $name!\n";
}

If I run an example program (attached) with this callback and reorder a row,
the following is printed:

[zb laptop][0]$ perl treeview_test.pl
Use of uninitialized value in concatenation (.) or string at treeview_test.pl
line 48.
Updated location of row !
[zb laptop][0]$

It behaves sort of like $iter is invalid, but $model->iter_is_valid($iter)
returns true.  $model->get_string_from_iter($iter) returns a string pointing to
the new location of the row.

Any help you guys could give would be great.  If you need any more information,
just ask.

Thanks,
Zach

Attachment: treeview_test.pl
Description: Perl program



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