Class: Yast::ConfirmClass
- Inherits:
-
Module
- Object
- Module
- Yast::ConfirmClass
- Defined in:
- ../../src/modules/Confirm.rb
Instance Method Summary (collapse)
-
- (Object) Delete(delete)
-
Opens a popup yes/no confirmation.
-
-
- (Object) DeleteSelected
-
Opens a popup yes/no confirmation.
-
-
- (Object) Detection(class_, icon_name)
Confirm hardware detection (only in manual installation).
- - (Object) main
-
- (Object) MustBeRoot
If we are running as root, return true.
Instance Method Details
- (Object) Delete(delete)
-
Opens a popup yes/no confirmation.
-
If users confirms deleting of named entry/file/etc.,
-
return true, else return false *
-
@param string file/entry name/etc.
-
@return boolean delete selected entry
219 220 221 222 223 224 |
# File '../../src/modules/Confirm.rb', line 219 def Delete(delete) Popup.YesNo( # Popup question, %1 is an item to delete (or filename, etc.) Builtins.sformat(_("Really delete '%1'?"), delete) ) end |
- (Object) DeleteSelected
-
Opens a popup yes/no confirmation.
-
If users confirms deleting, return true,
-
else return false *
-
@return boolean delete selected entry
205 206 207 208 209 210 |
# File '../../src/modules/Confirm.rb', line 205 def DeleteSelected Popup.YesNo( # Popup question _("Really delete selected entry?") ) end |
- (Object) Detection(class_, icon_name)
Confirm hardware detection (only in manual installation)
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File '../../src/modules/Confirm.rb', line 60 def Detection(class_, icon_name) return true if Linuxrc.manual != true # L3: no interaction in AY, just re-probe (bnc#568653) return true if Mode.autoinst == true || Mode.autoupgrade == true return true if Arch.s390 icon_name = "yast-hardware" if icon_name.nil? icon = Icon.Image(icon_name, {}) result = Ops.get(@detection_cache, class_) if !result.nil? Builtins.y2milestone( "Detection cached result: %1 -> %2", class_, result ) return result end UI.OpenDialog( Opt(:decorated), HBox( HSpacing(1), HCenter( HSquash( VBox( HCenter( HSquash( VBox( # Popup-Box for manual hardware detection. # If the user selects 'manual installation' when # booting from CD, YaST2 does not load any modules # automatically, but asks the user for confirmation # about every module. # The popup box informs the user about the detected # hardware and suggests a module to load. # The user can confirm the module or change # the suggested load command # # This is the heading of the popup box Left(Heading(_("Confirm Hardware Detection"))), VSpacing(0.5), # This is in information message. Next come the # hardware class name (network cards). HVCenter( Label(_("YaST will detect the following hardware:")) ), HVCenter(HBox(icon, HSpacing(0.5), Heading(class_))), VSpacing(0.5) ) ) ), ButtonBox( HWeight( 1, PushButton( Id(:continue), Opt(:default, :okButton), Label.ContinueButton ) ), # PushButton label HWeight( 1, PushButton(Id(:skip), Opt(:cancelButton), _("&Skip")) ) ), VSpacing(0.2) ) ) ), HSpacing(1) ) ) UI.SetFocus(Id(:continue)) # for autoinstallation popup has timeout 10 seconds (#192181) # timeout for every case (bnc#429562) ret = UI.TimeoutUserInput(10 * 1000) # any ret = Mode::autoinst() ? UI::TimeoutUserInput(10*1000) : UI::UserInput(); UI.CloseDialog result = true if ret != :continue Builtins.y2milestone("Detection skipped: %1", class_) result = false end Ops.set(@detection_cache, class_, result) result end |
- (Object) main
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File '../../src/modules/Confirm.rb', line 39 def main Yast.import "UI" textdomain "base" Yast.import "Icon" Yast.import "Label" Yast.import "Mode" Yast.import "Popup" Yast.import "Linuxrc" Yast.import "Stage" Yast.import "Arch" # #TODO bug number @detection_cache = {} end |
- (Object) MustBeRoot
If we are running as root, return true. Otherwise ask the user whether we should continue even though things might not work
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File '../../src/modules/Confirm.rb', line 165 def MustBeRoot if Ops.less_or_equal( Convert.to_integer(SCR.Read(path(".target.size"), "/usr/bin/id")), 0 ) if !Stage.initial Builtins.y2warning("/usr/bin/id not existing, supposing to be root") end return true end out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "/usr/bin/id --user") ) root = Ops.get_string(out, "stdout", "") == "0\n" return true if root # Message in a continue/cancel popup pop = _( "This module must be run as root.\n" \ "If you continue now, the module may not function properly.\n" \ "For example, some settings can be read improperly\n" \ "and it is unlikely that settings can be written.\n" ) # Popup headline if Popup.ContinueCancelHeadline(_("Root Privileges Needed"), pop) Builtins.y2error("NOT running as root!") return true end false end |