From 590cf32515eca733c2ae6224ff4e6df9caedc70a Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Mon, 4 Jul 2005 08:13:09 +0000 Subject: add a progress bar fonction --- common/Wizcommon.pm | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'common/Wizcommon.pm') diff --git a/common/Wizcommon.pm b/common/Wizcommon.pm index edbbbf3f..4cf9eadf 100644 --- a/common/Wizcommon.pm +++ b/common/Wizcommon.pm @@ -27,7 +27,7 @@ use MDK::Common; use MDK::Wizard::IFCFG; our @ISA = qw(Exporter); -our @EXPORT = qw(check_started run_command_and_log test_host_domain); +our @EXPORT = qw(check_started run_command_and_log test_host_domain wizard_progress_bar); my $net; @@ -63,6 +63,41 @@ sub test_host_domain { } +sub wizard_progress_bar { + use lib qw(/usr/lib/libDrakX); + use ugtk2 qw(:wrappers); + my ($command, $descr) = @_; + my ($value, $timer); + my $my_win = ugtk2->new(""); + my $window1 = $my_win->{window}; + gtkadd($window1, + gtkpack(Gtk2::VBox->new(0,0), + gtkpack_(Gtk2::VBox->new(0, 3), + 0, my $text = Gtk2::Label->new($descr), + 0, my $text2 = Gtk2::Label->new(), + 0, Gtk2::HSeparator->new, + 0, my $pbar = Gtk2::ProgressBar->new, + ), + ), + ); + $window1->realize; + $pbar->set_pulse_step(0.1); + + open(TMP, "$command 2>&1 |"); + while ($value = ) { + $timer = Glib::Timeout->add(10, sub {}); + $pbar->pulse; + $text2->set_text($value); + gtkflush(); + next; + $my_win->main; + $window1->show_all; + undef $value; + } + close TMP; + $my_win->destroy; +} + my $timeout; sub gtktext_get_log { -- cgit v1.2.1