home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * $Id: inst_environment.ycp,v 1.73 2000/03/13 11:46:06 kkaempf Exp $
- *
- * Module: inst_environment.ycp
- *
- * Author: Klaus KΣmpf
- * Michael Hager
- * Stefan Hundhammer <sh@suse.de>
- *
- * Purpose: Let the user choose keyboard and timezone.
- * Set the console font for the target machine.
- * The font depends on the current language.
- *
- * user_settings:
- *
- * wr: "console_font" \
- * wr: "console_unicodemap" > set console font
- * wr: "console_screenmap" /
- *
- * rw: "keyboard" the keyboardseting for the installation and
- * for target machine
- * rw: "timezone" the timezone for the target machine
- *
- * "rw" read/write
- * "wr" write only
- *
- * Reads:
- * timezone.ycp: a map with all supported timezones
- * keyboard.ycp: a map which contains all supported keyboards
- * consolefonts.ycp: map language to the corresponding font
- *
- *
- */
- {
- boolean test_mode = lookup ( user_settings, "test_mode", false );
-
- // map keyboard map back to yast1 (for install.inf)
-
- map keymap2yast1 =
- $[
- "english-uk" : "us",
- "english-us" : "us",
- "german" : "de-lat1-nd",
- "german-ch" : "de-lat1-nd",
- "french" : "fr-latin1",
- "french-ch" : "fr-latin1",
- "italian" : "it",
- "spanish" : "es",
- "dutch" : "nl",
- "portugese" : "pt2",
- "portugese-br" : "br-abnt2",
- "hungarian" : "hu",
- "polish" : "Pl02",
- "greek" : "gr",
- "russian" : "ru1",
- "czech" : "cz-lat2"
- ];
-
- /*
- * Set the console (text mode) keyboard as specified.
- * Uses the 'loadkeys' program.
- */
-
- define SetConsoleKeyboard( map all_keyboards, string keyboard_name ) ``{
- list keyboard_desc = lookup ( all_keyboards, keyboard_name, [] );
- string keymap = lookup ( select ( keyboard_desc, 1 ), "ncurses", "us.map.gz" );
- string loadkeys_command = "loadkeys " + keymap;
- Shell( loadkeys_command );
- return loadkeys_command;
- };
-
-
- /*
- * Set the X keyboard as specified.
- * Uses the 'xkbset' command (originally from SaX).
- */
-
- define SetXKeyboard( map all_keyboards, string keyboard_name ) ``{
- list keyboard_desc = lookup ( all_keyboards, keyboard_name, [] );
- list xkbset_args = lookup ( select ( keyboard_desc, 1 ), "qt", "english-us" );
- string xkbset_command = "xkbset";
- foreach( `arg, xkbset_args, ``{
- xkbset_command = xkbset_command + " \"" + arg + "\"";
- });
-
- if ( test_mode )
- y2log( .milestone, "inst_environment", 1,
- "Test mode - NOT setting X keyboard - would have called:\n" + xkbset_command );
- else
- Shell( xkbset_command );
-
- return xkbset_command;
- };
-
-
-
- string language = lookup( user_settings, "language" );
-
-
- /* ----------------------------------------------------------------------
- * Keyboard
- * ----------------------------------------------------------------------*/
-
- map lang2kbd =
- $[
- "en_GB" : "english-uk",
- "en_US" : "english-us",
- "en" : "english-us",
- "de_DE" : "german",
- "de_CH" : "german-ch",
- "de" : "german",
- "br_FR" : "french",
- "fr_FR" : "french",
- "fr_CH" : "french-ch",
- "it_IT" : "italian",
- "es_ES" : "spanish",
- "nl_NL" : "dutch",
- "pt_PT" : "portugese",
- "pt_BR" : "portugese-br",
- "hu_HU" : "hungarian",
- "pl_PL" : "polish",
- "el_GR" : "greek",
- "ru" : "russian",
- "ru_RU" : "russian",
- "ru_RU.KOI8-R" : "russian",
- "cs_CZ" : "czech"
- ];
-
- string default_keyboard = lookup ( lang2kbd, language, "english-us" );
-
- map keyboards = ReadY2( "keyboard.ycp" );
- string keyboard = lookup ( user_settings, "keyboard", default_keyboard );
- SetConsoleKeyboard( keyboards, keyboard );
- SetXKeyboard( keyboards, keyboard );
-
- // Create keyboard selection box with the default selection
- // according to user_settings
-
- term keyboardsel =
- `SelectionBox( `id( `keyboard ), `opt( `notify ),
- // title for selection box 'keyboard layout'
- _( "Keyboard layout" ),
- maplist( `key, `value, keyboards, ``{
- map languagemap = select( value, 0 );
- string name = translate( languagemap, language );
- return `item( `id( key ), name, key == keyboard );
- }));
-
- /* ----------------------------------------------------------------------
- * Timezone
- * ----------------------------------------------------------------------*/
-
- map timezones = ReadY2( "timezone.ycp" );
-
- // build up timezone selection box
- // with the default selection according to user_settings
-
- map lang2tz =
- $[
- "en_GB" : "Europe/London",
- "en_US" : "US/Pacific",
- "en" : "US/Pacific",
- "de_DE" : "Europe/Berlin",
- "de_CH" : "Europe/Zurich",
- "de_AT" : "Europe/Vienna",
- "de" : "Europe/Berlin",
- "br_FR" : "Europe/Paris",
- "fr_FR" : "Europe/Paris",
- "fr_CH" : "Europe/Zurich",
- "fr" : "Europe/Paris",
- "it_IT" : "Europe/Rome",
- "es_ES" : "Europe/Madrid",
- "nl_NL" : "Europe/Amsterdam",
- "pt_PT" : "Europe/Lisbon",
- "pt_BR" : "America/Buenos_Aires",
- "hu_HU" : "Europe/Budapest",
- "pl_PL" : "Europe/Warsaw",
- "el_GR" : "Europe/Athens",
- "ru" : "Europe/Moscow",
- "ru_RU" : "Europe/Moscow",
- "ru_RU.KOI8-R" : "Europe/Moscow",
- "cs_CZ" : "Europe/Prague"
- ];
-
- string default_timezone = lookup ( lang2tz, language, "Europe/Berlin" );
-
- string timezone = lookup ( user_settings, "timezone", default_timezone );
- map sortedzone = $[];
- foreach (`key, `languagemap, timezones, ``{
- string name = translate( languagemap, language );
- sortedzone = add (sortedzone, name, key);
- });
- term timezonesel =
- `SelectionBox( `id( `timezone ), `opt( `notify ),
- // title for selection box 'timezone'
- _( "Timezone" ),
- maplist( `name, `key, sortedzone, ``{
- return `item( `id( key ), name, key == timezone );
- })
- );
-
- /* ----------------------------------------------------------------------
- * Build dialog
- * ----------------------------------------------------------------------*/
-
- term contents =
- `HBox (
- `HWeight ( 5, `HStretch() ),
- `HWeight ( 100, `VBox(
- `HBox(
- `HWeight ( 50, keyboardsel ),
- `HWeight ( 2, `HStretch() ),
- `HWeight ( 50, timezonesel )
- ),
-
- // title for textentry widget to test your keyboard setting
- `TextEntry( _("Test your keyboard") ),
- `Label ( "" )
- )
- ),
- `HWeight ( 5, `HStretch() )
- );
-
- // Show a Wizardwindow with that contents.
- // Don't use the IDs `next, `back, and `help.
- //
-
- // help text for language,keyboard,timezone screen
- string help_text = UI( _( "\
- <p>
- Choose the <b>keyboard layout</b> you want to use now during
- installation and later in the installed system.
- </p>" ) );
-
- help_text = help_text + UI( _( "\
- <p>
- Then select the appropriate <b>timezone</b>. Choose the country or
- region where you are located.
- </p>" ) );
-
- help_text = help_text + UI( _( "\
- <p>
- If you are unsure, please use the default values already selected.
- </p>
- <br>" ) );
-
- // Screen title for keyboard and timezone screen
- any dlg = UI( `SetWizardContents( _( "Basic Configuration" ), contents,
- help_text,
- Args(0), Args(1) ) );
-
- any ret = nil;
-
- repeat
- {
- ret= UI( `UserInput() );
-
- if ( ret == `next || ret == `keyboard )
- {
- keyboard = UI( `QueryWidget( `id( `keyboard ), `CurrentItem ) );
- user_settings = add( user_settings, "keyboard", keyboard );
- string ckb_cmd = SetConsoleKeyboard( keyboards, keyboard );
- user_settings = add (user_settings, "ckb_cmd", ckb_cmd);
- string xkb_cmd = SetXKeyboard( keyboards, keyboard );
- user_settings = add (user_settings, "xkb_cmd", xkb_cmd);
-
- // replace Keytable in /etc/install.inf
-
- string yast1_keymap = lookup (keymap2yast1, keyboard, keyboard);
- user_settings = add (user_settings, "yast1_keymap", yast1_keymap);
-
- Shell ("grep -v ^Keytable /etc/install.inf > /tmp/install.inf");
- WriteString ("/tmp/yast2.inf", "Keytable: "+yast1_keymap+"\n");
- Shell ("cat /tmp/yast2.inf /tmp/install.inf > /etc/install.inf");
- }
-
- if ( ret == `next || ret == `timezone )
- {
- timezone = UI( `QueryWidget( `id( `timezone ), `CurrentItem ) );
- user_settings = add( user_settings, "timezone", timezone );
- }
- } until ( ret == `next || ret == `back || ret == `cancel );
-
- return ret;
- }
-