Class: Bootloader::LoaderTypeWidget

Inherits:
CWM::ComboBox
  • Object
show all
Defined in:
src/lib/bootloader/generic_widgets.rb

Overview

Widget to switch between all supported bootloaders

Instance Method Summary collapse

Constructor Details

#initializeLoaderTypeWidget

Returns a new instance of LoaderTypeWidget.



15
16
17
18
19
# File 'src/lib/bootloader/generic_widgets.rb', line 15

def initialize
  textdomain "bootloader"

  super
end

Instance Method Details

#handleObject

rubocop:disable Metrics/MethodLength It will be reduced again if systemd-boot is not anymore in beta phase.



56
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
# File 'src/lib/bootloader/generic_widgets.rb', line 56

def handle
  old_bl = BootloaderFactory.current.name
  new_bl = value

  return nil if old_bl == new_bl

  if new_bl == "none"
    # popup - Continue/Cancel
    popup_msg = _(
      "\n" \
      "If you do not install any boot loader, the system\n" \
      "might not start.\n" \
      "\n" \
      "Proceed?\n"
    )

    return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
  end

  if new_bl == "systemd-boot"
    # popup - Continue/Cancel
    popup_msg = _(
      "\n" \
      "Systemd-boot support is currently work in progress and\n" \
      "may not work as expected. Use at your own risk.\n" \
      "\n" \
      "Currently we do not provide official maintenance or support.\n" \
      "Proceed?\n"
    )

    return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
  end

  if !Yast::Stage.initial && (old_bl == "systemd-boot")
    Yast::Popup.Warning(_(
    "Switching from systemd-boot to another bootloader\n" \
    "is currently not supported.\n"
  ))
    return :redraw
  end

  BootloaderFactory.current_name = new_bl
  BootloaderFactory.current.propose

  :redraw
end

#helpObject

rubocop:enable Metrics/MethodLength



104
105
106
107
108
109
110
111
# File 'src/lib/bootloader/generic_widgets.rb', line 104

def help
  _(
    "<p><b>Boot Loader</b>\n" \
    "specifies which boot loader to install. Can be also set to <tt>None</tt> " \
    "which means that the boot loader configuration is not managed by YaST and also " \
    "the kernel post install script does not update the boot loader configuration."
  )
end

#initObject



27
28
29
# File 'src/lib/bootloader/generic_widgets.rb', line 27

def init
  self.value = BootloaderFactory.current.name
end

#itemsObject



35
36
37
38
39
# File 'src/lib/bootloader/generic_widgets.rb', line 35

def items
  BootloaderFactory.supported_names.map do |name|
    [name, localized_names(name)]
  end
end

#labelObject



21
22
23
24
25
# File 'src/lib/bootloader/generic_widgets.rb', line 21

def label
  textdomain "bootloader"

  _("&Boot Loader")
end

#localized_names(name) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'src/lib/bootloader/generic_widgets.rb', line 41

def localized_names(name)
  names = {
    "grub2"        => _("GRUB2"),
    "grub2-efi"    => _("GRUB2 for EFI"),
    # Translators: option in combo box when bootloader is not managed by yast2
    "systemd-boot" => _("Systemd Boot"),
    "none"         => _("Not Managed"),
    "default"      => _("Default")
  }

  names[name] or raise "Unknown supported bootloader '#{name}'"
end

#optObject



31
32
33
# File 'src/lib/bootloader/generic_widgets.rb', line 31

def opt
  [:notify]
end