From: Dirk Koopman Date: Thu, 27 Sep 2007 16:24:55 +0000 (+0100) Subject: start the recasting of gtkconsole X-Git-Tag: 1.55~57 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=d8a5452bc772fe71ef23e0e4ec679e63632f6af5;p=spider.git start the recasting of gtkconsole This involves splitting up the one screen into separate ones Adding a chat screen Making them only popup when input arrives. --- diff --git a/gtkconsole/Screen.pm b/gtkconsole/Screen.pm index cba19833..daf151b7 100644 --- a/gtkconsole/Screen.pm +++ b/gtkconsole/Screen.pm @@ -1,6 +1,4 @@ # -# Generic screen generator -# # This produces the Gtk for all the little sub-screens # # @@ -26,8 +24,8 @@ INIT { $cell->set(text => sprintf("%.1f", $info), xalign => 1.0); } ); - - + + Gtk2::SimpleList->add_column_type( 'tt', type => 'Glib::Scalar', renderer => 'Gtk2::CellRendererText', @@ -101,18 +99,18 @@ sub new { my $pkg = shift; my %args = @_; - + my $list = Gtk2::SimpleList->new(@{$args{fields}}); $list->set_rules_hint(1) if $args{hint}; $list->set_name($args{pkgname} || __PACKAGE__); - + my $scroll = Gtk2::ScrolledWindow->new (undef, undef); $scroll->set_shadow_type ($args{shadow_type} || 'etched-out'); $scroll->set_policy (exists $args{policy} ? @{$args{policy}} : qw(automatic automatic)); $scroll->set_size_request (@{$args{size}}) if exists $args{size}; $scroll->add($list); $scroll->set_border_width(exists $args{border_width} ? $args{border_width} : 2); - + my $self = $pkg->SUPER::new(scroller => $scroll, list => $list, widget => $scroll, maxsize => ($args{maxsize} || 100)); $list->get_model->signal_connect('row-inserted', \&_row_inserted, $self); @@ -129,7 +127,7 @@ sub add_data { my $self = shift; my $list = $self->{list}; - + push @{$list->{data}}, ref $_[0] ? $_[0] : [ @_ ]; shift @{$list->{data}} if @{$list->{data}} > $self->{maxsize}; } diff --git a/gtkconsole/gtkconsole b/gtkconsole/gtkconsole index bfeddb61..db12d1e0 100755 --- a/gtkconsole/gtkconsole +++ b/gtkconsole/gtkconsole @@ -3,7 +3,7 @@ # A GTK based console program # # usage: gtkconsole [] [ ] -# +# # Copyright (c) 2006-2007 Dirk Koopman G1TLH # # @@ -19,7 +19,7 @@ our $root; # search local then perl directories BEGIN { # root of directory tree for this system - $root = "/spider"; + $root = "/spider"; $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'}; } @@ -32,7 +32,7 @@ use IO::File; use Screen; -use vars qw(@modules $font); +use vars qw(@modules $font); @modules = (); # is the list of modules that need init calling # on them. It is set up by each 'use'ed module @@ -45,10 +45,17 @@ our @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); our $main; # the main screen our $scr_width; # calculated screen dimensions our $scr_height; -our ($dx, $cmd, $ann, $wcy, $wwv); # scrolling list windows +our ($dx, $cmd, $ann, $wcy, $wwv, $chat); # scrolling list windows our $bot; # the cmd entry window our $date; # the current date +# other windows +our $annwin; # the announcement window handle +our $dxwin; # the dx spot window handle +our $wwvwin; # wwv window handle +our $wcywin; # wcy window handle +our $chatwin; # chat window handle + require "$root/local/DXVars.pm" if -e "$root/local/DXVars.pm"; # read in the user data @@ -56,16 +63,16 @@ our $userfn = "$ENV{HOME}/.gtkconsole_data"; our $user = read_user_data(); our $call; our $passwd; -our $host; +our $host = 'localhost'; our $port = 7300; -# +# # read in gtkconsole file # Gtk2::Rc->set_default_files("$root/gtkconsole/gtkconsolerc", "$ENV{HOME}/.gtkconsolerc", ".gtkconsolerc"); Gtk2::Rc->reparse_all; - + # sort out a callsign, host and port, looking in order # 1. the command line # 2. any defaults in the user data; @@ -80,7 +87,7 @@ if (@ARGV) { unless ($call && $host) { my $node = $user->{clusters}->{$user->{node}}; - + if ($node->{call} || $user->{call}) { $call = $node->{call} || $user->{call} || $main::myalias; $host = $node->{passwd}; @@ -128,7 +135,7 @@ sendmsg('set/page 500'); sendmsg('set/nobeep'); my $sock_helper = Gtk2::Helper->add_watch($sock->fileno, 'in', \&tophandler, $sock); - + # the main loop $main->show_all; $bot->grab_focus; @@ -161,7 +168,7 @@ sub tophandler { my ($fd, $condx, $socket) = @_; - my $offset = length $rbuf; + my $offset = defined $rbuf ? length $rbuf : 0; my $l = sysread($socket, $rbuf, 1024, $offset); if (defined $l) { if ($l) { @@ -176,7 +183,7 @@ sub tophandler Gtk2->main_quit; } 1; - + } sub handlemsg @@ -246,7 +253,7 @@ sub handle_dx $dx->{lasttime} = $t; } $dx->add_data([$ts, @$ref[0,1,15,3,4,16], stim($ref->[2]) ]); - + $dxwin->show_all; } sub handle_ann @@ -254,39 +261,61 @@ sub handle_ann my $self = shift; my $ref = shift; my ($t, $ts) = (time, ''); - my $s; - $s = ref $ref ? join ', ',@$ref : $ref; +# my $s; +# $s = ref $ref ? (join ', ',@$ref) : $ref; if (($ann->{lasttime}||0) != $t) { $ts = tim($t); $ann->{lasttime} = $t; } - chomp $s; +# chomp $s; $ann->add_data([$ts, @$ref[3,1,2]]); + $annwin->show_all; } sub handle_wcy { my $self = shift; my $ref = shift; - my $s; - $s = ref $ref ? join ', ',@$ref : $ref; +# my $s; +# $s = ref $ref ? join ', ',@$ref : $ref; - chomp $s; +# chomp $s; $wcy->add_data([tim(), @$ref[10,4,5,3,6,2,7,8,9,1] ]); + $wcywin->show_all; } sub handle_wwv { my $self = shift; my $ref = shift; +# my $s; +# $s = ref $ref ? join ', ',@$ref : $ref; + +# chomp $s; + $wwv->add_data([tim(), @$ref[6,2,3,4,5,1] ]); + $wwvwin->show_all; +} + + +sub handle_chat +{ + my $self = shift; + my $ref = shift; + my ($t, $ts) = (time, ''); my $s; - $s = ref $ref ? join ', ',@$ref : $ref; + $s = ref $ref ? (join ', ',@$ref) : $ref; + + if (($ann->{lasttime}||0) != $t) { + $ts = tim($t); + $ann->{lasttime} = $t; + } chomp $s; - $wwv->add_data([tim(), @$ref[6,2,3,4,5,1] ]); + $chat->add_data([$ts, @$ref[3,1,2]]); + $chatwin->show_all; } @@ -349,7 +378,7 @@ sub cldatetime sub read_user_data { my $u; - + if (-e $userfn) { my $fh = new IO::File $userfn; my $s = undef; @@ -362,7 +391,7 @@ sub read_user_data } unless ($u) { print "$userfn missing or unreadable, starting afresh!\n"; - + $u = { clusters => { 'LOCAL' => {host => '127.0.0.1', port => 7300}, @@ -381,12 +410,11 @@ sub read_user_data sub write_user_data { my $u = shift; - + my $fh = new IO::File ">$userfn"; if ($fh) { my $dd = new Data::Dumper([ $u ]); $dd->Indent(1); - $dd->Terse(1); $dd->Quotekeys(0); $fh->print($dd->Dumpxs); $fh->close; @@ -404,8 +432,9 @@ sub gtk_create_main_screen { $main = new Gtk2::Window('toplevel'); my $scr = $main->get_screen; - $scr_width = int ($scr->get_width > 1280 ? 1280 : $scr->get_width) * 0.99; - $scr_height = int $scr->get_height * 0.5; + $scr_width = $scr->get_width; + $scr_width = 700 if $scr_width > 700; + $scr_height = int ($scr->get_height * 0.66); $main->set_default_size($scr_width, $scr_height); $main->signal_connect('delete_event', sub { Gtk2->main_quit; }); @@ -435,47 +464,31 @@ sub gtk_create_main_screen }, ]; - + my $menu = Gtk2::SimpleMenu->new(menu_tree => $menutree, default_callback => \&def_menu_callback, user_data => $user); $vbox->pack_start($menu->{widget}, 0, 1, 0); # a paned hbox is packed as the bottom of the vbox - my $bhpane = Gtk2::HPaned->new; - $vbox->pack_end($bhpane, 1, 1, 0); +# my $bhpane = Gtk2::HPaned->new; +# $vbox->pack_end($bhpane, 1, 1, 0); # now create the lh and rh panes - my $lhvpane = Gtk2::VPaned->new; - my $rhvpane = Gtk2::VPaned->new; - $bhpane->pack1($lhvpane, 1, 0); - $bhpane->pack2($rhvpane, 1, 0); - - # - # LEFT HAND SIDE - # - # The announce list - $ann = Screen::List->new(fields =>[ - RxTime => 'tt', - From => 'tt', - To => 'tt', - Announcement => 'ttlesslong', - ], - hint => 1, - frame => 'Announcements', - size => [$scr_width * 0.45, $scr_height * 0.33], - ); +# my $lhvpane = Gtk2::VPaned->new; +# my $rhvpane = Gtk2::VPaned->new; +# $bhpane->pack1($lhvpane, 1, 0); +# $bhpane->pack2($rhvpane, 1, 0); - $lhvpane->pack1($ann->widget, 1, 0); # The command list - my $lhvbox = Gtk2::VBox->new(0, 1); +# my $lhvbox = Gtk2::VBox->new(0, 1); $cmd = Screen::List->new(fields => [ RxTime => 'tt', Information => 'ttlong', ], - size => [$scr_width * 0.45, $scr_height * 0.66], + size => [$scr_width, $scr_height * 0.66], ); - $lhvbox->pack_start($cmd->widget, 1, 1, 0); + $vbox->pack_start($cmd->widget, 1, 1, 0); # callsign and current date and time @@ -485,23 +498,55 @@ sub gtk_create_main_screen $date->{tick} = Glib::Timeout->add(1000, \&updatetime, $date); $hbox->pack_start( $calllabel, 0, 1, 0 ); $hbox->pack_end($date, 0, 1, 0); - $lhvbox->pack_start($hbox, 0, 1, 0); - $lhvbox->pack_start(Gtk2::HSeparator->new, 0, 1, 0); + $vbox->pack_start($hbox, 0, 1, 0); + $vbox->pack_start(Gtk2::HSeparator->new, 0, 1, 0); # the bottom handler $bot = new Gtk2::Entry; $bot->set_editable(1); $bot->signal_connect('activate', \&bothandler); $bot->can_default(1); - $lhvbox->pack_end($bot, 0, 1, 0); - $lhvpane->pack2($lhvbox, 1, 0); + $vbox->pack_end($bot, 0, 1, 0); +# $lhvpane->pack2($lhvbox, 1, 0); $bot->grab_default; # - # RIGHT HAND SIDE + # # + # + # The announce list + $annwin = new Gtk2::Window('toplevel'); + $ann = Screen::List->new(fields =>[ + RxTime => 'tt', + From => 'tt', + To => 'tt', + Announcement => 'ttlesslong', + ], + hint => 1, + frame => 'Announcements', + size => [$scr_width * 0.85, $scr_height * 0.25], + ); + $annwin->add($ann->widget); +# $annwin->show_all; + + # The announce list + $chatwin = new Gtk2::Window('toplevel'); + $chat = Screen::List->new(fields =>[ + RxTime => 'tt', + From => 'tt', + To => 'tt', + Chat => 'ttlesslong', + ], + hint => 1, + frame => 'Chat', + size => [$scr_width * 0.85, $scr_height * 0.25], + ); + $chatwin->add($chat->widget); +# $annwin->show_all; + # DX window + $dxwin = new Gtk2::Window('toplevel'); $dx = Screen::List->new(fields => [ 'RxTime' => 'tt', 'QRG' => 'qrg', @@ -516,12 +561,15 @@ sub gtk_create_main_screen hint => 1, frame => "DX Spots", maxsize => 500, - size => [$scr_width * 0.45, $scr_height * 0.45], + size => [$scr_width * 0.9, $scr_height * 0.25], ); - $rhvpane->pack1($dx->widget, 1, 0); +# $rhvpane->pack1($dx->widget, 1, 0); + $dxwin->add($dx->widget); +# $dxwin->show_all; # The wwv list - my $rhvbox = Gtk2::VBox->new(0, 1); + $wwvwin = new Gtk2::Window('toplevel'); + # my $rhvbox = Gtk2::VBox->new(0, 1); $wwv = Screen::List->new( fields =>[ RxTime => 'tt', From => 'tt', @@ -535,9 +583,13 @@ sub gtk_create_main_screen policy => ['never', 'automatic'], frame => 'WWV Data', ); - $rhvbox->pack_start($wwv->widget, 1, 1, 0); + $wwvwin->add($wwv->widget); +# $wwvwin->show_all; + +# $rhvbox->pack_start($wwv->widget, 1, 1, 0); # The wcy list + $wcywin = new Gtk2::Window('toplevel'); $wcy = Screen::List->new(fields => [ RxTime => 'tt', From => 'tt', @@ -545,18 +597,20 @@ sub gtk_create_main_screen ExpK => 'int', A => 'int', R => 'int', - SFI => 'int', + SFI => 'int', SA => 'tt', GMF => 'tt', Aurora => 'tt', - Hour => 'tt' + Hour => 'tt' ], hint => 1, policy => ['never', 'automatic'], frame => 'WCY Data', ); - $rhvbox->pack_start($wcy->widget, 1, 1, 0); - $rhvbox->set_size_request($scr_width * 0.45, $scr_height * 0.33); - $rhvpane->pack2($rhvbox, 1, 0); +# $rhvbox->pack_start($wcy->widget, 1, 1, 0); +# $rhvbox->set_size_request($scr_width * 0.45, $scr_height * 0.33); +# $rhvpane->pack2($rhvbox, 1, 0); + $wcywin->add($wcy->widget); +# $wcywin->show_all; } diff --git a/perl/Version.pm b/perl/Version.pm index bb95399f..4d198fa0 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '157'; +$build = '158'; 1;