Skip to content

Commit

Permalink
initial work on object dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 6, 2016
1 parent a000adc commit fdca480
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 121 deletions.
19 changes: 0 additions & 19 deletions src/include/bootloader/routines/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@ def testAbort
UI.PollInput == :abort
end

# Read settings dialog
# @return `abort if aborted and `next otherwise
def ReadDialog
Bootloader.test_abort = fun_ref(method(:testAbort), "boolean ()")
Wizard.RestoreHelp(getInitProgressHelp)
ret = Bootloader.Read
ret ? :next : :abort
end

# Write settings dialog
# @return `abort if aborted and `next otherwise
def WriteDialog
if !Stage.initial
Bootloader.test_abort = fun_ref(method(:testAbort), "boolean ()")
end
Wizard.RestoreHelp(getSaveProgressHelp)
ret = Bootloader.Write
ret ? :next : :abort
end

# Run dialog for kernel section editation
# @return [Symbol] for wizard sequencer
Expand Down
18 changes: 0 additions & 18 deletions src/include/bootloader/routines/helps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@ def initialize_bootloader_routines_helps(_include_target)

# wizard sequecer widgets helps

# Get help
# @return [String] help text
def getInitProgressHelp
# help text 1/1 (shown during settings reading progress)
_(
"<P><BIG><B>Boot Loader Configuration Tool</B></BIG><BR>\nChange the settings of your boot loader.</P>"
)
end

# Get help
# @return [String] help text
def getSaveProgressHelp
# help text
_(
"<P><B><BIG>Saving Boot Loader Configuration</BIG></B><BR>\nPlease wait...<br></p>"
)
end

# Get help
# @return [String] help text
def getAdvancedButtonHelp
Expand Down
8 changes: 8 additions & 0 deletions src/lib/bootloader/bootloader_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def system
bootloader_by_name(Sysconfig.from_system.bootloader)
end

def current
@current ||= system
end

def current=(name)
@current = bootloader_by_name(name)
end

def supported_names
if Yast::Mode.config
# default means bootloader use what it think is the best
Expand Down
Original file line number Diff line number Diff line change
@@ -1,98 +1,47 @@
# encoding: utf-8
require "yast"

# File:
# include/bootloader/routines/wizards.ycp
#
# Module:
# Bootloader installation and configuration
#
# Summary:
# Wizard sequences for bootloader installation/configuration
#
# Authors:
# Jiri Srain <jsrain@suse.cz>
#
# $Id$
#
module Yast
module BootloaderRoutinesWizardsInclude
def initialize_bootloader_routines_wizards(include_target)
Yast.import "UI"
textdomain "bootloader"
require "bootloader/read_dialog"

Yast.import "Sequencer"
Yast.import "Wizard"
Yast.import "Report"
Yast.import "Popup"
Yast.include include_target, "bootloader/routines/dialogs.rb"
end

# Run wizard sequencer
# @return `next, `back or `abort
def MainSequence
if !BootCommon.BootloaderInstallable
# error report
Report.Error(
_(
"Because of the partitioning, the boot loader cannot be installed properly."
)
)
end

# run generic sequence
aliases = {
"main" => lambda { MainDialog() },
"installation_details" => lambda { DetailsDialog("installation") },
"loader_details" => lambda { DetailsDialog("loader") }
}

@return_tab = Bootloader.getLoaderType != "none" ? "sections" : "installation"

sequence = {
"ws_start" => "main",
"main" => {
:next => :next,
:abort => :abort,
:inst_details => "installation_details",
:loader_details => "loader_details",
:redraw => "main"
},
"installation_details" => { :next => "main", :abort => :abort },
"loader_details" => { :next => "main", :abort => :abort }
}
Yast.import "BootCommon"
Yast.import "Label"
Yast.import "Report"
Yast.import "Sequencer"
Yast.import "Stage"
Yast.import "UI"
Yast.import "Wizard"

Sequencer.Run(aliases, sequence)
end

