summaryrefslogtreecommitdiffstats
path: root/bin/net_monitor
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
committerOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
commit1d37bfdbbe874abd6dcb5563eea19f531de09e1c (patch)
tree74845e43ed8fa59c7aaafd1a87efaa6b0c83c228 /bin/net_monitor
parentc6ba983db7d5a82ee63599e775be0f8211447c72 (diff)
downloaddrakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.gz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.bz2
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.xz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.zip
sync with 2007.1 (because of SVN loss)2007.1
Diffstat (limited to 'bin/net_monitor')
-rwxr-xr-xbin/net_monitor162
1 files changed, 81 insertions, 81 deletions
diff --git a/bin/net_monitor b/bin/net_monitor
index b513b54..b9ca3de 100755
--- a/bin/net_monitor
+++ b/bin/net_monitor
@@ -2,7 +2,7 @@
# NetMonitor
-# Copyright (C) 1999-2005 Mandriva
+# Copyright (C) 1999-2006 Mandriva
# Damien "Dam's" Krotkine
# Thierry Vignaud <tvignaud@mandriva.com>
#
@@ -23,10 +23,13 @@
use lib qw(/usr/lib/libDrakX);
use strict;
+# i18n: IMPORTANT: to get correct namespace (drakx-net instead of libDrakX)
+BEGIN { unshift @::textdomains, 'drakx-net' }
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use c;
use interactive;
+use mygtk2 qw(gtknew gtkset);
use ugtk2 qw(:create :helpers :wrappers);
use common;
use network::network;
@@ -86,38 +89,38 @@ my %config = getVarsFromSh($cfg_file);
my $use_same_scale = text2bool($config{use_same_scale});
gtkadd($window1->{window},
- gtkpack_(Gtk2::VBox->new(0,5),
- 1, gtkpack_(Gtk2::HBox->new(0,5),
- 0, my $notebook = Gtk2::Notebook->new,
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Settings")), 'etched_out'),
- gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,0),5),
+ gtknew('VBox', spacing => 5, children => [
+ 1, gtknew('HBox', spacing => 5, children => [
+ 0, my $notebook = gtknew('Notebook'),
+ 1, gtknew('VBox', spacing => 5, children => [
+ 0, gtknew('Frame', text => N("Settings"), shadow_type => 'etched_out', child =>
+ gtknew('HBox', border_width => 5, children_tight => [
N("Connection type: "),
- my $label_cnx_type = Gtk2::Label->new("")),
+ my $label_cnx_type = gtknew('Label', text => "")]),
),
- 1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Global statistics")), 'etched_out'),
- gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0),5),
- create_packtable({ col_spacings => 1, row_spacings => 5, homogeneous => 1 },
- [ Gtk2::Label->new(""), Gtk2::Label->new(N("Instantaneous")) , Gtk2::Label->new(N("Average")) ],
- [ Gtk2::WrappedLabel->new(N("Sending\nspeed:")), my $label_st = Gtk2::Label->new(""), my $label_sta = Gtk2::Label->new(N("unknown")) ],
- [ Gtk2::WrappedLabel->new(N("Receiving\nspeed:")), my $label_sr = Gtk2::Label->new(""), my $label_sra = Gtk2::Label->new(N("unknown")) ],
- ),
- Gtk2::HSeparator->new,
- gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,0),5),
+ 1, gtknew('Frame', text => N("Global statistics"), shadow_type => 'etched_out', child =>
+ gtknew('VBox', border_width => 5, children_tight => [
+ gtknew('Table', col_spacings => 1, row_spacings => 5, homogeneous => 1, children => [
+ [ gtknew('Label', text => ""), gtknew('Label', text => N("Instantaneous")) , gtknew('Label', text => N("Average")) ],
+ [ gtknew('WrappedLabel', text => N("Sending\nspeed:")), my $label_st = gtknew('Label', text => ""), my $label_sta = gtknew('Label', text => N("unknown")) ],
+ [ gtknew('WrappedLabel', text => N("Receiving\nspeed:")), my $label_sr = gtknew('Label', text => ""), my $label_sra = gtknew('Label', text => N("unknown")) ],
+ ]),
+ gtknew('HSeparator'),
+ gtknew('HBox', border_width => 5, children_tight => [
N("Connection\ntime: "),
- my $label_ct = Gtk2::Label->new(N("unknown")),
- ),
- )
+ my $label_ct = gtknew('Label', text => N("unknown")),
+ ]),
+ ])
),
- )
- ),
- 0, gtksignal_connect(gtkset_active(Gtk2::CheckButton->new(N("Use same scale for received and transmitted")), $use_same_scale), clicked => sub { $use_same_scale = !$use_same_scale }),
- 0, gtkpack(create_hbox('edge'),
- gtksignal_connect(my $button_connect = gtkset_sensitive(Gtk2::Button->new(N("Wait please")), 0), clicked => \&connection),
- gtksignal_connect(my $button_close = Gtk2::Button->new(N("Close")), clicked => \&main_quit),
- ),
+ ])
+ ]),
+ 0, gtksignal_connect(gtkset_active(gtknew('CheckButton', text => N("Use same scale for received and transmitted")), $use_same_scale), clicked => sub { $use_same_scale = !$use_same_scale }),
+ 0, gtknew('HButtonBox', layout => 'edge', children_loose => [
+ my $button_connect = gtknew('Button', text => N("Wait please"), sensitive => 0, clicked => \&connection),
+ my $button_close = gtknew('Button', text => N("Close"), clicked => \&main_quit),
+ ]),
0, my $statusbar = Gtk2::Statusbar->new
- ),
+ ]),
);
$window1->{window}->show_all;
@@ -185,7 +188,7 @@ sub connection() {
$ct_tag = Glib::Timeout->add(1000, sub {
my ($sec, $min, $hour) = gmtime(time() - $c_time);
my $e = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
- $label_ct->set_label($e); 1 });
+ gtkset($label_ct, text => $e); 1 });
}
my $nb_point = 1;
$first = 1;
@@ -295,19 +298,19 @@ sub rescan() {
draw_monitor($monitor->{$intf}, $intf);
}
- $label_sr->set_label(formatXiB($monitor->{sr}) . "/s");
- $label_st->set_label(formatXiB($monitor->{st}) . "/s");
+ gtkset($label_sr, text => formatXiB($monitor->{sr}) . "/s");
+ gtkset($label_st, text => formatXiB($monitor->{st}) . "/s");
$monitor->{sra} += $monitor->{sr};
$monitor->{sta} += $monitor->{st};
$monitor->{nba}++;
if ($monitor->{nba} > 9) {
- $label_sra->set_label(formatXiB($monitor->{sra}/10) . "/s");
- $label_sta->set_label(formatXiB($monitor->{sta}/10) . "/s");
+ gtkset($label_sra, text => formatXiB($monitor->{sra}/10) . "/s");
+ gtkset($label_sta, text => formatXiB($monitor->{sta}/10) . "/s");
$monitor->{sra} = 0;
$monitor->{sta} = 0;
$monitor->{nba} = 0;
}
- $label_cnx_type->set_label(translate($net->{type}));
+ gtkset($label_cnx_type, text => translate($net->{type}));
$monitor->{$_} = 0 foreach 'sr', 'st';
1;
}
@@ -351,6 +354,19 @@ $scale_r = $scale_t = $height;
sub scale_tranmistted($) { $_[0] * $scale_t }
sub scale_received($) { $_[0] * $scale_r }
+sub color_button {
+ my ($gc, $color) = @_;
+ gtknew('Button', relief => 'none', clicked => sub {
+ $color = change_color($color);
+ $gc->set_rgb_fg_color($color);
+ $_[0]->queue_draw;
+ },
+ child => gtksignal_connect(gtkshow(gtksize(gtkset(Gtk2::DrawingArea->new, width => 10, height => 10), 10, 10)),
+ expose_event => sub { $_[0]->window->draw_rectangle($gc, 1, 0, 0, 10, 10) })
+ );
+}
+
+
sub update() {
if (!$during_connection) {
my $isconnect = test_connected(0);
@@ -369,54 +385,38 @@ sub update() {
$monitor->{$intf}{initialt} = $monitor->{$intf}{val}[8];
$darea->{$intf} = Gtk2::DrawingArea->new;
$darea->{$intf}->set_events(["pointer_motion_mask"]);
- $notebook->append_page(gtkshow(my $page = gtkpack_(Gtk2::VBox->new(0,0),
- 0, gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,0), 5),
- gtksize($darea->{$intf}, $width, $height)),
- 0, gtkpack_(Gtk2::HBox->new(0,0),
- 1, gtkpack__(Gtk2::VBox->new(0,0),
- gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,5), 5),
- gtksignal_connect(my $button_t = gtkset_relief(Gtk2::Button->new, 'none'), clicked => sub {
- $colort = change_color($colort);
- $gct->set_foreground($colort);
- $_[0]->queue_draw;
- }),
- N("sent: "), $monitor->{$intf}{labelt} = Gtk2::Label->new("0")),
- gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,5), 5),
- gtksignal_connect(my $button_r = gtkset_relief(Gtk2::Button->new, 'none'), clicked => sub {
- $colorr = change_color($colorr);
- $gcr->set_foreground($colorr);
- $_[0]->queue_draw;
- }),
- N("received: "), $monitor->{$intf}{labelr} = Gtk2::Label->new("0")),
- gtkpack__(gtkset_border_width(Gtk2::HBox->new(0,5), 5),
- gtksignal_connect(my $button_a = gtkset_relief(Gtk2::Button->new, 'none'), clicked => sub {
- $colora = change_color($colora);
- $gca->set_foreground($colora);
- $_[0]->queue_draw;
- }),
- N("average"))
- ),
- 0, gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0), 5),
- gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Local measure")), 'etched_out'),
- gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0), 5),
- gtkpack__(Gtk2::HBox->new(0,0),
+ $notebook->append_page(gtkshow(my $page = gtknew('VBox', children => [
+ 0, gtknew('HBox', border_width => 5, children_tight => [
+ gtksize($darea->{$intf}, $width, $height)]),
+ 0, gtknew('HBox', children => [
+ 1, gtknew('VBox', children_tight => [
+ gtknew('HBox', spacing => 5, border_width => 5, children_tight => [
+ color_button($gct, $colort),
+ N("sent: "), $monitor->{$intf}{labelt} = gtknew('Label', text => "0")]),
+ gtknew('HBox', spacing => 5, border_width => 5, children_tight => [
+ color_button($gcr, $colorr),
+ N("received: "), $monitor->{$intf}{labelr} = gtknew('Label', text => "0")]),
+ gtknew('HBox', spacing => 5, border_width => 5, children_tight => [
+ color_button($gca, $colora),
+ N("average")])
+ ]),
+ 0, gtknew('VBox', border_width => 5, children_tight => [
+ gtknew('Frame', text => N("Local measure"), shadow_type => 'etched_out', child =>
+ gtknew('VBox', border_width => 5, children_tight => [
+ gtknew('HBox', children_tight => [
N("sent: "),
- my $measure_t = Gtk2::Label->new("0")
- ),
- gtkpack__(Gtk2::HBox->new(0,0),
+ my $measure_t = gtknew('Label', text => "0")
+ ]),
+ gtknew('HBox', children_tight => [
N("received: "),
- my $measure_r = Gtk2::Label->new("0")
- )
- )
+ my $measure_r = gtknew('Label', text => "0")
+ ])
+ ])
)
- )
- )
- )),
- Gtk2::Label->new($intf));
- foreach my $i ([$button_t, $gct], [$button_r, $gcr], [$button_a, $gca]) {
- $i->[0]->add(gtksignal_connect(gtkshow(gtksize(gtkset_size_request(Gtk2::DrawingArea->new, 10, 10), 10, 10)),
- expose_event => sub { $_[0]->window->draw_rectangle($i->[1], 1, 0, 0, 10, 10) }));
- }
+ ])
+ ])
+ ])),
+ gtknew('Label', text => $intf));
$monitor->{$intf}{page} = $notebook->page_num($page);
$darea->{$intf}->realize;
$pixmap->{$intf} = Gtk2::Gdk::Pixmap->new($darea->{$intf}->window, $width, $height, $darea->{$intf}->window->get_depth);
@@ -428,8 +428,8 @@ sub update() {
my $x = $e->x - 50;
my $received = $x >= 0 ? $monitor->{$intf}{stack_r}[$x] : 0;
my $transmitted = $x >= 0 ? $monitor->{$intf}{stack_t}[$x] : 0;
- $measure_r->set_label(formatXiB($received));
- $measure_t->set_label(formatXiB($transmitted));
+ gtkset($measure_r, text => formatXiB($received));
+ gtkset($measure_t, text => formatXiB($transmitted));
});
$darea->{$intf}->signal_connect(expose_event => sub {
$darea->{$intf}->window->draw_drawable($darea->{$intf}->style->bg_gc('normal'), $pixmap->{$intf}, 0, 0, 0, 0, $width, $height);