Re: TreeView row reordering with DND?



Zach Bean said:
I'm having some trouble understanding how reordering TreeView rows works with
drag and drop.

Erm, as i understand it, the drag and drop Just Works to keep the model and
the view in sync.  All the docs that i've found say something to the effect of
"If you want more sophisticated DND handling, do it yourself."  :-/


I tried searching through the list archives, but didn't find
anything that answered my question;

The search facility on lists.gnome.org is infamously broken.  Use google's
site directive, instead.


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.

Why track individual changes (which is where the pain is coming from)?  Why
not just sync your entire data structure to disk?

Incidentally, a slight modification of your program:

  use Data::Dumper;
  # in both row-inserted and row-deleted, $_[1] is a Gtk2::TreePath
  $ts->signal_connect (row_deleted =>
                       sub { print "deleted ".$_[1]->to_string."\n" });
  $ts->signal_connect (row_inserted =>
                       sub { print "inserted ".$_[1]->to_string."\n" });

shows that the new row is inserted before the old row is deleted.

  tetsuo:~$ perl ~/treeview_test.pl
  inserted 0:1
  deleted 0:3:0


Also, the bindings for these signals are provided by the standard gtk2-perl
mechanism (i.e., no custom marshalers), so whatever values are coming in are
what GTK+ gave us.

-- 
muppet <scott at asofyet dot org>



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