module Bootloader
class MainDialog
# Whole configuration of printer but without reading and writing.
# For use with autoinstallation.
# @return sequence result
def BootloaderAutoSequence
Wizard.CreateDialog
Wizard.SetContentsButtons(
def run_auto
Yast::Wizard.CreateDialog
Yast::Wizard.SetContentsButtons(
"",
VBox(),
"",
Label.BackButton,
Label.NextButton
Yast::Label.BackButton,
Yast::Label.NextButton
)
if Stage.initial
Wizard.SetTitleIcon("bootloader") # no .desktop file in inst-sys
if Yast::Stage.initial
Yast::Wizard.SetTitleIcon("bootloader") # no .desktop file in inst-sys
else
Wizard.SetDesktopTitleAndIcon("bootloader")
Yast::Wizard.SetDesktopTitleAndIcon("bootloader")
end

ret = MainSequence()
UI.CloseDialog
ret = run_content
Yast::UI.CloseDialog
ret
end

# Whole configuration of dns-server
# @return sequence result
def BootloaderSequence
def run
my_aliases = {
"read" => [lambda { ReadDialog() }, true],
"main" => lambda { MainSequence() },
"read" => [lambda { ReadDialog.new.run }, true],
"main" => method(:run_content),
"write" => [lambda { WriteDialog() }, true]
}

Expand All @@ -103,19 +52,56 @@ def BootloaderSequence
"write" => { :abort => :abort, :next => :next }
}

Wizard.CreateDialog
Wizard.SetDesktopTitleAndIcon("bootloader")
Wizard.SetContentsButtons(
Yast::Wizard.CreateDialog
Yast::Wizard.SetDesktopTitleAndIcon("bootloader")
Yast::Wizard.SetContentsButtons(
"",
VBox(),
"",
Label.BackButton,
Label.NextButton
Yast::Label.BackButton,
Yast::Label.NextButton
)
ret = Sequencer.Run(my_aliases, sequence)
ret = Yast::Sequencer.Run(my_aliases, sequence)

Wizard.CloseDialog
Yast::Wizard.CloseDialog
ret
end

private

# Run wizard sequencer
# @return `next, `back or `abort
def run_content
if !Yast::BootCommon.BootloaderInstallable
# error report
Yast::Report.Error(
_(
"Because of the partitioning, the boot loader cannot be installed properly."
)
)
end

# run generic sequence
aliases = {
"main" => lambda { MainDialog() },
"installation_details" => lambda { DetailsDialog("installation") },
"loader_details" => lambda { DetailsDialog("loader") }
}

sequence = {
"ws_start" => "main",
"main" => {
:next => :next,
:abort => :abort,
:inst_details => "installation_details",
:loader_details => "loader_details",
:redraw => "main"
},
"installation_details" => { :next => "main", :abort => :abort },
"loader_details" => { :next => "main", :abort => :abort }
}

Yast::Sequencer.Run(aliases, sequence)
end
end
end
27 changes: 27 additions & 0 deletions src/lib/bootloader/read_dialog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "yast"

Yast.import "Bootloader"
Yast.import "Wizard"

module Bootloader
class ReadDialog
include Yast::I18n

def run
Yast::Wizard.RestoreHelp(help_text)
ret = Yast::Bootloader.Read
ret ? :next : :abort
end

private

def help_text
textdomain "bootloader"

_(
"<P><BIG><B>Boot Loader Configuration Tool</B></BIG><BR>\n" \
"Reading current configuration...</P>"
)
end
end
end
28 changes: 28 additions & 0 deletions src/lib/bootloader/write_dialog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "yast"

Yast.import "Bootloader"
Yast.import "Wizard"

module Bootloader
class WriteDialog
include Yast::I18n

# Write settings dialog
# @return `:abort` if aborted and `:next` otherwise
def run
Yast::Wizard.RestoreHelp(help_text)
ret = Yast::Bootloader.Write
ret ? :next : :abort
end

private

def help_text
textdomain "bootloader"

_(
"<P><B><BIG>Saving Boot Loader Configuration</BIG></B><BR>\nPlease wait...<br></p>"
)
end
end
end
5 changes: 3 additions & 2 deletions src/modules/Bootloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ def main
# Check whether abort was pressed
# @return [Boolean] true if abort was pressed
def testAbort
return false if @test_abort.nil?
@test_abort.call
return false if Mode.commandline

UI.PollInput == :abort
end

# bnc #419197 yast2-bootloader does not correctly initialise libstorage
Expand Down

0 comments on commit fdca480

Please sign in to comment.