Module: Yast::BootloaderGrubOptionsInclude

Defined in:
src/include/bootloader/grub/options.rb

Instance Method Summary (collapse)

Instance Method Details

- (Yast::Term) grubBootLoaderLocationWidget

Create Frame “Boot Loader Location”

Returns:

  • (Yast::Term)

    with widgets



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'src/include/bootloader/grub/options.rb', line 219

def grubBootLoaderLocationWidget
  partition_boot = if BootStorage.can_boot_from_partition
                     if BootStorage.BootPartitionDevice == BootStorage.RootPartitionDevice
                       Left(CheckBox(Id("boot_root"), _("Boot from &Root Partition")))
                     else
                       Left(CheckBox(Id("boot_boot"), _("Boo&t from Boot Partition")))
                     end
                   else
                     Empty()
                   end

  boot_custom = [
    Left(
      CheckBox(
        Id("boot_custom"),
        Opt(:notify),
        _("C&ustom Boot Partition")
      )
    ),
    Left(
      ComboBox(
        Id("boot_custom_list"),
        Opt(:editable, :hstretch),
        "",
        []
      )
    )]

  contents = VBox(
    VSpacing(1),
    Frame(
      _("Boot Loader Location"),
      VBox(
        HBox(
          HSpacing(1),
          VBox(
            Left(
              CheckBox(Id("boot_mbr"), _("Boot from &Master Boot Record"))
            ),
            partition_boot,
            if BootStorage.ExtendedPartitionDevice
              Left(
                CheckBox(
                  Id("boot_extended"),
                  _("Boot from &Extended Partition")
                )
              )
            else
              Empty()
            end,
            *boot_custom
          )
        )
      )
    ),
    VSpacing(1)
  )

  if !BootCommon.PartitionInstallable
    contents = VBox(
      Frame(
        _("Boot Loader Location"),
        VBox(
          HBox(
            HSpacing(1),
            VBox(
              Left(
                CheckBox(Id("boot_mbr"), _("Boot from &Master Boot Record"))
              ),
              *boot_custom,
              VStretch()
            )
          )
        )
      ),
      VStretch()
    )
  end

  if BootCommon.VerifyMDArray
    contents = VBox(
      Frame(
        _("Boot Loader Location"),
        VBox(
          HBox(
            HSpacing(1),
            VBox(
              Left(
                CheckBox(Id("boot_mbr"), _("Boot from &Master Boot Record"))
              ),
              Left(
                CheckBox(
                  Id("enable_redundancy"),
                  _("Enable Red&undancy for MD Array")
                )
              ),
              *boot_custom,
              VStretch()
            )
          )
        )
      ),
      VStretch()
    )
  end
  {
    "widget"        => :custom,
    "custom_widget" => contents,
    "init"          => fun_ref(
      method(:InitBootLoaderLocationWidget),
      "void (string)"
    ),
    "handle"        => fun_ref(
      method(:HandleBootLoaderLocationWidget),
      "symbol (string, map)"
    ),
    "store"         => fun_ref(
      method(:StoreBootLoaderLocationWidget),
      "void (string, map)"
    ),
    "help"          => HelpBootLoaderLocationWidget()
  }
end

- (Symbol) HandleBootLoaderLocationWidget(_widget, event)

handle function of a widget

Parameters:

  • widget (String)

    string widget key

  • event (Hash)

    map event that caused the operation

Returns:

  • (Symbol)


142
143
144
145
146
147
148
149
150
151
152
153
# File 'src/include/bootloader/grub/options.rb', line 142

