1 |
#!/usr/bin/perl |
2 |
################################################################################ |
3 |
# Mandriva Online # |
4 |
# # |
5 |
# Copyright (C) 2008 Mandriva # |
6 |
# # |
7 |
# Thierry Vignaud <tvignaud at mandriva dot com> # |
8 |
# # |
9 |
# This program is free software; you can redistribute it and/or modify # |
10 |
# it under the terms of the GNU General Public License Version 2 as # |
11 |
# published by the Free Software Foundation. # |
12 |
# # |
13 |
# This program is distributed in the hope that it will be useful, # |
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
16 |
# GNU General Public License for more details. # |
17 |
# # |
18 |
# You should have received a copy of the GNU General Public License # |
19 |
# along with this program; if not, write to the Free Software # |
20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # |
21 |
################################################################################ |
22 |
|
23 |
use strict; |
24 |
use lib qw(/usr/lib/libDrakX /usr/lib/libDrakX/drakfirsttime); |
25 |
use standalone; # for explanations |
26 |
use common; |
27 |
|
28 |
BEGIN { unshift @::textdomains, 'mgaonline' } |
29 |
|
30 |
use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version |
31 |
use ugtk2 qw(:all); |
32 |
use mgaonline; |
33 |
use mgaapplet_gui; |
34 |
use interactive; |
35 |
|
36 |
get_product_id(); |
37 |
configure(); |
38 |
|
39 |
ugtk2::exit(0); |
40 |
|
41 |
|
42 |
sub configure() { |
43 |
my $w = ugtk2->new(N("Adding an additional package medium"), width => -1); |
44 |
|
45 |
my %config = getVarsFromSh($config_file); |
46 |
|
47 |
# convert from ms to seconds: |
48 |
$config{FIRST_CHECK_DELAY} /= 1000; |
49 |
# convert from seconds to minutes : |
50 |
$config{FIRST_CHECK_DELAY} /= 60; |
51 |
# convert from seconds to hours : |
52 |
$config{UPDATE_FREQUENCY} /= 3600; |
53 |
|
54 |
# sanity check: |
55 |
$config{UPDATE_FREQUENCY} = 1 if $config{UPDATE_FREQUENCY} < 1; |
56 |
|
57 |
# config file has negative options but GUI want positive options (HIG): |
58 |
invbools_for_display(\%config); |
59 |
|
60 |
my $_ww = eval { gtknew('HScale', digits => 5) }; |
61 |
my $is_hscale_unsupported = $@; |
62 |
my $product = translate_product(); |
63 |
|
64 |
my $res = |
65 |
fill_n_run_portable_dialog( |
66 |
$w, |
67 |
[ |
68 |
if_(!$::isEmbedded, get_banner(N("Updates Configuration"))), |
69 |
gtknew('Label_Left', text => N("Here you can configure the updates applet"), @common), |
70 |
gtknew('Table', col_spacings => 5, row_spacings => 5, children => [ |
71 |
[ gtknew('Label', alignment => [ 0, 1 ], text => N("Update frequency (hours)")), |
72 |
gtknew($is_hscale_unsupported ? ('Entry', text_ref => \$config{UPDATE_FREQUENCY}) |
73 |
: ('HScale', |
74 |
digits => 0, |
75 |
lower => 1, |
76 |
upper => 24, |
77 |
step_increment => 1, |
78 |
width => 100, |
79 |
value_ref => \$config{UPDATE_FREQUENCY})) ], |
80 |
[ gtknew('Label', alignment => [ 0, 1 ], text => N("First check delay (minutes)")), |
81 |
gtknew($is_hscale_unsupported ? ('Entry', text_ref => \$config{UPDATE_FREQUENCY}) |
82 |
: ('HScale', |
83 |
digits => 0, |
84 |
lower => 5, |
85 |
upper => 30, |
86 |
step_increment => 1, |
87 |
value_ref => \$config{FIRST_CHECK_DELAY})) ], |
88 |
[ gtknew('CheckButton', |
89 |
text => N("Check for newer \"%s\" releases", $product), |
90 |
active_ref => \$config{DO_NOT_ASK_FOR_DISTRO_UPGRADE}, |
91 |
), |
92 |
], |
93 |
if_(is_restricted_media_supported(), |
94 |
[ gtknew('CheckButton', |
95 |
text => N("Check for missing \"%s\" media", N("Restricted")), |
96 |
active_ref => \$config{DO_NOT_ASK_FOR_RESTRICTED}, |
97 |
), |
98 |
]), |
99 |
if_(is_enterprise_media_supported(), |
100 |
[ gtknew('CheckButton', |
101 |
text => N("Check for missing \"%s\" media", N("Enterprise")), |
102 |
active_ref => \$config{DO_NOT_ASK_FOR_ENTERPRISE_UPDATE_MEDIA}, |
103 |
), |
104 |
]), |
105 |
]), |
106 |
create_okcancel($w), #, N("Next"), N("Cancel")), |
107 |
]); |
108 |
|
109 |
if ($res) { |
110 |
# convert from seconds to minutes : |
111 |
$config{FIRST_CHECK_DELAY} *= 60; |
112 |
|
113 |
# convert from seconds to hours : |
114 |
$config{UPDATE_FREQUENCY} *= 3600; |
115 |
|
116 |
# convert back into ms from seconds: |
117 |
$config{FIRST_CHECK_DELAY} *= 1000; |
118 |
|
119 |
# config file has negative options but GUI want positive options (HIG): |
120 |
invbools_for_display(\%config); |
121 |
|
122 |
setVarsInSh($config_file, \%config); |
123 |
} |
124 |
} |
125 |
|
126 |
sub invbools_for_display { |
127 |
my ($config) = @_; |
128 |
foreach (qw(DO_NOT_ASK_FOR_DISTRO_UPGRADE DO_NOT_ASK_FOR_RESTRICTED DO_NOT_ASK_FOR_ENTERPRISE_UPDATE_MEDIA)) { |
129 |
invbool(\$config->{$_}); |
130 |
} |
131 |
} |