From ee9bc5ffb7cf8c4b42a0ebe4137f484e1455b353 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sat, 15 Jan 2005 17:08:43 +0000 Subject: gtk2 progress bar when formatting ext3 --- perl-install/fs/format.pm | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'perl-install') diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index 7032f3413..0bae41ce8 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -105,7 +105,8 @@ sub mke2fs { local $/ = "\b"; local $_; while (<$F>) { - $wait_message->('', $1, $2) if m!^\s*(\d+)/(\d+)\b!; + #- when this is over, it still takes some time, hence the 85% + $wait_message->('', $1, int($2 / 0.85)) if m!^\s*(\d+)/(\d+)\b!; } return close($F); } @@ -118,14 +119,31 @@ sub disable_forced_fsck { sub wait_message { my ($in) = @_; - my $w; + my ($w, $progress, $last_msg, $displayed); $w, sub { my ($msg, $current, $total) = @_; if ($msg) { - $w ||= $in->wait_message('', $msg); + $last_msg = $msg; + if (!$w) { + $progress = Gtk2::ProgressBar->new if $in->isa('interactive::gtk'); + $w = $in->wait_message('', [ '', if_($progress, $progress) ]); + if ($progress) { + #- don't show by default, only if we are given progress information + $progress->hide; + $progress->signal_connect(expose_event => sub { $displayed = 1; 0 }); + } + } $w->set($msg); } elsif ($total) { - $w->set("$current / $total"); + log::l("set_fraction $current / $total"); + if ($progress) { + $progress->set_fraction($current / $total); + $progress->show; + $displayed = 0; + mygtk2::flush() while !$displayed; + } else { + $w->set([ $last_msg, "$current / $total" ]); + } } }; } -- cgit v1.2.1