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 / autoinstall / autoinst_dialogs.ycp < prev    next >
Text File  |  2006-11-29  |  6KB  |  192 lines

  1. /**
  2.  * File:    include/autoinstall/autoinst_dialogs.ycp
  3.  * Package:    Auto-installation
  4.  * Summary:    Define Profile file location
  5.  * Authors:    Anas Nashif <nashif@suse.de>
  6.  *
  7.  * $Id: autoinst_dialogs.ycp 24042 2005-07-14 13:37:53Z ug $
  8.  */
  9.  
  10. {
  11.     textdomain "autoinst";
  12.     import "Label";
  13.     import "Storage";
  14.  
  15.     /**
  16.       * Shows a dialog when 'control file' can't be found
  17.       * @param original Original value 
  18.       * @return string new value
  19.       */
  20.     define string ProfileSourceDialog (string original)
  21.     {
  22.             string helptext = _("<p>
  23. A profile for this machine could not be found or retrieved.
  24. Check that you entered the correct location
  25. on the command line and try again. Because of this error, you
  26. can only enter a URL to a profile and not to a directory. If you
  27. are using rules or host name-based control files, restart the
  28. installation process and make sure the control files are accessible.</p>
  29. ");
  30.             string title = _("System Profile Location");
  31.  
  32.             UI::OpenDialog(`opt( `decorated ),
  33.                     `HBox(
  34.                         `HWeight(50, `RichText( helptext )),
  35.                         `HStretch(),
  36.                         `HSpacing(1),
  37.                         `HWeight(50,
  38.                             `VBox(
  39.                                 `Heading( title),
  40.                                 `VSpacing(1),
  41.                                 `VStretch(),
  42.                                 `Left(`TextEntry(`id(`uri), _("&Profile Location:"), original )),
  43.                                 `VSpacing(1),
  44.                                 `VStretch(),
  45.                                 `HBox(
  46.                                     `PushButton(`id(`retry), `opt(`default),  Label::RetryButton()   ),
  47.                                     `PushButton(`id(`abort),  Label::AbortButton() )
  48.                                     )
  49.                                 )
  50.                             )
  51.                         )
  52.                     );
  53.  
  54.             string uri = "";
  55.             while (true) {
  56.                 symbol ret = (symbol)UI::UserInput();
  57.  
  58.                 if (ret == `abort && Popup::ConfirmAbort (`painless))
  59.                 {
  60.                     break;
  61.                 }
  62.                 else if (ret == `retry)
  63.                 {
  64.                     uri = (string)UI::QueryWidget(`id(`uri), `Value );
  65.                     if (uri == "")
  66.                         continue;
  67.                     else
  68.                         break;
  69.                 }
  70.             }
  71.  
  72.             UI::CloseDialog();
  73.             return uri;
  74.         }
  75.  
  76.  
  77.  
  78.     /**
  79.      * Disk selection dialog
  80.      * @return string device
  81.      */
  82.     define string DiskSelectionDialog()
  83.     {
  84.         y2milestone("Selecting disk manually....");
  85.         map<string, map> tm = Storage::GetTargetMap();
  86.         term contents = `Dummy();
  87.  
  88.         if( size(tm) > 0)
  89.         {
  90.             term buttonbox = `VBox();
  91.  
  92.             integer i = 0;
  93.             foreach( string tname, map tdata, tm,
  94.                     ``{
  95.                     if( Storage::IsRealDisk( tdata ))
  96.                     {
  97.                     string tlinename = tdata["name"]:"?";
  98.                     string tline = "&" + (i+1) + ":    " + tlinename;
  99.                     boolean sel = Storage::GetPartDisk()==tname &&
  100.                     Storage::GetPartMode()!="CUSTOM";
  101.                     buttonbox = add( buttonbox,
  102.                         `Left(`RadioButton(`id(tname), tline, sel )));
  103.                     i = i + 1;
  104.                     }
  105.                     });
  106.  
  107.             buttonbox = add(buttonbox, `VSpacing(0.8) );
  108.  
  109.  
  110.             // This dialog selects the target disk for the installation.
  111.             // Below this label, all targets are listed that can be used as
  112.             // installation target
  113.  
  114.             // heading text
  115.             contents = `Frame( _("Choose a hard disk"),
  116.                     `RadioButtonGroup(`id(`options),
  117.                         `VBox( `VSpacing(0.4),
  118.                             `HSquash(buttonbox),
  119.                             `VSpacing(0.4)
  120.                             )
  121.                         )
  122.                     );
  123.         }
  124.         else
  125.         {
  126.  
  127.             contents = `Label (_("No disks found."));
  128.         }
  129.  
  130.         // There are several hard disks found. Linux is completely installed on
  131.         // one hard disk - this selection is done here
  132.         // "Preparing Hard Disk - Step 1" is the description of the dialog what to
  133.         // do while the following locale is the help description
  134.         // help part 1 of 1
  135.         string help_text = _("<p>
  136. All hard disks automatically detected on your system
  137. are shown here. Select the hard disk on which to install &product;.
  138. </p>");
  139.         term buttons = `HBox(
  140.                 `PushButton(`id(`ok), `opt(`default), Label::OKButton() ),
  141.                 `PushButton(`id(`abort), Label::AbortButton() )
  142.                 );
  143.  
  144.  
  145.  
  146.         term ask_device_dialog = `HBox(
  147.                 `VSpacing( 15 ),       // force dialog height
  148.                 `VBox(
  149.                     `HSpacing( 30 ), // force help text width
  150.                     `RichText( help_text )
  151.                     ),
  152.                 `HSpacing( 3 ),
  153.                 `VBox(
  154.                     `VSpacing( 1 ),
  155.                     `Heading(_("Hard Disk Selection") ),
  156.                     contents,
  157.                     `VStretch(),
  158.                     buttons
  159.  
  160.                     ),
  161.                 `HSpacing( 3 )
  162.                 );
  163.  
  164.         UI::OpenDialog(`opt(`decorated), ask_device_dialog);
  165.  
  166.         any ret = nil;
  167.         string option = "";
  168.  
  169.         repeat
  170.         {
  171.             ret = UI::UserInput();
  172.             y2milestone("ret=%1", ret);
  173.             if( ret == `ok )
  174.             {
  175.                 option = (string) UI::QueryWidget(`id(`options), `CurrentButton);
  176.                 y2milestone( "selected disk: %1", option );
  177.                 if( option == nil )
  178.                 {
  179.                     // there is a selection from that one option has to be
  180.                     // chosen - at the moment no option is chosen
  181.                     Popup::Message(_("Select one of the options to continue."));
  182.                     ret = nil;
  183.                 }
  184.             }
  185.         } until ( ret == `ok || ret == `abort );
  186.  
  187.         UI::CloseDialog();
  188.         return option;
  189.     }
  190. // EOF
  191. }
  192.