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



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'src/lib/bootloader/grub2_widgets.rb', line 578

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)



595
596
597
598
599
600
601
602
# File 'src/lib/bootloader/grub2_widgets.rb', line 595

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



604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'src/lib/bootloader/grub2_widgets.rb', line 604

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



619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'src/lib/bootloader/grub2_widgets.rb', line 619

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



634
635
636
637
638
639
640
641
642
643
644
645
# File 'src/lib/bootloader/grub2_widgets.rb', line 634

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