package wizards;
# $Id$
use strict;
use c;
use common;
=head1 NAME
wizards - a layer on top of interactive that ensure proper stepping
=head1 SYNOPSIS
use wizards;
use interactive;
my $wiz = wizards->new({
allow_user => "", # do we need root
defaultimage => "", # wizard icon
init => sub { }, # code run on wizard startup
name => "logdrake", # wizard title
needed_rpm => "packages list", # packages to install before running the wizard
pages => {
{
name => "welcome", # first step
next => "step1", # which step should be displayed after the current one
pre => sub { }, # code executing when stepping backward
post => sub { }, # code executing when stepping forward;
# returned value is next step name (it overrides "next" field)
end => , # is it the last step ?
default => , # default answer for yes/no or when data does not conatains any fields
no_cancel => , # do not display the cancel button (eg for first step)
no_back => , # do not display the back button (eg for first step)
ignore => , # do not stack this step for back stepping (eg for warnings and the like steps)
interactive_help_id => , # help id (for installer only)
data => [], # the actual data passed to interactive
},
{
name => "step1",
data => [
{
# usual interactive fields:
label => N("Banner:"),
val => \$o->{var}{wiz_banner},
list => [] ,
# wizard layer variables:
boolean_list => "", # provide default status for booleans list
},
],
},
},
});
my $in = 'interactive'->vnew;
$wiz->process($in);
=head1 DESCRIPTION
wizards is a layer built on top of the interactive layer that do proper
backward/forward stepping for us.
A step is made up of a name/description, a list of interactive fields (see
interactive documentation), a "complete", "pre" and "post" callbacks, an help
id, ...
The "pre" callback is run first. Its only argument is the actual step hash.
Then, if the "name" fiels is a code reference, that callback is run and its
actual result is used as the description of the step.
At this stage, the interactive layer is used to display the actual step.
The "post" callback is only run if the user has steped forward.
Alternatively, you can call safe_process() rather than process().
safe_process() will handle for you the "wizcancel" exception while running the
wizard. Actually, it should be used everywhere but where the wizard is not the
main path (eg "mail alert wizard" in logdrake, ...), ie when you may need to do
extra exception managment such as destroying the wizard window and the like.
=cut
sub new {
my ($class, $o) = @_;
bless $o, $class;
}
sub check_rpm {
my ($in, $rpms) = @_;
foreach my $rpm (@$rpms) {
next if $in->do_pkgs->is_installed($rpm);
if ($in->ask_okcancel(N("Error"), N("%s is not installed\nClick \"Next\" to install or \"Cancel\" to quit", $rpm))) {
$::testing and next;
if (!$in->do_pkgs->install($rpm)) {
local $::Wizard_finished = 1;
$in->ask_okcancel(N("Error"), N("Installation failed"));
$in->exit;
}
} else { $in->exit }
}
}
# sync me with interactive::ask_from_normalize() if needed:
my %default_callback = (complete => sub { 0 });
sub process {
my ($o, $in) = @_;
local $::isWizard = 1;
local $::Wizard_title = $o->{name} || $::Wizard_title;
local $::Wizard_pix_up = $o->{defaultimage} || $::Wizard_pix_up;
#require_root_capability() if $> && !$o->{allow_user} && !$::testing;
check_rpm($in, $o->{needed_rpm}) if ref($o->{needed_rpm});
if (defined $o->{init}) {
my ($res, $msg) = &{$o->{init}};
if (!$res) {
$in->ask_okcancel(N("Error"), $msg);
die "wizard failed" if !$::testing;
}
}
my @steps; # steps stack
# initial step:
my $next = 'welcome';
my $page = $o->{pages}{welcome};
while ($next) {
local $::Wizard_no_previous = $page->{no_back};
local $::Wizard_no_cancel = $page->{no_cancel} || $page->{end};
local $::Wizard_finished = $page->{end};
defined $page->{pre} and $page->{pre}($page);
die qq(inexistant "$next" wizard step) if is_empty_hash_ref($page);
# FIXME or the displaying fails
my $data = defined $page->{data} ? (ref($page->{data}) eq 'CODE' ? $page->{data}->() : $page->{data}) : [];
my $data2;
foreach my $d (@$data) {
$d->{val} = ${$d->{val_ref}} if $d->{val_ref};
$d->{list} = $d->{list_ref} if $d->{list_ref};
#$d->{val} = ref($d->{val}) eq 'CODE' ? $d->{val}->() : $d->{val};
if ($d->{boolean_list}) {
my $i;
foreach (@{$d->{boolean_list}}) {
push @$data2, { text => $_, type => 'bool', val => \${$d->{val}}->[$i], disabled => $d->{disabled} };
$i++;
}
} else {
push @$data2, $d;
}
}
my $name = ref($page->{name}) ? $page->{name}->() : $page->{name};
my %yesno = (yes => N("Yes"), no => N("No"));
my $yes = ref($page->{default}) eq 'CODE' ? $page->{default}->() : $page->{default};
$data2 = [ { val => \$yes, type => 'list', list => [ keys %yesno ], format => sub { $yesno{$_[0]} },
gtk => { use_boxradio => 1 } } ] if $page->{type} eq "yesorno";
my $a;
if (ref $data2 eq 'ARRAY' && @$data2) {
$a = $in->ask_from_({ title => $o->{name},
messages => $name,
(map { $_ => $page->{$_} || $default_callback{$_} } qw(complete)),
if_($page->{interactive_help_id}, interactive_help_id => $page->{interactive_help_id}),
}, $data2);
} else {
$a = $in->ask_okcancel($o->{name}, $name, $yes || 'ok');
}
# interactive->ask_yesorno does not support stepping forward or backward:
$a = $yes if $a && $page->{type} eq "yesorno";
if ($a) {
# step forward:
push @steps, $next if !$page->{ignore} && $steps[-1] ne $next;
my $current = $next;
$next = defined $page->{post} ? $page->{post}($page->{type} eq "yesorno" ? $yes eq 'yes' : $a) : 0;
return if $page->{end};
if (!$next) {
if (!defined $o->{pages}{$next}) {
$next = $page->{next};
} else {
die qq(the "$next" page (from previous wizard step) is undefined) if !$next;
}
}
die qq(Step "$current": inexistant "$next" page) if !exists $o->{pages}{$next};
} else {
# step back:
$next = pop @steps;
}
$page = $o->{pages}{$next};
}
}
sub safe_process {
my ($o, $in) = @_;
eval { $o->process($in) };
my $err = $@;
if ($err =~ /wizcancel/) {
$in->exit(0);
} else {
die $err if $err;
}
}
1;
iv>
#
-# Copyright (C) 2002,2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002,2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
# Copyright (C) 2002 Mandriva
#
# Matias Griese <mahagr@utu.fi>, 2001, 2002.
@@ -8,14 +8,14 @@
# Taisto Kuikka <69319@batman.jypoly.fi>, 2003, 2004.
# Esa Linna <denzo@mbnet.fi>, 2004.
# Thomas Backlund <tmb@mandrake.org>, 2002, 2003, 2004, 2005.
-# Thomas Backlund <tmb@mandriva.org>, 2005, 2006.
+# Thomas Backlund <tmb@mandriva.org>, 2005, 2006, 2008.
# Anssi Hannula <anssi@mandriva.org>, 2007.
msgid ""
msgstr ""
-"Project-Id-Version: drakconf\n"
+"Project-Id-Version: control-center-fi\n"
"POT-Creation-Date: 2008-02-14 17:42+0100\n"
-"PO-Revision-Date: 2007-09-30 03:25+0300\n"
-"Last-Translator: Anssi Hannula <anssi@mandriva.org>\n"
+"PO-Revision-Date: 2008-02-29 18:24+0200\n"
+"Last-Translator: Thomas Backlund <tmb@mandriva.org>\n"
"Language-Team: Finnish <fi@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -306,8 +306,7 @@ msgstr "Emmanuel Blindauer"
#: ../contributors.pl:35
#, c-format
msgid "lm_sensors for 2.6 kernel, testing, some contrib packages."
-msgstr ""
-"lm_sensors 2.6 sarajn ytimelle, testausta, joitakin contrib paketteja."
+msgstr "lm_sensors 2.6 sarajn ytimelle, testausta, joitakin contrib paketteja."
#: ../contributors.pl:36
#, c-format
@@ -570,10 +569,8 @@ msgstr "Tunnistustapa"
#: ../control-center:153
#, c-format
-msgid ""
-"Select the authentication method (local, NIS, LDAP, Windows Domain, ...)"
-msgstr ""
-"Valitse tunnistustapa (paikallinen, NIS, LDAP, Windows Verkkoalue, ...)"
+msgid "Select the authentication method (local, NIS, LDAP, Windows Domain, ...)"
+msgstr "Valitse tunnistustapa (paikallinen, NIS, LDAP, Windows Verkkoalue, ...)"
#: ../control-center:162
#, c-format
@@ -593,8 +590,7 @@ msgstr "Aseta automaattikirjautuminen"
#: ../control-center:173
#, c-format
msgid "Enable autologin and select the user to automatically log in"
-msgstr ""
-"Ota automaattikirjautuminen käyttöön ja valitse käyttäjä joka käytetään"
+msgstr "Ota automaattikirjautuminen käyttöön ja valitse käyttäjä joka käytetään"
#: ../control-center:182
#, c-format
@@ -688,10 +684,8 @@ msgstr "Aseta henkilökohtainen palomuuri"
#: ../control-center:295
#, c-format
-msgid ""
-"Set up a personal firewall in order to protect the computer and the network"
-msgstr ""
-"Asetä henkilökohtainen palomuuri suojaaksesi tietokonetta ja lähiverkkoa."
+msgid "Set up a personal firewall in order to protect the computer and the network"
+msgstr "Asetä henkilökohtainen palomuuri suojaaksesi tietokonetta ja lähiverkkoa."
#: ../control-center:304 ../control-center:305
#, c-format
@@ -729,9 +723,9 @@ msgid "Manage hosts definitions"
msgstr "Hallitse koneiden määritykset"
#: ../control-center:355
-#, fuzzy, c-format
+#, c-format
msgid "Install & Remove Software"
-msgstr "Asenna ohjelmia"
+msgstr "Asenna & Poista Ohjelmia"
#: ../control-center:356
#, c-format
@@ -877,9 +871,9 @@ msgid "Activate and manage network profiles"
msgstr "Aktivoi ja hallitse verkkoprofiileja"
#: ../control-center:516
-#, fuzzy, c-format
+#, c-format
msgid "Access NFS shared drives and directories"
-msgstr "Windows-jakojen (Samba) asettaminen"
+msgstr "NFS-jakojen asettaminen"
#: ../control-center:517
#, c-format
@@ -889,7 +883,7 @@ msgstr "Aseta NFS-liitospisteet"
#: ../control-center:526
#, c-format
msgid "Share drives and directories using NFS"
-msgstr ""
+msgstr "Jaa asemat ja hakemistot käyttäen NFS"
#: ../control-center:527
#, c-format
@@ -929,8 +923,7 @@ msgstr "Ajoitetut tehtävät"
#: ../control-center:569
#, c-format
msgid "Schedule programs to run periodically or at given times"
-msgstr ""
-"Määritä ohjelmia joka suoritetaan määräaikaisesti tai märrittyihin aikoihin"
+msgstr "Määritä ohjelmia joka suoritetaan määräaikaisesti tai märrittyihin aikoihin"
#: ../control-center:578
#, c-format
@@ -968,9 +961,9 @@ msgid "Wireless connection"
msgstr "Langaton yhteys"
#: ../control-center:618
-#, fuzzy, c-format
+#, c-format
msgid "Access Windows (SMB) shared drives and directories"
-msgstr "Windows-jakojen (Samba) asettaminen"
+msgstr "Windows-jakojen (SMB) asettaminen"
#: ../control-center:619
#, c-format
@@ -978,9 +971,9 @@ msgid "Configuration of Windows (Samba) shared drives and directories"
msgstr "Windows-jakojen (Samba) asettaminen"
#: ../control-center:628
-#, fuzzy, c-format
+#, c-format
msgid "Share drives and directories with Windows (SMB) systems"
-msgstr "Jaa tietoja Windows-järjestelmän kanssa"
+msgstr "Jaa asemat ja hakemistot Windows (SMB) järjestelmien kanssa"
#: ../control-center:629
#, c-format
@@ -1000,8 +993,7 @@ msgstr "Aseta turvallisuusaste ja -tarkistus"
#: ../control-center:649
#, c-format
msgid "Set the system security level and the periodic security audit"
-msgstr ""
-"Aseta järjestelmän turvallisuusaste ja määräaikainen turvallisuustarkistus"
+msgstr "Aseta järjestelmän turvallisuusaste ja määräaikainen turvallisuustarkistus"
#: ../control-center:658
#, c-format
@@ -1061,9 +1053,9 @@ msgid "Configure VPN connection to secure network access"
msgstr "Aseta turvallinen VPN-etäyhteys"
#: ../control-center:735
-#, fuzzy, c-format
+#, c-format
msgid "Access WebDAV shared drives and directories"
-msgstr "Windows-jakojen (Samba) asettaminen"
+msgstr "WebDAV-jakojen asettaminen"
#: ../control-center:736
#, c-format
@@ -1187,8 +1179,7 @@ msgstr "Aseta aika"
#: ../control-center:837
#, c-format
-msgid ""
-"Set the time of the server to be synchronized with an external time server"
+msgid "Set the time of the server to be synchronized with an external time server"
msgstr "Aseta palvelimen aika synkronoitavaksi ulkoisen aikapalvelimen kanssa"
#: ../control-center:839 ../control-center:840
@@ -1269,8 +1260,7 @@ msgstr "Aseta paikalliskone webbiselaimen kautta"
#: ../control-center:915
#, c-format
msgid "You don't seem to have webmin intalled. Local config is disabled"
-msgstr ""
-"Sinulla ei ole webmin asennettuna. Paikallinen asetus on poistettu käytöstä"
+msgstr "Sinulla ei ole webmin asennettuna. Paikallinen asetus on poistettu käytöstä"
#: ../control-center:917
#, c-format
@@ -1518,7 +1508,7 @@ msgstr "/_Julkaisutiedot"
#: ../control-center:1267
#, c-format
msgid "/What's _New?"
-msgstr ""
+msgstr "/Mitä Uutta?"
#: ../control-center:1268
#, c-format
@@ -1920,41 +1910,3 @@ msgstr "Näyttö"
msgid "Screen Resolution"
msgstr "Näyttötila"
-#~ msgid "/_Upload the hardware list"
-#~ msgstr "/Lähetä laitteistolista"
-
-#~ msgid "<control>U"
-#~ msgstr "<control>U"
-
-#~ msgid "Upload the hardware list"
-#~ msgstr "Lähetä laitteistolistaus"
-
-#~ msgid "Account:"
-#~ msgstr "Käyttäjätunnus:"
-
-#~ msgid "Password:"
-#~ msgstr "Salasana:"
-
-#~ msgid "Hostname:"
-#~ msgstr "Tietokoneen nimi:"
-
-#~ msgid "Please wait"
-#~ msgstr "Odota hetki"
-
-#~ msgid "Uploading in progress"
-#~ msgstr "Lähetys käynnissä"
-
-#~ msgid "Manage software"
-#~ msgstr "Ohjelmistonhallinta"
-
-#~ msgid "Use NFS shares"
-#~ msgstr "Käytä NFS-jakoja"
-
-#~ msgid "Share your data through NFS"
-#~ msgstr "Jaa tietoja NFS-jakamisen avulla"
-
-#~ msgid "Manage Samba configuration"
-#~ msgstr "Hallitse Samban asetuksia"
-
-#~ msgid "Use WebDAV shares"
-#~ msgstr "Käytä WebDAV-jakoja"