home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / clients / inst_mouse.ycp < prev    next >
Encoding:
Text File  |  2000-03-30  |  4.7 KB  |  165 lines

  1. /**
  2.  *
  3.  *
  4.  * $Id: inst_mouse.ycp,v 1.40 2000/03/02 15:57:26 kkaempf Exp $
  5.  *
  6.  * Module:        inst_mouse.ycp
  7.  *
  8.  * Author:         Klaus KΣmpf
  9.  *                 Michael Hager
  10.  *
  11.  * Purpose:        If the mouse wasn't autodetected, ask the user
  12.  *            default is ps2
  13.  *
  14.  * user_settings:
  15.  *
  16.  * rw: "mouse"    autoprobed mouse or the selected mouse
  17.  * rw: "mouse_id" id of the mouse selected by the user in the mouse selection
  18.  *                (is used only to pre-select the mouse after a move
  19.  *           backward and after that forward)
  20.  * ro: "language" current language for the dialog
  21.  *
  22.  * "rw" read/write
  23.  * "ro" readonly
  24.  */
  25. {
  26.  
  27.   map     user_mouse    = lookup(user_settings,   "mouse",    $[] );
  28.   string  user_mouse_id    = lookup(user_settings,   "mouse_id", "");
  29.   boolean test_mode    = lookup ( user_settings, "test_mode", false );
  30.  
  31.   if ( (size (user_mouse) > 0) && (user_mouse_id != "") && ! test_mode )
  32.       return `auto;
  33.  
  34.   // Autoprobing failed, let the user decide
  35.  
  36.   string language    = lookup(user_settings,   "language", default_language);
  37.   user_mouse        = $["xf86":"PS/2","gpm":"ps2","device":"/dev/psaux","emul3":true];
  38.   user_mouse_id        = "ps2";
  39.  
  40.   // Build the contents of the dialog.
  41.  
  42.   /*
  43.    * Mouse
  44.    */
  45.   map mice = ReadY2("mouse.ycp");
  46.  
  47.   // build mouse selection box
  48.   // with the default selection according to user_settings
  49.  
  50.   term contents =
  51.       `VBox(
  52.         `SelectionBox(`id(`mouse),
  53.               // title for selection box 'mouse'
  54.               _("Please choose your mouse type from the list"),
  55.               maplist(`mouse_code, `mouse_value, mice, ``{
  56.                   map    mouse_name_map = select(mouse_value, 0);
  57.                   string mouse_name     = translate(mouse_name_map , language);
  58.                   return `item(`id(mouse_code),
  59.                        mouse_name,
  60.                        user_mouse_id == mouse_code);
  61.               } ) ),
  62.         
  63.         // push button to apply the currently selected mouse setting
  64.         `PushButton( `id(`apply), _("&Test") )
  65.         );
  66.  
  67.   // Help text for mouse settings dialog - START:
  68.   //
  69.   // The user chooses a mouse type (e.g. Logitech MouseMan, PS/2,
  70.   // Microsoft serial) from a list. He can apply the settings with a
  71.   // "Test" button or just leave this dialog with "next" (this will
  72.   // also apply the settings). Special care needs to be taken to
  73.   // explain keyboard procedures since the mouse very likely does not
  74.   // work right now - otherwise the user wouldn't see this screen in
  75.   // the first place.
  76.   string help_text = UI(_("\
  77. <p>
  78. YaST2 could not identify your type of mouse.
  79. Choose the <b>mouse type</b> attached to your computer.
  80. </p>" ) );
  81.  
  82.   
  83.   // Help text - continued
  84.   help_text = help_text + UI(_("\
  85. <p>
  86. Use the arrow keys to select a mouse. If the selection bar does not
  87. move, hit the <b><i>Tab</i></b> key (maybe repeatedly) until it does.
  88. </p>
  89. " ) );
  90.  
  91.   
  92.   // Help text - continued
  93.   help_text = help_text + UI(_("\
  94. <p>
  95. Use the <b>Test</b> button to apply and test the selected settings.
  96. </p>
  97. " ) );
  98.  
  99.   
  100.   // Help text - END
  101.   help_text = help_text + UI(_("\
  102. <p>
  103. If you select <b>None</b>, you have to use the keyboard as
  104. described in the manual.
  105. </p>
  106. <br>" ) );
  107.  
  108.   UI(`SetWizardContents(_("Mouse configuration"), contents,
  109.             help_text,
  110.             Args(0), Args(1)));
  111.  
  112.   any ret = nil;
  113.  
  114.   repeat
  115.       {
  116.       // In this dialog only, set the keyboard focus to the mouse
  117.       // selection box for every iteration of the input loop. If
  118.       // anything goes wrong here, the user has a hard enough time
  119.       // getting his system to work-  even without having to worry about
  120.       // how to get the keyboard focus into the list. He most likely
  121.       // doesn't have a working mouse right now (otherwise he wouldn't
  122.       // be here in the first place).
  123.  
  124.       // TODO
  125.       //    UI(`ControlWidget(dlg, `id(`mouse), `SetFocus()));
  126.  
  127.       ret = UI(`UserInput());
  128.  
  129.       if ( ret == `next || ret == `apply )
  130.       {
  131.           string mouse_id = UI(`QueryWidget(`id(`mouse), `CurrentItem));
  132.           list   entry    = lookup( mice, mouse_id);
  133.  
  134.           if ( entry != nil && entry != "non" )
  135.           {
  136.           map  mouse_tech_params  = select( entry, 1);
  137.           _debug("Mouse name: ", mouse_id );
  138.           _debug("Mouse tech params: ", mouse_tech_params);
  139.  
  140.           // get real mouse device
  141.           string realdevice = lookup (mouse_tech_params, "device", "");
  142.           // make symlink for X11
  143.           Symlink (realdevice, "/dev/mouse");
  144.           // fake mouse device as /dev/mouse for SetXMouse
  145.           mouse_tech_params = add (mouse_tech_params, "device", "/dev/mouse");
  146.  
  147.           if ( mouse_id != "non" )
  148.               SetXMouse( mouse_tech_params );
  149.           
  150.           // put back real device for inst_finish
  151.           mouse_tech_params = add (mouse_tech_params, "device", realdevice);
  152.  
  153.           user_settings = add(user_settings, "mouse", mouse_tech_params );
  154.           }
  155.           else
  156.           {
  157.           user_settings = add(user_settings, "mouse", nil );
  158.           }
  159.           user_settings = add(user_settings, "mouse_id", mouse_id );
  160.       }
  161.       } until (ret == `next || ret == `back);
  162.  
  163.   return ret;
  164. }
  165.