1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Glib qw(TRUE FALSE); use Gtk2 '-init'; use Gtk2::Ex::Simple::List; ######################################################################## Gtk2::Ex::Simple::List->add_column_type( 'toggle', type => 'Glib::Boolean', renderer => 'Gtk2::CellRendererToggle', attr => 'active', ); ######################################################################## my $window = Gtk2::Window->new; $window->set_title ('Liste'); $window->set_border_width(5); $window->signal_connect (delete_event => sub { Gtk2->main_quit; 1; }); ######################################################################## my $list = Gtk2::Ex::Simple::List->new ( 'Text' => 'text', 'Toggle' => 'toggle', ); $window->add($list); @{$list->{data}} = ( [ 'test1', 0], [ 'test2', 1], [ 'test3', 1], [ 'test3', 0], ); $list->signal_connect (row_activated => sub { my ($slist, $path, $column) = @_; print Dumper($slist->{data}); }); ######################################################################## $window->show_all; Gtk2->main;
$slist->{data}