home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- *
- * $Id: inst_mouse.ycp,v 1.40 2000/03/02 15:57:26 kkaempf Exp $
- *
- * Module: inst_mouse.ycp
- *
- * Author: Klaus KΣmpf
- * Michael Hager
- *
- * Purpose: If the mouse wasn't autodetected, ask the user
- * default is ps2
- *
- * user_settings:
- *
- * rw: "mouse" autoprobed mouse or the selected mouse
- * rw: "mouse_id" id of the mouse selected by the user in the mouse selection
- * (is used only to pre-select the mouse after a move
- * backward and after that forward)
- * ro: "language" current language for the dialog
- *
- * "rw" read/write
- * "ro" readonly
- */
- {
-
- map user_mouse = lookup(user_settings, "mouse", $[] );
- string user_mouse_id = lookup(user_settings, "mouse_id", "");
- boolean test_mode = lookup ( user_settings, "test_mode", false );
-
- if ( (size (user_mouse) > 0) && (user_mouse_id != "") && ! test_mode )
- return `auto;
-
- // Autoprobing failed, let the user decide
-
- string language = lookup(user_settings, "language", default_language);
- user_mouse = $["xf86":"PS/2","gpm":"ps2","device":"/dev/psaux","emul3":true];
- user_mouse_id = "ps2";
-
- // Build the contents of the dialog.
-
- /*
- * Mouse
- */
- map mice = ReadY2("mouse.ycp");
-
- // build mouse selection box
- // with the default selection according to user_settings
-
- term contents =
- `VBox(
- `SelectionBox(`id(`mouse),
- // title for selection box 'mouse'
- _("Please choose your mouse type from the list"),
- maplist(`mouse_code, `mouse_value, mice, ``{
- map mouse_name_map = select(mouse_value, 0);
- string mouse_name = translate(mouse_name_map , language);
- return `item(`id(mouse_code),
- mouse_name,
- user_mouse_id == mouse_code);
- } ) ),
-
- // push button to apply the currently selected mouse setting
- `PushButton( `id(`apply), _("&Test") )
- );
-
- // Help text for mouse settings dialog - START:
- //
- // The user chooses a mouse type (e.g. Logitech MouseMan, PS/2,
- // Microsoft serial) from a list. He can apply the settings with a
- // "Test" button or just leave this dialog with "next" (this will
- // also apply the settings). Special care needs to be taken to
- // explain keyboard procedures since the mouse very likely does not
- // work right now - otherwise the user wouldn't see this screen in
- // the first place.
- string help_text = UI(_("\
- <p>
- YaST2 could not identify your type of mouse.
- Choose the <b>mouse type</b> attached to your computer.
- </p>" ) );
-
-
- // Help text - continued
- help_text = help_text + UI(_("\
- <p>
- Use the arrow keys to select a mouse. If the selection bar does not
- move, hit the <b><i>Tab</i></b> key (maybe repeatedly) until it does.
- </p>
- " ) );
-
-
- // Help text - continued
- help_text = help_text + UI(_("\
- <p>
- Use the <b>Test</b> button to apply and test the selected settings.
- </p>
- " ) );
-
-
- // Help text - END
- help_text = help_text + UI(_("\
- <p>
- If you select <b>None</b>, you have to use the keyboard as
- described in the manual.
- </p>
- <br>" ) );
-
- UI(`SetWizardContents(_("Mouse configuration"), contents,
- help_text,
- Args(0), Args(1)));
-
- any ret = nil;
-
- repeat
- {
- // In this dialog only, set the keyboard focus to the mouse
- // selection box for every iteration of the input loop. If
- // anything goes wrong here, the user has a hard enough time
- // getting his system to work- even without having to worry about
- // how to get the keyboard focus into the list. He most likely
- // doesn't have a working mouse right now (otherwise he wouldn't
- // be here in the first place).
-
- // TODO
- // UI(`ControlWidget(dlg, `id(`mouse), `SetFocus()));
-
- ret = UI(`UserInput());
-
- if ( ret == `next || ret == `apply )
- {
- string mouse_id = UI(`QueryWidget(`id(`mouse), `CurrentItem));
- list entry = lookup( mice, mouse_id);
-
- if ( entry != nil && entry != "non" )
- {
- map mouse_tech_params = select( entry, 1);
- _debug("Mouse name: ", mouse_id );
- _debug("Mouse tech params: ", mouse_tech_params);
-
- // get real mouse device
- string realdevice = lookup (mouse_tech_params, "device", "");
- // make symlink for X11
- Symlink (realdevice, "/dev/mouse");
- // fake mouse device as /dev/mouse for SetXMouse
- mouse_tech_params = add (mouse_tech_params, "device", "/dev/mouse");
-
- if ( mouse_id != "non" )
- SetXMouse( mouse_tech_params );
-
- // put back real device for inst_finish
- mouse_tech_params = add (mouse_tech_params, "device", realdevice);
-
- user_settings = add(user_settings, "mouse", mouse_tech_params );
- }
- else
- {
- user_settings = add(user_settings, "mouse", nil );
- }
- user_settings = add(user_settings, "mouse_id", mouse_id );
- }
- } until (ret == `next || ret == `back);
-
- return ret;
- }
-