2 # Generic screen generator
4 # This produces the Gtk for all the little sub-screens
8 # Copyright (c) 2006 Dirk Koopman G1TLH
20 Gtk2::SimpleList->add_column_type( 'qrg',
21 type => 'Glib::Scalar',
22 renderer => 'Gtk2::CellRendererText',
24 my ($treecol, $cell, $model, $iter, $col_num) = @_;
25 my $info = $model->get ($iter, $col_num);
26 $cell->set(text => sprintf("%.1f", $info), xalign => 1.0);
31 Gtk2::SimpleList->add_column_type( 'tt',
32 type => 'Glib::Scalar',
33 renderer => 'Gtk2::CellRendererText',
35 my ($treecol, $cell, $model, $iter, $col_num) = @_;
36 my $info = $model->get ($iter, $col_num);
37 $cell->set(text => $info);
41 Gtk2::SimpleList->add_column_type( 'ttlong',
42 type => 'Glib::Scalar',
43 renderer => 'Gtk2::CellRendererText',
45 my ($treecol, $cell, $model, $iter, $col_num) = @_;
46 my $info = $model->get ($iter, $col_num);
47 $Text::Wrap::columns = 80;
48 $cell->set(text => join("\n",wrap("","",$info)));
52 Gtk2::SimpleList->add_column_type( 'ttlesslong',
53 type => 'Glib::Scalar',
54 renderer => 'Gtk2::CellRendererText',
56 my ($treecol, $cell, $model, $iter, $col_num) = @_;
57 my $info = $model->get ($iter, $col_num);
58 $Text::Wrap::columns = 65;
59 $cell->set(text => join("\n",wrap("","",$info)));
63 Gtk2::SimpleList->add_column_type( 'ttshort',
64 type => 'Glib::Scalar',
65 renderer => 'Gtk2::CellRendererText',
67 my ($treecol, $cell, $model, $iter, $col_num) = @_;
68 my $info = $model->get ($iter, $col_num);
69 $Text::Wrap::columns = 30;
70 $cell->set(text => join("\n",wrap("","",$info)));
79 my $class = ref $pkg || $pkg;
80 return bless {@_}, $class;
85 return $_[0]->{widget};
92 our @ISA = qw(Screen);
96 my ($liststore, $path, $iter, $self) = @_;
97 $self->{list}->scroll_to_cell($path);
105 my $list = Gtk2::SimpleList->new(@{$args{fields}});
106 $list->set_rules_hint(1) if $args{hint};
107 $list->set_name($args{pkgname} || __PACKAGE__);
109 my $scroll = Gtk2::ScrolledWindow->new (undef, undef);
110 $scroll->set_shadow_type ($args{shadow_type} || 'etched-out');
111 $scroll->set_policy (exists $args{policy} ? @{$args{policy}} : qw(automatic automatic));
112 $scroll->set_size_request (@{$args{size}}) if exists $args{size};
114 $scroll->set_border_width(exists $args{border_width} ? $args{border_width} : 2);
116 my $self = $pkg->SUPER::new(scroller => $scroll, list => $list, widget => $scroll, maxsize => ($args{maxsize} || 100));
118 $list->get_model->signal_connect('row-inserted', \&_row_inserted, $self);
121 my $frame = Gtk2::Frame->new($args{frame});
122 $frame->add($scroll);
123 $self->{widget} = $self->{frame} = $frame;
131 my $list = $self->{list};
133 push @{$list->{data}}, ref $_[0] ? $_[0] : [ @_ ];
134 shift @{$list->{data}} if @{$list->{data}} > $self->{maxsize};