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.



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

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.



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

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



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

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



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

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

#itemsObject



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

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

#labelObject



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

def label
  textdomain "bootloader"

  _("&Boot Loader")
end

#localized_names(name) ⇒ Object



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

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



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

def opt
  [:notify]
end