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



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
# 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 !Yast::Stage.initial && ["systemd-boot", "grub2-bls"].include?(old_bl)
    Yast::Popup.Warning(format(_(
    "Switching from %s to another bootloader\n" \
    "is currently not supported.\n"
  ), old_bl))
    return :redraw
  end

  if !Yast::Stage.initial && ["systemd-boot", "grub2-bls"].include?(new_bl)
    Yast::Popup.Warning(format(_(
    "Switching to bootloader %s \n" \
    "is currently not supported.\n"
  ), new_bl))
    return :redraw
  end

  BootloaderFactory.current_name = new_bl
  BootloaderFactory.current.propose

  :redraw
end

#helpObject



98
99
100
101
102
103
104
105
# File 'src/lib/bootloader/generic_widgets.rb', line 98

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

def localized_names(name)
  names = {
    "grub2"        => _("GRUB2"),
    "grub2-efi"    => _("GRUB2 for EFI"),
    # Translators: Using Boot Loader Specification (BLS) snippets.
    "grub2-bls"    => _("GRUB2 with BLS"),
    "systemd-boot" => _("Systemd Boot"),
    # Translators: option in combo box when bootloader is not managed by yast2
    "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