Re: How to link expand/compact behavior of two treeviews?



On Tue, 2005-07-19 at 00:15 +0000, steve madsen virgin net wrote:

I found the thread "Freeze a treeview column" from April 2004 very
useful, and am using two treeviews which share a model for a project.
The linking of the scrollbars was easy, but I also need to link the
expand/compact behavior of the two views (so when the user clicks
the little triangle to expand the children in one view, the triangle
also gets "clicked" in the other treeview)

Connect to the row-expanded and row-collapsed signals of the views and
do the appropriate action on the other view.  Make sure you block the
corresponding signal handler when you do this -- otherwise you get
endless loops.  Untested proof of concept:

my ($expanded_handler_one, $expanded_handler_two);

$expanded_handler_one = $view_one->signal_connect (row_expanded => sub {
  my ($view, $iter, $path) = @_;
  my $path_two = get_path_for_view_two ($path);

  $view_two->signal_handler_block ($expanded_handler_two);
  $view_two->expand_row ($path_two, FALSE);
  $view_two->signal_handler_unblock ($expanded_handler_two);
});

$expanded_handler_two = $view_two->signal_connect (row_expanded => sub {
  my ($view, $iter, $path) = @_;
  my $path_one = get_path_for_view_one ($path);

  $view_one->signal_handler_block ($expanded_handler_one);
  $view_one->expand_row ($path_one, FALSE);
  $view_one->signal_handler_unblock ($expanded_handler_one);
});

And the same for row_collapsed.  This looks rather ugly, so maybe
there's a better way to do it.

-- 
Bye,
-Torsten




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