Class: Bootloader::ConsoleWidget

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

Overview

Represents graphical and serial console for bootloader

Instance Method Summary (collapse)

Methods included from Grub2Widget

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

Constructor Details

- (ConsoleWidget) initialize

Returns a new instance of ConsoleWidget



398
399
400
# File 'src/lib/bootloader/grub2_widgets.rb', line 398

def initialize
  textdomain "bootloader"
end

Instance Method Details

- (Object) contents



402
403
404
405
406
407
408
# File 'src/lib/bootloader/grub2_widgets.rb', line 402

def contents
  # TODO: simplify a bit content or split it
  VBox(
    graphical_console_frame,
    serial_console_frame
  )
end

- (Object) handle(event)



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'src/lib/bootloader/grub2_widgets.rb', line 450

def handle(event)
  return if event["ID"] != :browsegfx

  theme_dir = "/boot/grub2/themes/openSUSE"
  theme_dir = "/boot/grub2" unless ::Dir.exist?(theme_dir)

  file = Yast::UI.AskForExistingFile(
    theme_dir,
    "*.txt",
    _("Choose new graphical theme file")
  )

  Yast::UI.ChangeWidget(Id(:theme), :Value, file) if file

  nil
end

- (Object) init



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'src/lib/bootloader/grub2_widgets.rb', line 410

def init
  enable = grub_default.terminal == :serial
  Yast::UI.ChangeWidget(Id(:console_frame), :Value, enable)
  args = grub_default.serial_console || ""
  Yast::UI.ChangeWidget(Id(:console_args), :Value, args)

  enable = grub_default.terminal == :gfxterm
  Yast::UI.ChangeWidget(Id(:gfxterm_frame), :Value, enable)

  Yast::UI.ChangeWidget(Id(:gfxmode), :Items, vga_modes_items)
  mode = grub_default.gfxmode

  # there's mode specified, use it
  Yast::UI.ChangeWidget(Id(:gfxmode), :Value, mode) if mode && mode != ""

  Yast::UI.ChangeWidget(Id(:theme), :Value, grub_default.theme || "")
end

- (Object) store



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'src/lib/bootloader/grub2_widgets.rb', line 428

def store
  use_serial = Yast::UI.QueryWidget(Id(:console_frame), :Value)
  use_gfxterm = Yast::UI.QueryWidget(Id(:gfxterm_frame), :Value)

  use_gfxterm = false if use_gfxterm && use_serial

  if use_serial
    console_value = Yast::UI.QueryWidget(Id(:console_args), :Value)
    BootloaderFactory.current.enable_serial_console(console_value)
  elsif use_gfxterm
    grub_default.terminal = :gfxterm
  else
    grub_default.terminal = :console
  end

  mode = Yast::UI.QueryWidget(Id(:gfxmode), :Value)
  grub_default.gfxmode = mode if mode != ""

  theme = Yast::UI.QueryWidget(Id(:theme), :Value)
  grub_default.theme = theme if theme != ""
end