Class: Bootloader::Grub2Widget::LoaderLocationWidget

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

Overview

Represents stage1 location for bootloader

Instance Method Summary collapse

Methods included from Grub2Helper

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

Instance Method Details

#contentsObject



854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
# File 'src/lib/bootloader/grub2_widgets.rb', line 854

def contents
  textdomain "bootloader"

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

#handle(event) ⇒ Object



870
871
872
873
874
875
876
877
# File 'src/lib/bootloader/grub2_widgets.rb', line 870

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

#initObject



879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
# File 'src/lib/bootloader/grub2_widgets.rb', line 879

def init
  if locations.include?(:boot)
    Yast::UI.ChangeWidget(Id(:boot), :Value,
      stage1.boot_partition?)
  end
  if locations.include?(:logical)
    Yast::UI.ChangeWidget(Id(:logical), :Value, stage1.boot_partition?)
  end
  if locations.include?(:extended)
    Yast::UI.ChangeWidget(Id(:extended), :Value, stage1.extended_boot_partition?)
  end
  Yast::UI.ChangeWidget(Id(:mbr), :Value, stage1.mbr?) if locations.include?(:mbr)

  init_custom_devices(stage1.custom_devices)
end

#storeObject



895
896
897
898
899
900
901
902
903
904
905
# File 'src/lib/bootloader/grub2_widgets.rb', line 895

def store
  stage1.clear_devices
  locations.each { |l| add_location(l) }

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

  devs = Yast::UI.QueryWidget(:custom_list, :Value)
  devs.split(",").each do |dev|
    stage1.add_device(DevicePath.new(dev).path)
  end
end

#validateObject



907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'src/lib/bootloader/grub2_widgets.rb', line 907

def validate
  return true if !Yast::UI.QueryWidget(:custom, :Value)

  devs = Yast::UI.QueryWidget(:custom_list, :Value)

  if devs.strip.empty?
    Yast::Report.Error(_("Custom boot device has to be specified if checked"))
    Yast::UI.SetFocus(Id(:custom_list))
    return false
  end

  invalid_devs = invalid_custom_devices(devs)
  if !invalid_devs.empty?
    ret = Yast::Popup.ContinueCancel(
      format(
        _(
          "These custom devices can be invalid: %s." \
          "Please check if exist and spelled correctly." \
          "Do you want to continue?"
        ),
        invalid_devs.join(", ")
      )
    )

    if !ret
      Yast::UI.SetFocus(Id(:custom_list))
      return false
    end
  end

  true
end