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 / modules / Confirm.ycp < prev    next >
Encoding:
Text File  |  2006-11-29  |  3.5 KB  |  149 lines

  1. /**
  2.  * File:    modules/Confirm.ycp
  3.  *
  4.  * Package:    yast2
  5.  *
  6.  * Summary:    Confirmation routines
  7.  *
  8.  * Authors:    Michal Svec <msvec@suse.cz>
  9.  *
  10.  * Flags:    Stable
  11.  *
  12.  * $Id: Confirm.ycp 31242 2006-06-01 12:59:16Z locilka $
  13.  */
  14.  
  15. {
  16.  
  17. module "Confirm";
  18.  
  19. textdomain "base";
  20.  
  21. import "Label";
  22. import "Mode";
  23. import "Popup";
  24. import "Linuxrc";
  25.  
  26. /**
  27.  * Confirm hardware detection (only in manual installation)
  28.  * @param class hardware class (network cards)
  29.  * @return true on continue
  30.  */
  31. global define boolean Detection(string class) ``{
  32.  
  33.     if(Linuxrc::manual () != true) return true;
  34.  
  35.     UI::OpenDialog(`opt(`decorated), `HBox(
  36.     `HSpacing(1),
  37.     `HCenter(`HSquash(`VBox(
  38.         `HCenter(`HSquash(`VBox(
  39.         // Popup-Box for manual hardware detection.
  40.         // If the user selects 'manual installation' when
  41.         // booting from CD, YaST2 does not load any modules
  42.         // automatically, but asks the user for confirmation
  43.         // about every module.
  44.         // The popup box informs the user about the detected
  45.         // hardware and suggests a module to load.
  46.         // The user can confirm the module or change
  47.         // the suggested load command
  48.         //
  49.         // This is the heading of the popup box
  50.         `Left(`Heading(_("Confirm Hardware Detection"))),
  51.         `VSpacing(0.5),
  52.         // This is in information message. Next come the
  53.         // hardware class name (network cards).
  54.         `HVCenter(`Label(_("YaST2 will detect the following hardware:"))),
  55.         `HVCenter(`Heading(class)),
  56.         `VSpacing(0.5)
  57.         ))),
  58.         `HSquash(`HBox(
  59.         `HWeight(1, `PushButton(`id(`continue), `opt(`default),  Label::ContinueButton())),
  60.         `HSpacing(2),
  61.         /* PushButton label */
  62.         `HWeight(1, `PushButton(`id(`skip),  _("&Skip")))
  63.         )),
  64.         `VSpacing(0.2)
  65.     ))),
  66.     `HSpacing(1)
  67.     ));
  68.  
  69.     UI::SetFocus (`id(`continue));
  70.  
  71.     any ret = UI::UserInput();
  72.     UI::CloseDialog();
  73.  
  74.     if(ret != `continue) {
  75.     y2milestone("Detection skipped: %1", class);
  76.     return false;
  77.     }
  78.  
  79.     return true;
  80. }
  81.  
  82. /*
  83. y2milestone("--%1", Detection("graphics cards"));
  84. Linuxrc::manual () = true;
  85. y2milestone("--%1", Detection("network cards"));
  86. y2milestone("--%1", Detection("modems"));
  87. */
  88.  
  89. /**
  90.  * If we are running as root, return true.
  91.  * Otherwise ask the user whether we should continue even though things
  92.  * might not work
  93.  * @return true if running as root
  94.  */
  95. global define boolean MustBeRoot()
  96. {
  97.     map out = (map) SCR::Execute (.target.bash_output, "/usr/bin/id --user");
  98.     boolean root = out["stdout"]:"" == "0\n";
  99.     if(root) return true;
  100.  
  101.     /* Message in a continue/cancel popup */
  102.     string pop = _("This module must be run as root.
  103. If you continue now, the module may not function properly.
  104. For example, some settings can be read improperly
  105. and it is unlikely that settings can be written.\n");
  106.  
  107.     /* Popup headline */
  108.     if(Popup::ContinueCancelHeadline(_("Root Privileges Needed"), pop)) {
  109.     y2error("NOT running as root!");
  110.     return true;
  111.     }
  112.  
  113.     return false;
  114. }
  115.  
  116. /**
  117.  * Opens a popup yes/no confirmation.
  118.  
  119.  * If users confirms deleting, return true,
  120.  * else return false
  121.  *
  122.  * @return boolean delete selected entry
  123.  */
  124. global define boolean DeleteSelected() {
  125.     return Popup::YesNo(
  126.     /* Popup question */
  127.     _("Really delete selected entry?")
  128.     );
  129. }
  130.  
  131. /**
  132.  * Opens a popup yes/no confirmation.
  133.  
  134.  * If users confirms deleting of named entry/file/etc.,
  135.  * return true, else return false
  136.  *
  137.  * @param string file/entry name/etc.
  138.  * @return boolean delete selected entry
  139.  */
  140. global define boolean Delete(string delete) {
  141.     return Popup::YesNo(
  142.     /* Popup question, %1 is an item to delete (or filename, etc.) */
  143.     sformat(_("Really delete '%1'?"), delete)
  144.     );
  145. }
  146.  
  147. /* EOF */
  148. }
  149.