summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-07-14 19:24:31 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-07-14 19:24:31 +0000
commitde49f7583295f4d4437d4f95589c0a2d904fc9c1 (patch)
tree5101e7403c3f560b9b56203d089709c581c68259 /perl-install/standalone
parentd634f19feff7feb422d06d85e8014f54e15fd56f (diff)
downloaddrakx-de49f7583295f4d4437d4f95589c0a2d904fc9c1.tar
drakx-de49f7583295f4d4437d4f95589c0a2d904fc9c1.tar.gz
drakx-de49f7583295f4d4437d4f95589c0a2d904fc9c1.tar.bz2
drakx-de49f7583295f4d4437d4f95589c0a2d904fc9c1.tar.xz
drakx-de49f7583295f4d4437d4f95589c0a2d904fc9c1.zip
gtk+2 port
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-xperl-install/standalone/net_monitor356
1 files changed, 176 insertions, 180 deletions
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 170a70bee..3cc30ec8f 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -23,11 +23,8 @@ use lib qw(/usr/lib/libDrakX);
use strict;
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-#- languages that can't be displayed with gtk1, so we unset translations
-#- for them until this tool is ported to gtk2
-if ($ENV{LANGUAGE} =~ /\b(ar|he|hi|ta)/) { $ENV{LANGUAGE} = "C" };
-
-use my_gtk qw(:helpers :wrappers);
+use interactive;
+use ugtk2 qw(:helpers :wrappers :create);
use common;
use network::netconnect;
use network::tools;
@@ -46,19 +43,18 @@ if ($force) {
$connect = $disconnect = 0;
}
$quiet and exit(0);
-init Gtk;
+my $in = 'interactive'->vnew('su', 'default');
+
-require_root_capability();
+my $window1 = ugtk2->new(N("Network Monitoring"));
+$window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
-my $window1 = my_gtk->new('net_monitor');
-$window1->{rwindow}->signal_connect(delete_event => sub { my_gtk->exit(0) });
unless ($::isEmbedded) {
- $window1->{rwindow}->set_position(1);
+ $window1->{rwindow}->set_position('center');
$window1->{rwindow}->set_title(N("Network Monitoring"));
- $window1->{rwindow}->set_policy(1, 1, 1);
$window1->{rwindow}->set_border_width(5);
}
-#$::isEmbedded or $window1->{rwindow}->set_usize(580, 320);
+#$::isEmbedded or $window1->{rwindow}->set_size_request(580, 320);
my $colorr = gtkcolor(50400, 655, 20000);
my $colort = gtkcolor(55400, 55400, 655);
@@ -71,12 +67,15 @@ my $netc = {};
my $intf = {};
my $c_time = 0;
my $ct_tag;
-my $style = new Gtk::Style;
-$style->font(Gtk::Gdk::Font->fontset_load("-adobe-times-medium-r-normal-*-12-*-75-75-p-*-iso8859-*,*-r-*"));
+my $style = Gtk2::Style->new;
+#$style->font(Gtk2::Gdk::Font->fontset_load("-adobe-times-medium-r-normal-*-12-*-75-75-p-*-iso8859-*,*-r-*"));
+
+my ($pixmap, $darea);
+my ($width, $height) = (300, 150);
network::netconnect::load_conf($netcnx, $netc, $intf);
network::netconnect::read_net_conf('', $netcnx, $netc);
-my $combo1 = new Gtk::Combo;
+my $combo1 = Gtk2::Combo->new;
$combo1->set_popdown_strings(network::netconnect::get_profiles());
$combo1->entry->set_text($netcnx->{PROFILE} || "default");
$combo1->entry->set_editable(0);
@@ -88,45 +87,48 @@ MDK::Common::Globals::init(
connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg");
gtkadd($window1->{window},
- gtkpack_(new Gtk::VBox(0,5),
- 0, N("Network Monitoring"),
- 1, gtkpack_(new Gtk::HBox(0,5),
- 1, my $notebook = new Gtk::Notebook,
- 0, gtkpack_(new Gtk::VBox(0,5),
- 0, gtkadd(gtkset_shadow_type(new Gtk::Frame(N("Settings")), 'etched_out'),
- gtkpack__(gtkset_border_width(new Gtk::VBox(0,5),5),
- gtkpack__(new Gtk::HBox(0,0),
- N("Connection type: "), my $label_cnx_type = new Gtk::Label("")),
- gtkpack__(new Gtk::HBox(0,0),
- N("Profile "), $combo1)
- )
- ),
- 1, gtkadd(gtkset_shadow_type(new Gtk::Frame(N("Statistics")), 'etched_out'),
- gtkpack__(new Gtk::VBox(0,0),
- create_packtable({ col_spacings => 1, row_spacings => 1 },
- [ "", "instantaneous" , "average" ],
- [ N("Sending Speed:"), my $label_st = new Gtk::Label(""), my $label_sta = new Gtk::Label("na") ],
- [ N("Receiving Speed:"), my $label_sr = new Gtk::Label(""), my $label_sra = new Gtk::Label("na") ],
- ),
- gtkpack__(new Gtk::HBox(0,0), " " . N("Connection Time: "), my $label_ct = new Gtk::Label("")),
- )
- ),
- 0, gtkpack_(new Gtk::HBox(0,5),
- 1, gtksignal_connect(my $button_connect = gtkset_sensitive(new Gtk::Button(), 0), clicked => \&connection),
- 0, new Gtk::VSeparator,
- 0, gtkpack(new Gtk::VBox(0,5),
- gtksignal_connect(new Gtk::Button(N("Logs")), clicked => sub {
- -e "/usr/sbin/logdrake"
- ? system('/usr/sbin/logdrake --file=/var/log/messages &')
- : system('/usr/X11R6/bin/xvt -e "tail -f /var/log/messages " &')
- }),
- gtksignal_connect(my $button_close = new Gtk::Button(N("Close")), clicked => sub { my_gtk->exit(0) }),
- )
- )
- )
- ),
- 0, my $statusbar = new Gtk::Statusbar
- )
+ gtkpack_(Gtk2::VBox->new(0,5),
+ 1, gtkpack_(Gtk2::HBox->new(0,5),
+ 1, my $notebook = Gtk2::Notebook->new,
+ 0, gtkpack_(Gtk2::VBox->new(0,5),
+ 0, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Settings")), 'etched_out'),
+ gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,5),5),
+ gtkpack__(Gtk2::HBox->new(0,0),
+ N("Connection type: "),
+ my $label_cnx_type = Gtk2::Label->new("")),
+ gtkpack__(Gtk2::HBox->new(0,0),
+ N("Profile "), $combo1)
+ )
+ ),
+ 1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Statistics")), 'etched_out'),
+ gtkpack__(Gtk2::VBox->new(0,0),
+ create_packtable({ col_spacings => 1, row_spacings => 1 },
+ [ "", "instantaneous" , "average" ],
+ [ N("Sending Speed:"), my $label_st = Gtk2::Label->new(""), my $label_sta = Gtk2::Label->new("na") ],
+ [ N("Receiving Speed:"), my $label_sr = Gtk2::Label->new(""), my $label_sra = Gtk2::Label->new("na") ],
+ ),
+ gtkpack__(Gtk2::HBox->new(0,0),
+ " " . N("Connection Time: "),
+ my $label_ct = Gtk2::Label->new(""),
+ ),
+ )
+ ),
+ 0, gtkpack_(Gtk2::HBox->new(0,5),
+ 1, gtksignal_connect(my $button_connect = gtkset_sensitive(Gtk2::Button->new(), 0), clicked => \&connection),
+ 0, Gtk2::VSeparator->new,
+ 0, gtkpack(Gtk2::VBox->new(0,5),
+ gtksignal_connect(Gtk2::Button->new(N("Logs")), clicked => sub {
+ -e "/usr/sbin/logdrake"
+ ? system('/usr/sbin/logdrake --file=/var/log/messages &')
+ : system('/usr/X11R6/bin/xvt -e "tail -f /var/log/messages " &')
+ }),
+ gtksignal_connect(my $button_close = Gtk2::Button->new_from_stock('gtk-close'), clicked => sub { ugtk2->exit(0) }),
+ )
+ )
+ )
+ ),
+ 0, my $statusbar = Gtk2::Statusbar->new
+ ),
);
$window1->{rwindow}->show_all;
$window1->{rwindow}->realize;
@@ -136,39 +138,35 @@ $combo1->entry->signal_connect(changed => sub {
network::netconnect::set_net_conf($netcnx, $netc, $intf);
network::netconnect::read_net_conf('', $netcnx, $netc);
});
-my $gct = new Gtk::Gdk::GC($window1->{rwindow}->window);
+my $gct = Gtk2::Gdk::GC->new($window1->{rwindow}->window);
$gct->set_foreground($colort);
-my $gcr = new Gtk::Gdk::GC($window1->{rwindow}->window);
+my $gcr = Gtk2::Gdk::GC->new($window1->{rwindow}->window);
$gcr->set_foreground($colorr);
-my $gca = new Gtk::Gdk::GC($window1->{rwindow}->window);
+my $gca = Gtk2::Gdk::GC->new($window1->{rwindow}->window);
$gca->set_foreground($colora);
-my ($pix_c_map, $pix_c_mask) = gtkcreate_png("net_c.png");
-my ($pix_d_map, $pix_d_mask) = gtkcreate_png("net_d.png");
-my ($pix_u_map, $pix_u_mask) = gtkcreate_png("net_u.png");
-$button_connect->add(gtkpack__(new Gtk::VBox(0,3),
- my $pix_c = new Gtk::Pixmap($pix_u_map, $pix_u_mask),
- my $label_c = new Gtk::Label(N("Wait please"))
+my $pix_c_map = gtkcreate_pixbuf("net_c.png");
+my $pix_d_map = gtkcreate_pixbuf("net_d.png");
+$button_connect->add(gtkpack__(Gtk2::VBox->new(0,3),
+ my $pix_c = gtkcreate_img("net_u.png"),
+ my $label_c = Gtk2::Label->new(N("Wait please"))
));
$statusbar->push(1, N("Wait please, testing your connection..."));
$window1->{rwindow}->show_all;
-#$window1->{rwindow}->set_policy (1, 1, 1);
-my $time_tag = Gtk->timeout_add(1000, \&rescan);
-my $time_tag2 = Gtk->timeout_add(1000, \&update);
+my $time_tag = Glib::Timeout->add(1000, \&rescan);
+my $time_tag2 = Glib::Timeout->add(1000, \&update);
update();
rescan();
-while ($isconnected == -2 || $isconnected == -1) {
- ugtk::gtkflush()
-}
+gtkflush() while $isconnected == -2 || $isconnected == -1;
-Gtk->timeout_remove($time_tag2);
-$time_tag2 = Gtk->timeout_add(20000, \&update);
+Glib::Source->remove($time_tag2);
+$time_tag2 = Glib::Timeout->add(20000, \&update);
connection() if $connect && !$isconnected || $disconnect && $isconnected;
$window1->main;
-my_gtk->exit(0);
+ugtk2->exit(0);
my $during_connection;
my $first;
@@ -180,20 +178,20 @@ sub connection {
$button_connect->set_sensitive(0);
$button_close->set_sensitive(0);
$statusbar->pop(1);
- $statusbar->push(1, $wasconnected ? N("Disconnecting from the Internet ") : N("Connecting to the Internet "));
+ $statusbar->push(1, $wasconnected ? N("Disconnecting from Internet ") : N("Connecting to Internet "));
if ($wasconnected == 1) {
$c_time = time();
- $ct_tag = Gtk->timeout_add(1000, sub {
+ $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($e); 1 })
- } else { Gtk->timeout_remove($ct_tag) }
+ $label_ct->set_label($e); 1 })
+ } else { Glib::Source->remove($ct_tag) }
my $nb_point = 1;
$first = 1;
- my $tag = Gtk->timeout_add(1000, sub {
+ my $tag = Glib::Timeout->add(1000, sub {
$statusbar->pop(1);
- $statusbar->push(1, ($wasconnected == 1 ? N("Disconnecting from the Internet ") : N("Connecting to the Internet "))
+ $statusbar->push(1, ($wasconnected == 1 ? N("Disconnecting from Internet ") : N("Connecting to Internet "))
. join('', map { "." } (1..$nb_point)));
$nb_point++;
if ($nb_point < 4) { return 1 }
@@ -224,8 +222,8 @@ sub connection {
$ret = 0;
$statusbar->pop(1);
$statusbar->push(1, $wasconnected ? ($isconnected ?
- N("Disconnection from the Internet failed.") :
- N("Disconnection from the Internet complete.")) :
+ N("Disconnection from Internet failed.") :
+ N("Disconnection from Internet complete.")) :
($isconnected ?
N("Connection complete.") :
N("Connection failed.\nVerify your configuration in the Mandrake Control Center."))
@@ -233,7 +231,7 @@ sub connection {
my $delay = 1000;
# keep the message displayed longer if there is a problem.
if ($isconnected == $wasconnected) { $delay = 5000 }
- my $tag3 = Gtk->timeout_add($delay, sub {
+ my $tag3 = Glib::Timeout->add($delay, sub {
$button_connect->set_sensitive(1);
$button_close->set_sensitive(1);
@@ -245,7 +243,7 @@ sub connection {
return $ret });
my $netc = {};
- Gtk->main_iteration while Gtk->events_pending;
+ gtkflush();
if ($wasconnected == 1) {
system("/etc/sysconfig/network-scripts/net_cnx_down &");
@@ -275,7 +273,7 @@ sub rescan {
push(@{$monitor->{$intf}{stack_r}}, $recv - $refr);
shift @{$monitor->{$intf}{stack_r}} if @{$monitor->{$intf}{stack_r}} > 250;
- $monitor->{$intf}{labelr}->set(formatXiB($recv - $monitor->{$intf}{initialr}));
+ $monitor->{$intf}{labelr}->set_label(formatXiB($recv - $monitor->{$intf}{initialr}));
$monitor->{$intf}{referencer} = $recv;
$monitor->{$intf}{transmita} += $transmit - $reft;
@@ -288,24 +286,24 @@ sub rescan {
push(@{$monitor->{$intf}{stack_t}}, $transmit - $reft);
shift @{$monitor->{$intf}{stack_t}} if @{$monitor->{$intf}{stack_t}} > 250;
- $monitor->{$intf}{labelt}->set(formatXiB($transmit - $monitor->{$intf}{initialt}));
+ $monitor->{$intf}{labelt}->set_label(formatXiB($transmit - $monitor->{$intf}{initialt}));
$monitor->{$intf}{referencet} = $transmit;
draw_monitor($monitor->{$intf});
}
- $label_sr->set(formatXiB($monitor->{sr}) . "/s");
- $label_st->set(formatXiB($monitor->{st}) . "/s");
+ $label_sr->set_label(formatXiB($monitor->{sr}) . "/s");
+ $label_st->set_label(formatXiB($monitor->{st}) . "/s");
$monitor->{sra} += $monitor->{sr};
$monitor->{sta} += $monitor->{st};
$monitor->{nba}++;
if ($monitor->{nba} > 9) {
- $label_sra->set(formatXiB($monitor->{sra}/10) . "/s");
- $label_sta->set(formatXiB($monitor->{sta}/10) . "/s");
+ $label_sra->set_label(formatXiB($monitor->{sra}/10) . "/s");
+ $label_sta->set_label(formatXiB($monitor->{sta}/10) . "/s");
$monitor->{sra} = 0;
$monitor->{sta} = 0;
$monitor->{nba} = 0;
}
- $label_cnx_type->set($netcnx->{type});
+ $label_cnx_type->set_label($netcnx->{type});
$monitor->{$_} = 0 foreach 'sr', 'st';
1;
}
@@ -319,7 +317,7 @@ sub get_val {
foreach (@line) {
s/\s*(\w*)://;
my $intf = $1;
- push @ret,$intf;
+ push @ret, $intf;
$monitor->{$intf}{val} = [split()];
$monitor->{$intf}{intf} = $intf;
}
@@ -328,28 +326,22 @@ sub get_val {
sub change_color {
my ($color) = @_;
- my $window = Gtk::Window->new('toplevel');
+ my $dialog = _create_dialog(N("Color configuration"));
my $doit;
- $window->signal_connect(delete_event => sub { Gtk->main_quit });
- $window->set_position(1);
- $window->set_title(N("Color configuration"));
- $window->set_border_width(5);
- gtkadd(gtkset_modal($window,1),
- gtkpack_(new Gtk::VBox(0,5),
- 1, my $colorsel = new Gtk::ColorSelection,
- 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -end),
- gtksignal_connect(new Gtk::Button(N("OK")), clicked => sub { $doit = 1; Gtk->main_quit }),
- gtksignal_connect(new Gtk::Button(N("Cancel")), clicked => sub { Gtk->main_quit }),
- )
- )
- );
- $colorsel->set_color($color->red/65535, $color->green/65535, $color->blue/65535, $color->pixel);
- $window->show_all;
- Gtk->main;
- $window->destroy;
- $doit or return $color;
- my (@color) = $colorsel->get_color;
- my_gtk::gtkcolor($color[0]*65535, $color[1]*65535, $color[2]*65535);
+ $dialog->vbox->add(my $colorsel = Gtk2::ColorSelection->new);
+ gtkpack($dialog->action_area,
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-cancel'), clicked => sub {
+ $doit = 1;
+ $dialog->destroy;
+ }),
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-ok'), clicked => sub {
+ $dialog->destroy;
+ }),
+ );
+ $colorsel->set_current_color($color);
+ $dialog->show_all;
+ $dialog->run;
+ $doit ? $colorsel->get_current_color : $color;
}
my $scale;
@@ -372,77 +364,77 @@ sub update {
$default_intf = $intf;
$monitor->{$intf}{initialr} = $monitor->{$intf}{val}[0];
$monitor->{$intf}{initialt} = $monitor->{$intf}{val}[8];
- $monitor->{$intf}{darea} = new Gtk::DrawingArea();
- $monitor->{$intf}{darea}->set_events(["pointer_motion_mask"]);
- $notebook->append_page(gtkshow(my $page = gtkpack_(new Gtk::VBox(0,0),
- 0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,0), 5),
- gtksize($monitor->{$intf}{darea},300, 150)),
- 0, gtkpack_(new Gtk::HBox(0,0),
- 1, gtkpack__(new Gtk::VBox(0,0),
- gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
- gtksignal_connect(my $button_t = gtkset_relief(new Gtk::Button(), 'none'), clicked => sub {
+ $darea = Gtk2::DrawingArea->new();
+ $darea->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, $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]->draw(undef);
+ $_[0]->queue_draw;
}),
- N("sent: "), $monitor->{$intf}{labelt} = new Gtk::Label("0")),
- gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
- gtksignal_connect(my $button_r = gtkset_relief(new Gtk::Button(), 'none'), clicked => sub {
+ 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]->draw(undef);
+ $_[0]->queue_draw;
}),
- N("received: "), $monitor->{$intf}{labelr} = new Gtk::Label("0")),
- gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
- gtksignal_connect(my $button_a = gtkset_relief(new Gtk::Button(), 'none'), clicked => sub {
+ 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]->draw(undef);
+ $_[0]->queue_draw;
}),
N("average"))
),
- 0, gtkpack__(gtkset_border_width(new Gtk::VBox(0,0), 5),
- gtkadd(gtkset_shadow_type(new Gtk::Frame(N("Local measure")), 'etched_out'),
- gtkpack__(gtkset_border_width(new Gtk::VBox(0,0), 5),
- gtkpack__(new Gtk::HBox(0,0),
+ 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),
N("sent: "),
- my $measure_t = new Gtk::Label("0")
+ my $measure_t = Gtk2::Label->new("0")
),
- gtkpack__(new Gtk::HBox(0,0),
+ gtkpack__(Gtk2::HBox->new(0,0),
N("received: "),
- my $measure_r = new Gtk::Label("0")
+ my $measure_r = Gtk2::Label->new("0")
)
)
)
)
)
)),
- new Gtk::Label($intf));
+ Gtk2::Label->new($intf));
foreach my $i ([$button_t, $gct], [$button_r, $gcr], [$button_a, $gca]) {
- $i->[0]->add(gtksignal_connect(gtkshow(gtksize(gtkset_usize(new Gtk::DrawingArea(), 10, 10), 10, 10)), expose_event => sub { $_[0]->window->draw_rectangle($i->[1], 1, 0, 0, 10, 10) }));
+ $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) }));
}
- $notebook->set_page($notebook->page_num($page));
+ $notebook->set_current_page($notebook->page_num($page));
$monitor->{$intf}{page} = $notebook->page_num($page);
- $monitor->{$intf}{pixmap_db} = new Gtk::Gdk::Pixmap($monitor->{$intf}{darea}->window, 300, 150);
+ $darea->realize;
+ $pixmap = Gtk2::Gdk::Pixmap->new($darea->window, $width, $height, $darea->window->get_depth);
$monitor->{$intf}{referencer} = $monitor->{$intf}{val}[0];
$monitor->{$intf}{referencet} = $monitor->{$intf}{val}[8];
- $monitor->{$intf}{pixmap_db}->draw_rectangle($monitor->{$intf}{darea}->style->black_gc, 1, 0, 0, 300, 150);
- $monitor->{$intf}{darea}->signal_connect(motion_notify_event =>
- sub { my ($w, $e) = @_;
- my $x = $e->{'x'} - 50;
- my $y = $e->{'y'};
- my $received = $x >= 0 ? $monitor->{$intf}{stack_r}[$x] : 0;
- my $transmitted = $x >= 0 ? $monitor->{$intf}{stack_t}[$x] : 0;
- my $type;
- $y * $scale / 150 < $transmitted and $type = N("transmitted");
- (150 - $y) * $scale / 150 < $received and $type = N("received");
- $measure_r->set(formatXiB($received));
- $measure_t->set(formatXiB($transmitted));
- });
- $monitor->{$intf}{darea}->signal_connect(expose_event => sub {
- $monitor->{$intf}{darea}->window->draw_pixmap($monitor->{$intf}{darea}->style->bg_gc('normal'),
- $monitor->{$intf}{pixmap_db}, 0, 0, 0, 0, 300, 150);
- });
+ $pixmap->draw_rectangle($darea->style->black_gc, 1, 0, 0, $width, $height);
+ $darea->signal_connect(motion_notify_event => sub {
+ my ($w, $e) = @_;
+ my $x = $e->x - 50;
+ my $y = $e->y;
+ my $received = $x >= 0 ? $monitor->{$intf}{stack_r}[$x] : 0;
+ my $transmitted = $x >= 0 ? $monitor->{$intf}{stack_t}[$x] : 0;
+ my $type;
+ $y * $scale / 150 < $transmitted and $type = N("transmitted");
+ (150 - $y) * $scale / 150 < $received and $type = N("received");
+ $measure_r->set_label(formatXiB($received));
+ $measure_t->set_label(formatXiB($transmitted));
+ });
+ $darea->signal_connect(expose_event => sub {
+ $darea->window->draw_drawable($darea->style->bg_gc('normal'), $pixmap, 0, 0, 0, 0, $width, $height);
+ });
}
}
foreach (@interfaces) {
@@ -461,13 +453,13 @@ sub update {
$statusbar->pop(1);
$statusbar->push(1, $isconnected == 1 ? N("Connected") : N("Not connected"));
}
- $label_c->set($isconnected == 1 ? N("Disconnect %s", $netcnx->{type}) : N("Connect %s", $netcnx->{type}));
- $isconnected == 1 ? $pix_c->set($pix_c_map, $pix_c_mask) : $pix_c->set($pix_d_map, $pix_d_mask);
+ $label_c->set_label($isconnected == 1 ? N("Disconnect %s", $netcnx->{type}) : N("Connect %s", $netcnx->{type}));
+ $pix_c->set_from_pixbuf($isconnected == 1 ? $pix_c_map : $pix_d_map);
$button_connect->set_sensitive(1);
}
if (!(-e $connect_file && -e $disconnect_file)) {
$button_connect->set_sensitive(0);
- $label_c->set("No internet connection configured");
+ $label_c->set_label("No internet connection configured");
}
1;
}
@@ -481,8 +473,8 @@ sub in_ifconfig {
sub draw_monitor {
my ($o) = @_;
- defined $o->{darea} or return;
- $o->{pixmap_db}->draw_rectangle($o->{darea}->style->black_gc, 1, 0, 0, 300, 150);
+ defined $darea or return;
+ $pixmap->draw_rectangle($darea->style->black_gc, 1, 0, 0, $width, $height);
my $maxr = 0;
foreach (@{$o->{stack_r}}) { $maxr = $_ if $_ > $maxr }
my $maxt = 0;
@@ -492,7 +484,7 @@ sub draw_monitor {
$scale = $ech;
my $step = 49;
foreach (@{$o->{stack_t}}) {
- $o->{pixmap_db}->draw_rectangle($gct, 1, $step, 0, 1, $_*150/$ech);
+ $pixmap->draw_rectangle($gct, 1, $step, 0, 1, $_*150/$ech);
$step++;
}
$step = 49;
@@ -501,7 +493,7 @@ sub draw_monitor {
if ($_ != -1) {
if (!defined $av1) { $av1 = $_ } else { defined $av2 or $av2 = $_ }
if ($av1 && $av2) {
- $o->{pixmap_db}->draw_line($gca, $step-15, $av1*150/$ech, $step-5, $av2*150/$ech);
+ $pixmap->draw_line($gca, $step-15, $av1*150/$ech, $step-5, $av2*150/$ech);
$av1 = $av2;
undef $av2;
$last_a = $step-50;
@@ -511,7 +503,7 @@ sub draw_monitor {
}
$step = 49;
foreach (@{$o->{stack_r}}) {
- $o->{pixmap_db}->draw_rectangle($gcr, 1, $step, 151-$_*150/$ech, 1, $_*150/$ech);
+ $pixmap->draw_rectangle($gcr, 1, $step, 151-$_*150/$ech, 1, $_*150/$ech);
$step++;
}
$step = 49;
@@ -520,7 +512,7 @@ sub draw_monitor {
if ($_ != -1) {
if (!defined $av1) { $av1 = $_ } else { defined $av2 or $av2 = $_ }
if (defined $av1 && defined $av2) {
- $o->{pixmap_db}->draw_line($gca, $step-15, 151-$av1*150/$ech, $step-5, 151-$av2*150/$ech);
+ $pixmap->draw_line($gca, $step-15, 151-$av1*150/$ech, $step-5, 151-$av2*150/$ech);
$av1 = $av2;
undef $av2;
}
@@ -529,11 +521,11 @@ sub draw_monitor {
}
my $switch = 1;
- my $gcl = new Gtk::Gdk::GC($o->{darea}->window);
- $gcl->set_foreground($o->{darea}->window->get_colormap->color_white);
+ my $gcl = Gtk2::Gdk::GC->new($darea->window);
+ $gcl->set_foreground($darea->style->white);
$gcl->set_line_attributes(1, 'on-off-dash', 'not-last', 'round');
for (my $i = 30; $i <= 120; $i += 30) {
- $o->{pixmap_db}->draw_line($gcl, 50, $i, 300, $i);
+ $pixmap->draw_line($gcl, 50, $i, 300, $i);
my ($gc2, $text);
my ($dif1, $dif2);
if ($last_a) {
@@ -548,24 +540,28 @@ sub draw_monitor {
$gc2 = $gcr;
my $x_l = 5;
if ($i > 30 && $switch) {
- $o->{pixmap_db}->draw_line($gct, $x_l, 0, $x_l, $i-30);
- $o->{pixmap_db}->draw_line($gct, $x_l-1, 0, $x_l-1, $i-30);
- $o->{pixmap_db}->draw_line($gct, $x_l+1, 0, $x_l+1, $i-30);
- $o->{pixmap_db}->draw_polygon($gct, 1, $x_l-4, $i-30, $x_l+5, $i-30, $x_l, $i-25);
+ $pixmap->draw_line($gct, $x_l, 0, $x_l, $i-30);
+ $pixmap->draw_line($gct, $x_l-1, 0, $x_l-1, $i-30);
+ $pixmap->draw_line($gct, $x_l+1, 0, $x_l+1, $i-30);
+ $pixmap->draw_polygon($gct, 1, $x_l-4, $i-30, $x_l+5, $i-30, $x_l, $i-25);
}
if ($switch) {
- $o->{pixmap_db}->draw_line($gcr, $x_l, 150, $x_l, $i);
- $o->{pixmap_db}->draw_line($gcr, $x_l-1, 150, $x_l-1, $i);
- $o->{pixmap_db}->draw_line($gcr, $x_l+1, 150, $x_l+1, $i);
- $o->{pixmap_db}->draw_polygon($gcr, 1, $x_l-5, $i, $x_l+5, $i, $x_l, $i-6);
+ $pixmap->draw_line($gcr, $x_l, 150, $x_l, $i);
+ $pixmap->draw_line($gcr, $x_l-1, 150, $x_l-1, $i);
+ $pixmap->draw_line($gcr, $x_l+1, 150, $x_l+1, $i);
+ $pixmap->draw_polygon($gcr, 1, $x_l-5, $i, $x_l+5, $i, $x_l, $i-6);
}
undef $switch;
} else {
$text = formatXiB($i*$ech/150);
$gc2 = $gct;
}
- my $w = $style->font->string_width($text);
- $o->{pixmap_db}->draw_string($style->font, $gc2, 45-$w, $i+5, ($text));
+ $pixmap->draw_layout($gc2, 45-string_width($darea, $text), $i-5, $darea->create_pango_layout($text));
}
- $o->{darea}->draw(undef);
+ $darea->queue_draw;
+}
+
+
+sub test_connected {
+ $::testing || network::tools::test_connected;
}