2 # This produces the Gtk for all the little sub-screens
6 # Copyright (c) 2006 Dirk Koopman G1TLH
18 Gtk2::SimpleList->add_column_type( 'qrg',
19 type => 'Glib::Scalar',
20 renderer => 'Gtk2::CellRendererText',
22 my ($treecol, $cell, $model, $iter, $col_num) = @_;
23 my $info = $model->get ($iter, $col_num);
24 $cell->set(text => sprintf("%.1f", $info), xalign => 1.0);
29 Gtk2::SimpleList->add_column_type( 'tt',
30 type => 'Glib::Scalar',
31 renderer => 'Gtk2::CellRendererText',
33 my ($treecol, $cell, $model, $iter, $col_num) = @_;
34 my $info = $model->get ($iter, $col_num);
35 $cell->set(text => $info);
39 Gtk2::SimpleList->add_column_type( 'ttlong',
40 type => 'Glib::Scalar',
41 renderer => 'Gtk2::CellRendererText',
43 my ($treecol, $cell, $model, $iter, $col_num) = @_;
44 my $info = $model->get ($iter, $col_num);
45 $Text::Wrap::columns = 80;
46 $cell->set(text => join("\n",wrap("","",$info)));
50 Gtk2::SimpleList->add_column_type( 'ttlesslong',
51 type => 'Glib::Scalar',
52 renderer => 'Gtk2::CellRendererText',
54 my ($treecol, $cell, $model, $iter, $col_num) = @_;
55 my $info = $model->get ($iter, $col_num);
56 $Text::Wrap::columns = 65;
57 $cell->set(text => join("\n",wrap("","",$info)));
61 Gtk2::SimpleList->add_column_type( 'ttshort',
62 type => 'Glib::Scalar',
63 renderer => 'Gtk2::CellRendererText',
65 my ($treecol, $cell, $model, $iter, $col_num) = @_;
66 my $info = $model->get ($iter, $col_num);
67 $Text::Wrap::columns = 30;
68 $cell->set(text => join("\n",wrap("","",$info)));
77 my $class = ref $pkg || $pkg;
78 return bless {@_}, $class;
83 return $_[0]->{widget};
90 our @ISA = qw(Screen);
94 my ($liststore, $path, $iter, $self) = @_;
95 $self->{list}->scroll_to_cell($path);
103 my $list = Gtk2::SimpleList->new(@{$args{fields}});
104 $list->set_rules_hint(1) if $args{hint};
105 $list->set_name($args{pkgname} || __PACKAGE__);
107 my $scroll = Gtk2::ScrolledWindow->new (undef, undef);
108 $scroll->set_shadow_type ($args{shadow_type} || 'etched-out');
109 $scroll->set_policy (exists $args{policy} ? @{$args{policy}} : qw(automatic automatic));
110 $scroll->set_size_request (@{$args{size}}) if exists $args{size};
112 $scroll->set_border_width(exists $args{border_width} ? $args{border_width} : 2);
114 my $self = $pkg->SUPER::new(scroller => $scroll, list => $list, widget => $scroll, maxsize => ($args{maxsize} || 100));
116 $list->get_model->signal_connect('row-inserted', \&_row_inserted, $self);
119 my $frame = Gtk2::Frame->new($args{frame});
120 $frame->add($scroll);
121 $self->{widget} = $self->{frame} = $frame;
129 my $list = $self->{list};
131 push @{$list->{data}}, ref $_[0] ? $_[0] : [ @_ ];
132 shift @{$list->{data}} if @{$list->{data}} > $self->{maxsize};