summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-04-06 09:36:51 +0000
committerdamien <damien@mandriva.com>2001-04-06 09:36:51 +0000
commit2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd (patch)
tree028d1895d010e4a2ce8b2cc2d1779fcf2b13366e /perl-install/standalone
parent633ac8dfe536691a27c99a6e744c0ef906a64326 (diff)
downloaddrakx-backup-do-not-use-2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd.tar
drakx-backup-do-not-use-2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd.tar.gz
drakx-backup-do-not-use-2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd.tar.bz2
drakx-backup-do-not-use-2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd.tar.xz
drakx-backup-do-not-use-2bd7933c1ce2cf625b042ec36a2e1074a03ac6bd.zip
updated
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-xperl-install/standalone/net_monitor96
1 files changed, 88 insertions, 8 deletions
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 6cabf232b..9e0f051d4 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -26,6 +26,7 @@ use my_gtk qw(:helpers :wrappers);
use Data::Dumper;
use common qw(:common :file :functional :system);
use strict;
+use netconnect;
my $default_intf;
init Gtk;
@@ -35,10 +36,13 @@ my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel
$window1->signal_connect ( delete_event => sub { Gtk->exit(0); });
$window1->set_position(1);
$window1->set_title(_("Network monitoring"));
-$window1->set_policy(0, 0, 1);
+$window1->set_policy(0, 0, 0);
$window1->set_border_width(5);
#$::isEmbedded or $window1->set_usize(500, 400);
+my @anim;
+($anim[$_]->[0], $anim[$_]->[1]) = gtkcreate_png("/usr/share/icons/anim_" . ($_ + 1) . ".png") foreach (0..9);
+my $isconnected=0;
my @interfaces;
my $monitor = {};
gtkadd($window1,
@@ -47,20 +51,27 @@ gtkadd($window1,
1, gtkpack_(new Gtk::HBox(0,5),
1, my $notebook = new Gtk::Notebook,
0, gtkpack_(new Gtk::VBox(0,5),
- 1, gtkadd(gtkset_shadow_type(new Gtk::Frame("Statistics"), 'etched_out'),
+ 1, gtkadd(gtkset_shadow_type(new Gtk::Frame(_("Statistics")), 'etched_out'),
gtkpack__(gtkset_border_width(new Gtk::VBox(0,5),5),
gtkpack__(new Gtk::HBox(0,0), _("Sending Speed : "), my $label_st = new Gtk::Label("")),
gtkpack__(new Gtk::HBox(0,0), _("Receiving Speed : "), my $label_sr = new Gtk::Label("")),
)
),
- 0, my $button_connect = new Gtk::Button("connect"),
+ 0, gtksignal_connect(my $button_connect = new Gtk::Button(), clicked => \&connection),
0, new Gtk::HSeparator,
- 0, my $button_more = new Gtk::Button("more")
+ 0, gtksignal_connect(new Gtk::Button(_("Close")), clicked => sub { Gtk->exit(0) })
)
),
- 0, new Gtk::Statusbar,
+ 0, my $statusbar = new Gtk::Statusbar
)
);
+my ($pix_c_map, $pix_c_mask) = gtkcreate_png("net_c.png");
+my ($pix_d_map, $pix_d_mask) = gtkcreate_png("net_d.png");
+$button_connect->add(gtkpack__(new Gtk::VBox(0,3),
+ my $pix_c = new Gtk::Pixmap($pix_d_map, $pix_d_mask),
+ my $label_c = new Gtk::Label(_("Connect to internet"))
+ ));
+$statusbar->push(1, "Not connected");
$window1->show_all();
$window1->set_policy (1, 1, 1);
update();
@@ -71,6 +82,61 @@ rescan();
Gtk->main;
Gtk->exit(0);
+sub connection {
+ my $dialog = new Gtk::Dialog();
+ $dialog->set_position(1);
+ $dialog->vbox->set_border_width(10);
+ my $darea1= new Gtk::DrawingArea();
+ $darea1->size(350,12);
+ $darea1->set_usize(350,12);
+ gtkpack_($dialog->vbox,
+ 0, $isconnected ? _("Deconnecting from internet ...") : _("Connecting to internet ..."),
+ 1, my $frame = gtkadd(gtkset_shadow_type(new Gtk::Frame(""), 'etched_out'),
+ $darea1)
+ );
+ my $bbox_dialog = new Gtk::HButtonBox;
+ $dialog->action_area->add($bbox_dialog);
+ $bbox_dialog->set_layout(-spread);
+ my $button_ok = gtksignal_connect(new Gtk::Button (_("OK")), clicked => sub {
+ $dialog->set_modal(0);
+ $dialog->destroy;
+ update();
+ });
+ $button_ok->set_sensitive(0);
+ $bbox_dialog->add($button_ok );
+ $dialog->show_all;
+ $dialog->set_modal(1);
+ $darea1->realize();
+ my $anim_nb=0;
+ my $tag = Gtk->timeout_add(100, sub {
+ $darea1->window->draw_pixmap
+ ($darea1->style->white_gc,
+ $anim[$anim_nb]->[0], 0, 0,
+ ($darea1->allocation->[2]-340)/2, ($darea1->allocation->[3]-15)/2,
+ 350, 13);
+ $anim_nb++;
+ $anim_nb > 9 and $anim_nb=0;
+ 1;
+ });
+ my $netc = {};
+ my $tag2 = Gtk->timeout_add(7000, sub {
+ Gtk->timeout_remove($tag);
+ $frame->destroy;
+ gtkpack_($dialog->vbox,
+ 1, $isconnected ? ( netconnect::connected('', $netc) ?
+ _("Deconnection from internet failed.") :
+ _("Deconnection from internet complete.")) :
+ ( netconnect::connected('', $netc) ?
+ _("Connection complete.") :
+ _("Connection failed.\nVerify your configuration in the Mandrake Control Center."))
+ );
+ $dialog->vbox->show_all;
+ $button_ok->set_sensitive(1);
+ 0;
+ });
+ $isconnected ? netconnect::disconnect_backend('') : netconnect::connect_backend('');
+}
+
sub rescan {
get_val();
foreach(@interfaces) {
@@ -121,7 +187,7 @@ sub update {
push (@interfaces, $intf);
$default_intf = $intf;
$monitor->{$intf}{initialr} = $monitor->{$intf}{val}->[0];
- $monitor->{$intf}{initialt}=$monitor->{$intf}{val}->[8];
+ $monitor->{$intf}{initialt} = $monitor->{$intf}{val}->[8];
$notebook->append_page(gtkshow(my $page = gtkpack_(new Gtk::VBox(0,0),
0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,0), 5),
gtksize(my $darea = $monitor->{$intf}{darea} = new Gtk::DrawingArea(),300, 150)),
@@ -132,9 +198,10 @@ sub update {
)),
new Gtk::Label($intf));
$notebook->set_page($notebook->page_num($page));
+ $monitor->{$intf}{page}=($notebook->page_num($page));
$monitor->{$intf}{pixmap_db} = new Gtk::Gdk::Pixmap($darea->window, 300, 150);
- $monitor->{$intf}{referencer}=$monitor->{$intf}{val}->[0];
- $monitor->{$intf}{referencet}=$monitor->{$intf}{val}->[8];
+ $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);
$darea->signal_connect( expose_event => sub {
$darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
@@ -142,6 +209,19 @@ sub update {
});
}
}
+ foreach(@interfaces) {
+ my $intf = $_;
+ if(!member($intf,@intfs)) {
+ $notebook->remove_page($monitor->{$intf}{page});
+ @interfaces = map { $_ if($_ ne $intf)} @interfaces;
+ }
+ }
+ my $netc={};
+ if(netconnect::connected('', $netc) == !$isconnected) {
+ $isconnected = $isconnected ? 0 : 1;
+ $label_c->set($isconnected ? _("Disconnect") : _("Connect"));
+ $isconnected ? $pix_c->set($pix_c_map, $pix_c_mask) : $pix_c->set($pix_d_map, $pix_d_mask);
+ }
1;
}