Class: Bootloader::LoaderLocationWidget

Inherits:
CWM::CustomWidget
  • Object
show all
Includes:
Grub2Widget
Defined in:
src/lib/bootloader/grub2_widgets.rb

Overview

Represents stage1 location for bootloader

Instance Method Summary (collapse)

Methods included from Grub2Widget

#grub2, #grub_default, #password, #sections, #stage1

Instance Method Details

- (Object) contents



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'src/lib/bootloader/grub2_widgets.rb', line 639

def contents
  textdomain "bootloader"

  VBox(
    VSpacing(1),
    Frame(
      _("Boot Loader Location"),
      HBox(
        HSpacing(1),
        VBox(*location_checkboxes),
        HSpacing(1)
      )
    ),
    VSpacing(1)
  )
end

- (Object) handle(event)



656
657
658
659
660
661
662
663
# File 'src/lib/bootloader/grub2_widgets.rb', line 656

def handle(event)
  return unless event["ID"] == :custom

  checked = Yast::UI.QueryWidget(Id(:custom), :Value)
  Yast::UI.ChangeWidget(Id(:custom_list), :Enabled, checked)

  nil
end

- (Object) init



665
666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'src/lib/bootloader/grub2_widgets.rb', line 665

def init
  if locations[:boot]
    Yast::UI.ChangeWidget(Id(:boot), :Value, stage1.boot_partition?)
  end
  if locations[:root]
    Yast::UI.ChangeWidget(Id(:root), :Value, stage1.root_partition?)
  end
  if locations[:extended]
    Yast::UI.ChangeWidget(Id(:extended), :Value, stage1.extended_partition?)
  end
  Yast::UI.ChangeWidget(Id(:mbr), :Value, stage1.mbr?) if locations[:mbr]

  init_custom_devices(stage1.custom_devices)
end

- (Object) store



680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'src/lib/bootloader/grub2_widgets.rb', line 680

def store
  locations = stage1.available_locations
  stage1.clear_devices
  locations.each_pair do |id, dev|
    stage1.add_udev_device(dev) if Yast::UI.QueryWidget(Id(id), :Value)
  end

  return unless Yast::UI.QueryWidget(:custom, :Value)

  devs = Yast::UI.QueryWidget(:custom_list, :Value)
  devs.split(",").each do |dev|
    stage1.add_udev_device(dev.strip)
  end
end

- (Object) validate



695
696
697
698
699
700
701
702
703
704
705
706
# File 'src/lib/bootloader/grub2_widgets.rb', line 695

def validate
  if Yast::UI.QueryWidget(:custom, :Value)
    devs = Yast::UI.QueryWidget(:custom_list, :Value)
    if devs.strip.empty?
      Yast::Report.Error(_("Custom boot device have to be specied if checked"))
      Yast::UI.SetFocus(Id(:custom_list))
      return false
    end
  end

  true
end