def HandleBootLoaderLocationWidget(_widget, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  if ret == "boot_custom"
    if Convert.to_boolean(UI.QueryWidget(Id("boot_custom"), :Value))
      UI.ChangeWidget(Id("boot_custom_list"), :Enabled, true)
    else
      UI.ChangeWidget(Id("boot_custom_list"), :Enabled, false)
    end
  end
  nil
end

- (Symbol) HandlePasswdWidget(_widget, event)

Handle function of a widget

Parameters:

  • widget (String)

    string id of the widget

  • event (Hash)

    map event description of event that occured

Returns:

  • (Symbol)

    always nil



39
40
41
42
43
44
45
46
47
48
# File 'src/include/bootloader/grub/options.rb', line 39

def HandlePasswdWidget(_widget, event)
  event = deep_copy(event)
  if Ops.get(event, "ID") == :use_pas
    enabled = Convert.to_boolean(UI.QueryWidget(Id(:use_pas), :Value))
    UI.ChangeWidget(Id(:unrestricted_pw), :Enabled, enabled)
    UI.ChangeWidget(Id(:pw1), :Enabled, enabled)
    UI.ChangeWidget(Id(:pw2), :Enabled, enabled)
  end
  nil
end

- (String) HelpBootLoaderLocationWidget

FIXME: merge help text to one for BootLoaderLocationWidget Function merge help text from ../grub/helps.ycp

Returns:

  • (String)

    help text for widget BootLoaderLocationWidget



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'src/include/bootloader/grub/options.rb', line 195

def HelpBootLoaderLocationWidget
  ret = Ops.get(@grub_help_messages, "boot_mbr", "")
  ret = Ops.add(ret, "\n")
  ret = Ops.add(ret, Ops.get(@grub_help_messages, "boot_custom", ""))
  ret = Ops.add(ret, "\n")
  if BootCommon.VerifyMDArray
    ret = Ops.add(
      ret,
      Ops.get(@grub_help_messages, "enable_redundancy", "")
    )
  else
    ret = Ops.add(ret, Ops.get(@grub_help_messages, "boot_root", ""))
    ret = Ops.add(ret, "\n")
    ret = Ops.add(ret, Ops.get(@grub_help_messages, "boot_boot", ""))
    ret = Ops.add(ret, "\n")
    ret = Ops.add(ret, Ops.get(@grub_help_messages, "boot_extended", ""))
  end
  ret
end

- (Object) InitBootLoaderLocationWidget(_widget)

Init function of a widget

Parameters:

  • widget (String)

    string widget key



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
# File 'src/include/bootloader/grub/options.rb', line 98

def InitBootLoaderLocationWidget(_widget)
  boot_devices = BootStorage.possible_locations_for_stage1
  if BootCommon.VerifyMDArray
    UI.ChangeWidget(Id("enable_redundancy"), :Value,
      BootCommon.enable_md_array_redundancy
    )

    value = BootCommon.globals["boot_mbr"] == "true"
    UI.ChangeWidget(Id("boot_mbr"), :Value, value)
  else
    list_global_target_keys = [
      "boot_mbr",
      "boot_boot",
      "boot_root",
      "boot_extended"
    ]
    list_global_target_keys.each do |key|
      value = BootCommon.globals[key]
      if value && UI.WidgetExists(Id(key))
        UI.ChangeWidget(Id(key), :Value, value == "true" ? true : false)
      end
    end
    UI.ChangeWidget(Id("boot_custom_list"), :Items, boot_devices)
  end

  if !Builtins.haskey(BootCommon.globals, "boot_custom") ||
      Ops.get(BootCommon.globals, "boot_custom", "") == ""
    UI.ChangeWidget(Id("boot_custom_list"), :Enabled, false)
  else
    UI.ChangeWidget(Id("boot_custom"), :Value, true)
    UI.ChangeWidget(Id("boot_custom_list"), :Enabled, true)
    UI.ChangeWidget(
      Id("boot_custom_list"),
      :Value,
      Ops.get(BootCommon.globals, "boot_custom", "")
    )
  end

  nil
end

- (Object) initialize_bootloader_grub_options(include_target)



23
24
25
26
27
28
29
30
31
32
33
# File 'src/include/bootloader/grub/options.rb', line 23

def initialize_bootloader_grub_options(include_target)
  textdomain "bootloader"

  Yast.import "Label"
  Yast.import "BootStorage"

  Yast.include include_target, "bootloader/routines/common_options.rb"
  Yast.include include_target, "bootloader/routines/popups.rb"
  Yast.include include_target, "bootloader/routines/helps.rb"
  Yast.include include_target, "bootloader/grub/helps.rb"
end

- (Object) passwd_content



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
# File 'src/include/bootloader/grub/options.rb', line 69

def passwd_content
  HBox(
    CheckBoxFrame(
      Id(:use_pas),
      _("Prot&ect Boot Loader with Password"),
      true,
      VBox(
        HBox(
          HSpacing(2),
          # TRANSLATORS: checkbox entry
          CheckBox(Id(:unrestricted_pw), _("P&rotect Entry Modification Only")),
          HStretch()
        ),
        HBox(
          HSpacing(2),
          # text entry
          Password(Id(:pw1), Opt(:hstretch), _("&Password")),
          # text entry
          HSpacing(2),
          Password(Id(:pw2), Opt(:hstretch), _("Re&type Password")),
          HStretch()
        )
      )
    )
  )
end

- (Object) StoreBootLoaderLocationWidget(_widget, _event)

Store function of a widget

Parameters:

  • widget (String)

    string widget key

  • event (Hash)

    map event that caused the operation



158
159
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
# File 'src/include/bootloader/grub/options.rb', line 158

def StoreBootLoaderLocationWidget(_widget, _event)
  if BootCommon.VerifyMDArray
    BootCommon.enable_md_array_redundancy = Convert.to_boolean(
      UI.QueryWidget(Id("enable_redundancy"), :Value)
    )
    Ops.set(
      BootCommon.globals,
      "boot_mbr",
      Convert.to_boolean(UI.QueryWidget(Id("boot_mbr"), :Value)) ? "true" : "false"
    )
  else
    list_global_target_keys = [
      "boot_mbr",
      "boot_boot",
      "boot_root",
      "boot_extended"
    ]
    Builtins.foreach(list_global_target_keys) do |key|
      value = UI.WidgetExists(Id(key)) && UI.QueryWidget(Id(key), :Value)
      BootCommon.globals[key] = value.to_s
    end
  end
  if UI.QueryWidget(Id("boot_custom"), :Value)
    custom_value = UI.QueryWidget(Id("boot_custom_list"), :Value)
  else
    # bnc#544809 Custom Boot Partition cannot be deleted
    custom_value = ""
  end
  BootCommon.globals["boot_custom"] = custom_value

  nil
end

- (Boolean) ValidatePasswdWidget(_key, _event)

Validate function of a popup

Parameters:

  • key (String)

    any widget key

  • event (Hash)

    map event that caused validation

Returns:

  • (Boolean)

    true if widget settings ok



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'src/include/bootloader/grub/options.rb', line 54

def ValidatePasswdWidget(_key, _event)
  return true if !Convert.to_boolean(UI.QueryWidget(Id(:use_pas), :Value))
  if UI.QueryWidget(Id(:pw1), :Value) == ""
    emptyPasswdErrorPopup
    UI.SetFocus(Id(:pw1))
    return false
  end
  if UI.QueryWidget(Id(:pw1), :Value) == UI.QueryWidget(Id(:pw2), :Value)
    return true
  end
  passwdMissmatchPopup
  UI.SetFocus(Id(:pw1))
  false
end