treeview style setting



Hi,

I'm trying to adjust some of the style settings in a treeview,
like the expander size and vertical spacing. I can get the
list of styles, but I can't see where to set them. Anyone know?

#! /usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Glib qw/TRUE FALSE/; 
 
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_border_width(5);
$window->set_position('center_always');

my $vbox = &ret_vbox();
$window->add($vbox);
$window->show();
Gtk2->main();

sub ret_vbox {
   my $vbox = Gtk2::VBox->new(FALSE,5);
   my $sw = Gtk2::ScrolledWindow->new (undef, undef);
                $sw->set_shadow_type ('etched-out');
                $sw->set_policy ('automatic', 'automatic');
                $sw->set_size_request (300, 300);
                $sw->set_border_width(5);
        
        my $tree_store = Gtk2::TreeStore->new(qw/Glib::String/);

        foreach (1..30) {
                my $parent_nr = $_;
                my $iter = $tree_store->append(undef);
                $tree_store->set ($iter,0 => "Parent $parent_nr");
                
                 foreach (1..3){
                  my $iter_child = $tree_store->append($iter);
                      $tree_store->set ($iter_child,0 => "Child $_ of Parent $parent_nr");
                }
        }

        my $tree_view = Gtk2::TreeView->new($tree_store);
        my $tree_column = Gtk2::TreeViewColumn->new();
        $tree_column->set_title ("Click to sort");
                        
        my $renderer = Gtk2::CellRendererText->new;
        $tree_column->pack_start ($renderer, FALSE);
        $tree_column->add_attribute($renderer, text => 0);
        
        $tree_view->append_column ($tree_column);

###############################################################################
        my @list = $tree_view->style_get("vertical-separator",
                                            "even-row-color","odd-row-color",
                                            "expander-size","horizontal-separator",
                                            "indent-expanders"
                                             );
          print "@list\n";

          my $style = $tree_view->get_style;
          print "$style\n";
          my $new_style = $style->copy();
          $new_style->{'expander-size'} = 20;
          $tree_view->set_style($style);
 
###########################################################################

     $sw->add($tree_view);
        
      $vbox->pack_start($sw,TRUE,TRUE,0);


$vbox->show_all();
return $vbox;
}
__END__


Thanks


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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