home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / share / YaST2 / include / x11 / x11Dialog.ycp < prev   
Text File  |  2006-11-29  |  6KB  |  218 lines

  1. /**************
  2. FILE          : x11Dialog.ycp
  3. ***************
  4. PROJECT       : YaST2
  5.               :
  6. AUTHOR        : Marcus Sch├ñfer <ms@suse.de>
  7.               :
  8. BELONGS TO    : YaST2 - Yet another Setup Tool
  9.               : (X11 integration part using libsax)
  10.               :
  11. DESCRIPTION   : UI part of the automatic X11 configuration
  12.               : Authors: Marcus Sch├ñfer <ms@suse.de>
  13.               :
  14. STATUS        : Development
  15. **************/
  16. /**
  17.  * File:        dialog/x11Dialog.ycp
  18.  * Package:     X11 Configuration
  19.  * Summary:     Popups for the X11 proposal
  20.  * Authors:     Marcus Schaefer <ms@suse.de>
  21.  *
  22.  */
  23. {
  24. textdomain "x11";
  25.  
  26. //================================
  27. // Imports...
  28. //--------------------------------
  29. import "XMessages";
  30. import "Popup";
  31.  
  32. //================================
  33. // Popups
  34. //--------------------------------
  35. define void infoPopup () ``{
  36.     Popup::Message(XMessages::selectLink);
  37. }
  38.  
  39. define void warnNoteBookPopup () ``{
  40.     Popup::Message(XMessages::warnNoteBook);
  41. }
  42.  
  43. //================================
  44. // setupColors
  45. //--------------------------------
  46. define string setupColors ( string currentText ) ``{
  47.     string space = "                       ";
  48.     string topic = XMessages::selectColorDepth + space;
  49.     UI::OpenDialog(
  50.         `VBox(
  51.             `HBox(`ComboBox(`id(`depth),`opt(`hstretch),topic,
  52.                 [
  53.                     `item(`id(`bit8),  "256 [ 8 bit ]"        ),
  54.                     `item(`id(`bit15), "32768 [ 15 bit ]"     ),
  55.                     `item(`id(`bit16), "65536 [ 16 bit ]"     ),
  56.                     `item(`id(`bit24), "16.7 Mio. [ 24 Bit ]" )
  57.                 ]
  58.             )),
  59.             `Right (`HBox (
  60.                 `PushButton(`id(`ok),"&OK"),
  61.                 `PushButton(`id(`cancel),"&Cancel")
  62.             ))
  63.         )
  64.     );
  65.     UI::ChangeWidget(`id(`depth), `Value, currentText);
  66.     any id = UI::UserInput();
  67.     if (id == `cancel) {
  68.         UI::CloseDialog();
  69.         if (currentText == "256 [ 8 bit ]") {
  70.             return "8";
  71.         }
  72.         if (currentText == "32768 [ 15 bit ]") {
  73.             return "15";
  74.         }
  75.         if (currentText == "65536 [ 16 bit ]") {
  76.             return "16";
  77.         }
  78.         if (currentText == "16.7 Mio. [ 24 Bit ]") {
  79.             return "24";
  80.         }
  81.         return "undef";
  82.     }
  83.     any col=UI::QueryWidget(`id(`depth), `Value);
  84.     UI::CloseDialog();
  85.  
  86.     if ( col == `bit8  ) return "8";
  87.     if ( col == `bit15 ) return "15";
  88.     if ( col == `bit16 ) return "16";
  89.     if ( col == `bit24 ) return "24";
  90.  
  91.     return "undef";
  92. };
  93.  
  94. //================================
  95. // setupResolutions
  96. //--------------------------------
  97. define string setupResolutions ( list reslist, string currentText ) ``{
  98.     string space = "                       ";
  99.     string topic = XMessages::selectResolution + space;
  100.     UI::OpenDialog(
  101.         `VBox(
  102.             `HBox(`Left ( `ComboBox(`id(`resitem),topic, reslist))),
  103.             `Right (`HBox (
  104.                 `PushButton(`id(`ok),"&OK"),
  105.                 `PushButton(`id(`cancel),"&Cancel")
  106.             ))
  107.         )
  108.     );
  109.     UI::ChangeWidget(`id(`resitem), `Value, currentText);
  110.     any id = UI::UserInput();
  111.     if (id == `cancel) {
  112.         UI::CloseDialog();
  113.         return currentText;
  114.     }
  115.     any res=UI::QueryWidget(`id(`resitem), `Value);
  116.     UI::CloseDialog();
  117.     return (string)res;
  118. };
  119.  
  120. //================================
  121. // setupDisplaySize
  122. //--------------------------------
  123. define list<string> setupDisplaySize (
  124.     string currentTraversal, string currentRatios
  125. ) ``{
  126.     //string space = "                       ";
  127.     string topic1 = XMessages::selectDisplayTraversal;
  128.     string topic2 = XMessages::selectDisplayRatio;
  129.     list<string> traverlist = ["21","20","19","18.1","17","15.4","15","14.1","13.3","12.2"];
  130.     list<string> ratioslist = ["4/3","5/4","16/10"];
  131.     UI::OpenDialog(
  132.         `VBox(
  133.             `HBox(
  134.                 `Left  ( `ComboBox(`id(`traveritem),topic1, traverlist)),
  135.                 `Right ( `ComboBox(`id(`ratiositem),topic2, ratioslist))
  136.             ),
  137.             `Right (`HBox (
  138.                 `PushButton(`id(`ok),"&OK"),
  139.                 `PushButton(`id(`cancel),"&Cancel")
  140.             ))
  141.         )
  142.     );
  143.     UI::ChangeWidget(`id(`traveritem), `Value, currentTraversal);
  144.     UI::ChangeWidget(`id(`ratiositem), `Value, currentRatios);
  145.     any id = UI::UserInput();
  146.     list<string> result = [];
  147.     if (id == `cancel) {
  148.         UI::CloseDialog();
  149.         result = add (result,currentTraversal);
  150.         result = add (result,currentRatios);
  151.         return result;
  152.     }
  153.     any traversal=UI::QueryWidget(`id(`traveritem), `Value);
  154.     any ratios=UI::QueryWidget(`id(`ratiositem), `Value);
  155.     result = add (result,(string)traversal);
  156.     result = add (result,(string)ratios);
  157.     UI::CloseDialog();
  158.     return result;
  159. };
  160.  
  161. //================================
  162. // setupMonitor
  163. //--------------------------------
  164. define list setupMonitor (
  165.     map<string,list> data, string currentVendor, string currentModel
  166. ) ``{
  167.     any id = nil;
  168.     list<string> result = [];
  169.     list<string> vendorList = [];
  170.     foreach (string vendor, list models, data, ``{
  171.         vendorList = vendorList + vendor;
  172.     });
  173.     UI::OpenDialog(
  174.         `VBox(
  175.         `HSpacing(70),
  176.         `Left (`Label(XMessages::selectMonitor)),
  177.         `HBox (
  178.             `VSpacing(20),
  179.             `SelectionBox(`id(`vendor),`opt(`notify,`immediate),"",vendorList),
  180.             `SelectionBox(`id(`model) ,`opt(`notify,`immediate),"", [])
  181.         ),
  182.         `Right( `HBox (
  183.             `PushButton(`id(`ok),"&OK"),
  184.             `PushButton(`id(`cancel),"&Cancel")
  185.         ))
  186.         )
  187.     );
  188.     list modelList = sort (data[currentVendor]:[]);
  189.     UI::ChangeWidget(`id(`vendor), `CurrentItem, currentVendor);
  190.     UI::ChangeWidget(`id(`model) , `Items, modelList);
  191.     UI::ChangeWidget(`id(`model) , `CurrentItem, currentModel);
  192.     any vendor = (string)currentVendor;
  193.     any model  = (string)currentModel;
  194.     repeat {
  195.         id = UI::UserInput();
  196.         if (id == `vendor) {
  197.             vendor = UI::QueryWidget(`id(`vendor), `CurrentItem);
  198.             list modelList = sort (data[(string)vendor]:[]);
  199.             UI::ChangeWidget( `id( `model ), `Items, [] );
  200.             UI::ChangeWidget( `id( `model ), `Items, modelList );
  201.         }
  202.         if (id == `model) {
  203.             model  = UI::QueryWidget(`id(`model),  `CurrentItem);
  204.         }
  205.         if (id == `cancel) {
  206.             result[0] = (string)currentVendor;
  207.             result[1] = (string)currentModel;
  208.             UI::CloseDialog();
  209.             return result;
  210.         }
  211.     } until ( id == `ok );
  212.     UI::CloseDialog();
  213.     result[0] = (string)vendor;
  214.     result[1] = (string)model;
  215.     return result;
  216. };
  217. }
  218.