home *** CD-ROM | disk | FTP | other *** search
- /**************
- FILE : inst_mouse.ycp
- ***************
- PROJECT : YaST2 - Yet another Setup Tool
- :
- AUTHOR : Marcus SchΣfer <ms@suse.de>
- :
- BELONGS TO : YaST2 - GPM mouse configuration
- :
- DESCRIPTION : mouse.ycp will call inst_mouse to initialize
- : the target system GUI
- :
- STATUS : Development
- **************/
- /*! \brief YaST2 - GPM configuration interface
- *
- * File: inst_mouse.ycp
- * Package: Mouse configuration
- * Summary: Main client
- * Authors: Marcus SchΣfer <ms@suse.de>
- */
- {
- textdomain "mouse";
- //==========================================
- // Imports...
- //------------------------------------------
- import "Mode";
- import "Stage";
- import "Mouse";
- import "Wizard";
- import "Popup";
- import "GetInstArgs";
-
- //==========================================
- // Globals...
- //------------------------------------------
- string mouse_on_entry = Mouse::mouse;
- string mouse = Mouse::mouse;
-
- //==========================================
- // Build dialog
- //------------------------------------------
- if ( Mode::test() ) {
- mouse = "00_ps2";
- }
- term probe_mouse_check_button = `Empty();
- term test_button = `Empty();
-
- if (Mode::config()) {
- Wizard::HideAbortButton();
- } else {
- Wizard::OpenAcceptDialog();
- //test_button = `PushButton( `id(`apply), _("&Test") );
- }
-
- term contents =
- `VBox(
- `SelectionBox (`id(`mouse),
- _("Choose your &mouse type from the list"),
- maplist (string mouse_code, string mouse_name, Mouse::Selection (),
- ``{
- return `item(`id (mouse_code),
- mouse_name,
- mouse == mouse_code);
- } ) ),
- probe_mouse_check_button,
- `VSpacing(0.3),
- test_button,
- `VSpacing(0.5)
- );
-
- //==========================================
- // help texts
- //------------------------------------------
- string help_text = _("<p>
- Choose the <b>mouse type</b> of the mouse attached to your computer.
- </p>
- ");
-
- help_text = help_text + _("<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 = help_text + _("<p>
- If you select <b>None</b>, you have to use the keyboard as
- described in the manual.
- </p>");
-
- Wizard::SetContents(_("Mouse configuration"), contents,
- help_text,
- GetInstArgs::enable_back(), GetInstArgs::enable_next()
- );
-
- Wizard::SetDesktopIcon("mouse");
- if( Stage::initial() ) {
- Wizard::SetTitleIcon( "mouse" );
- }
-
- Mouse::Set( Mouse::mouse );
-
- any ret = nil;
-
- //==========================================
- // main loop
- //------------------------------------------
- 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).
- UI::SetFocus(`id(`mouse));
- ret = Wizard::UserInput();
-
- if ( !Mode::config() && ret == `abort
- && Popup::ConfirmAbort (`painless) )
- {
- break;
- }
-
- if ( ret == `next || ret == `apply ) {
- string new_mouse = (string) UI::QueryWidget(`id(`mouse), `CurrentItem);
-
- if ( new_mouse != nil )
- {
- Mouse::Set( new_mouse );
- if (Mode::config())
- {
- import "AutoinstGeneral";
- AutoinstGeneral::mouse["id"] = Mouse::mouse;
- }
- }
-
- if ( ret == `next && new_mouse != mouse_on_entry )
- {
- y2milestone("Clearing unique key <%1> due to manual selection",
- Mouse::unique_key
- );
- Mouse::unique_key = "";
- }
- }
- } until( ret == `next || ret == `back || ret == `cancel );
-
- if ( ret == `back || ret == `cancel )
- {
- y2milestone("`back or `cancel restoring: <%1>", mouse_on_entry );
- Mouse::Set( mouse_on_entry );
- }
-
- Wizard::CloseDialog();
- return ret;
- }
-