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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package mdkapplet_gui;
################################################################################
# Mandriva Online #
# #
# Copyright (C) 2003-2010 Mandriva #
# #
# Daouda Lo #
# Thierry Vignaud <tvignaud at mandriva dot com> #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License Version 2 as #
# published by the Free Software Foundation. #
# #
# 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. #
################################################################################
use strict;
use lib qw(/usr/lib/libDrakX);
use common;
our @ISA = qw(Exporter);
our @EXPORT = qw(
@common
%local_config
$localdir
$localfile
$width
fill_n_run_portable_dialog
new_link_button
new_portable_dialog
setVar
);
use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version
use ugtk2 qw(:all);
use lib qw(/usr/lib/libDrakX/drakfirsttime);
ugtk2::add_icon_path("/usr/share/mdkonline/pixmaps/");
our $localdir = "$ENV{HOME}/.MdkOnline";
our $localfile = "$localdir/mdkonline";
#compatibility
mkdir_p($localdir) if !-d $localdir;
-e "$ENV{HOME}/.mdkonline" and system("mv", "$ENV{HOME}/.mdkonline", $localfile);
our %local_config;
read_local_config();
our $width = 500;
our @common = (
# explicitely wrap (for 2008.1):
line_wrap => 1,
# workaround infamous 6 years old gnome bug #101968:
width => $width - 50,
);
sub new_portable_dialog {
my ($title) = @_;
ugtk2->new($title, width => $width + 20);
}
sub fill_n_run_portable_dialog {
my ($w, $widgets) = @_;
# use wizard button order (for both 2008.1 & 2009.0):
{
local $::isWizard = 1;
local $w->{pop_it} = 0;
local $::isInstall = 1;
my %children;
if ($::isEmbedded) {
my (@children_tight, $child);
@children_tight = @$widgets;
$child = pop @children_tight;
%children = (
children => [
(map { (0, $_) } @children_tight),
1, gtknew('Label'),
0, $child,
]
);
} else {
%children = (children_tight => $widgets);
}
gtkadd($w->{window}, gtknew('VBox', %children));
}
$w->{ok}->grab_focus;
$w->main;
}
sub new_link_button {
my ($url, $text) = @_;
my $link = Gtk2::LinkButton->new($url, $text);
$link->set_uri_hook(sub {
my (undef, $url) = @_;
run_program::raw({ detach => 1, setuid => get_parent_uid() }, 'www-browser', $url);
});
$link;
}
sub read_local_config() {
%local_config = getVarsFromSh($localfile);
}
sub setVar {
my ($var, $st) = @_;
my %s = getVarsFromSh($localfile);
$s{$var} = $st;
setVarsInSh($localfile, \%s);
}
|