summaryrefslogtreecommitdiffstats
path: root/common/Wizcommon_gtk3.pm
blob: a5b89acbba732ef284f068f3b38850b2ba2c085f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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;