summaryrefslogtreecommitdiffstats
path: root/common/Wizcommon_gtk3.pm
diff options
context:
space:
mode:
Diffstat (limited to 'common/Wizcommon_gtk3.pm')
-rw-r--r--common/Wizcommon_gtk3.pm104
1 files changed, 104 insertions, 0 deletions
diff --git a/common/Wizcommon_gtk3.pm b/common/Wizcommon_gtk3.pm
new file mode 100644
index 00000000..a5b89acb
--- /dev/null
+++ b/common/Wizcommon_gtk3.pm
@@ -0,0 +1,104 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2003 Mandrakesoft
+#
+# Author: Florent Villard <warly@mandrakesoft.com>
+# A Ginies
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package MDK::Wizard::Wizcommon_gtk3;
+use strict;
+#use common;
+
+sub wizard_progress_bar {
+ use lib qw(/usr/lib/libDrakX);
+ use ugtk3 qw(:wrappers);
+ my ($command, $descr) = @_;
+ my ($value, $timer);
+ my $my_win = ugtk3->new("");
+ my $window1 = $my_win->{window};
+ gtkadd($window1,
+ gtkpack(Gtk3::VBox->new(0,0),
+ gtkpack_(Gtk3::VBox->new(0, 3),
+ 0, my $text = Gtk3::Label->new($descr),
+ 0, my $text2 = Gtk3::Label->new,
+ 0, Gtk3::HSeparator->new,
+ 0, my $pbar = Gtk3::ProgressBar->new,
+ ),
+ ),
+ );
+ $window1->realize;
+ $pbar->set_pulse_step(0.1);
+
+ local *TMP;
+ open(TMP, "GP_LANG=UTF-8 $command 2>&1 |");
+ while (<TMP>) {
+ $timer = Glib::Timeout->add(10, sub {});
+ $pbar->pulse;
+ s/\033\[[^mG]*[mG]//g;
+ $text2->set_text($_);
+ gtkflush();
+ next;
+ $my_win->main;
+ $window1->show_all;
+ #undef $value;
+ }
+ close TMP;
+ $my_win->destroy;
+ return 0;
+}
+
+sub gtk_log {
+ use lib qw(/usr/lib/libDrakX);
+ use ugtk3 qw(:wrappers);
+ use mygtk3 qw(gtknew);
+ my ($command, $text) = @_;
+ my $log_text = gtknew('TextView');
+ my $my_win = ugtk3->new("");
+ my $window1 = $my_win->{window};
+ #my $pid;
+ gtkadd($window1,
+ gtknew('VBox', spacing => 3, children => [
+ 0, Gtk3::Label->new($text),
+ 1, gtknew('ScrolledWindow', to_bottom => 1, child => $log_text),
+# 0, gtksignal_connect(gtknew('Button', text => N("cancel")), clicked => sub {
+ # if ($pid) {
+# $::in->ask_yesorno('', N("The command is still running. Do you want to kill it and quit the Wizard?")) or return;
+# kill 9, $pid and system("touch /tmp/wiz_error");
+# }
+# }
+# ),
+ ],
+ ),
+ );
+
+ my $TMP;
+ open($TMP, "GP_LANG=UTF-8 $command 2>&1 |");
+ gtktext_append($log_text, "$command\n\n");
+ while (<$TMP>) {
+ s/\033\[[^mG]*[mG]//g;
+ c::set_tagged_utf8($_);
+ gtktext_append($log_text, $_);
+ gtkflush();
+ next;
+ $my_win->main;
+ }
+ $window1->show_all;
+ close $TMP;
+ $my_win->destroy;
+}
+
+1;