Class: Yast::ConfirmClass
- Inherits:
-
Module
- Object
- Module
- Yast::ConfirmClass
- Defined in:
- library/wizard/src/modules/Confirm.rb
Instance Method Summary collapse
-
#Delete(delete) ⇒ Object
- Opens a popup yes/no confirmation.
-
#DeleteSelected ⇒ Object
- Opens a popup yes/no confirmation.
-
#Detection(class_, icon_name) ⇒ Object
Confirm hardware detection (only in manual installation).
- #main ⇒ Object
-
#MustBeRoot ⇒ Object
If we are running as root, return true.
Instance Method Details
#Delete(delete) ⇒ Object
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
212 213 214 215 216 217 |
# File 'library/wizard/src/modules/Confirm.rb', line 212 def Delete(delete) Popup.YesNo( # Popup question, %1 is an item to delete (or filename, etc.) Builtins.sformat(_("Really delete '%1'?"), delete) ) end |
#DeleteSelected ⇒ Object
Opens a popup yes/no confirmation.
- If users confirms deleting, return true,
- else return false *
- @return boolean delete selected entry
198 199 200 201 202 203 |
# File 'library/wizard/src/modules/Confirm.rb', line 198 def DeleteSelected Popup.YesNo( # Popup question _("Really delete selected entry?") ) end |
#Detection(class_, icon_name) ⇒ Object
Confirm hardware detection (only in manual installation)
57 58 59 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 |
# File 'library/wizard/src/modules/Confirm.rb', line 57 def Detection(class_, icon_name) Builtins.y2warning(-1, "Parameter 'icon_name' is deprecated.") if !icon_name.nil? 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 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(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 |
#main ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'library/wizard/src/modules/Confirm.rb', line 37 def main Yast.import "UI" textdomain "base" Yast.import "Label" Yast.import "Mode" Yast.import "Popup" Yast.import "Linuxrc" Yast.import "Stage" Yast.import "Arch" # #TODO bug number @detection_cache = {} end |
#MustBeRoot ⇒ Object
If we are running as root, return true. Otherwise ask the user whether we should continue even though things might not work
160 161 162 163 164 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 |
# File 'library/wizard/src/modules/Confirm.rb', line 160 def MustBeRoot if Ops.less_or_equal( Convert.to_integer(SCR.Read(path(".target.size"), "/usr/bin/id")), 0 ) Builtins.y2warning("/usr/bin/id not existing, supposing to be root") if !Stage.initial 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 |