Skip to content

Commit

Permalink
Merge pull request #131 from yast/export_config
Browse files Browse the repository at this point in the history
Export config
  • Loading branch information
jreidinger committed Jan 21, 2014
2 parents 72448f2 + 1022df5 commit 70b92d4
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 81 deletions.
10 changes: 10 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Jan 21 12:15:21 UTC 2014 - jreidinger@suse.com

- Remove "Change..." button in non-textual installation
- Add "Export Configuration" button in non-textual installation
(FATE#308539)
- Add "Export Configuration" menu item in textual installation
(FATE#308539)
- 3.1.21

-------------------------------------------------------------------
Tue Jan 21 08:48:17 UTC 2014 - jsrain@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.20
Version: 3.1.21
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
170 changes: 90 additions & 80 deletions src/clients/inst_proposal.rb
Expand Up @@ -50,6 +50,7 @@ def main
Yast.import "Popup"
Yast.import "Language"
Yast.import "GetInstArgs"
Yast.import "String"

Yast.include self, "installation/misc.rb"

Expand Down Expand Up @@ -175,9 +176,8 @@ def main
get_submod_descriptions_and_build_menu
end

# check for hyperlink id

if Ops.is_string?(@input)
case @input
when ::String #hyperlink
# get module for hyperlink id
@submod = Ops.get_string(@id2submod, @input, "")

Expand All @@ -200,25 +200,33 @@ def main
# so we have to do this special case here. Kind of broken.
return :finish if @input == :finish
end
elsif @input == "rel_notes"
WFM.CallFunction("release_notes_popup", [])
elsif @input == :finish
when :finish
return :finish
elsif @input == :abort
when :abort
if Stage.initial
return :abort if Popup.ConfirmAbort(:painless)
else
return :abort if Popup.ConfirmAbort(:incomplete)
end
elsif @input == :reset_to_defaults &&
Popup.ContinueCancel(
when :reset_to_defaults
next unless Popup.ContinueCancel(
# question in a popup box
_("Really reset everything to default values?") + "\n" +
# explain consequences of a decision
_("You will lose all changes.")
)
make_proposal(true, false) # force_reset
elsif @input == :skip || @input == :dontskip
when :export_config
path = UI.AskForSaveFileName("/", "*.xml", _("Location of Stored Configuration"))
next unless path

WFM.CallFunction("clone_proposal", ["Write"])
if !File.exists?("/root/autoinst.xml")
raise _("Failed to store configuration. Details can be found in log.")
end

WFM.Execute(path(".local.bash"), "mv -- /root/autoinst.xml '#{String.Quote(path)}'")
when :skip, :dontskip
if Convert.to_boolean(UI.QueryWidget(Id(:skip), :Value))
# User doesn't want to use any of the settings
UI.ChangeWidget(
Expand All @@ -236,7 +244,7 @@ def main
make_proposal(false, false)
UI.ChangeWidget(Id(:menu), :Enabled, true)
end
elsif @input == :next
when :next
@skip = UI.WidgetExists(Id(:skip)) ?
Convert.to_boolean(UI.QueryWidget(Id(:skip), :Value)) :
true
Expand Down Expand Up @@ -270,18 +278,13 @@ def main
Wizard.HideReleaseNotesButton
return :next
end
elsif @input == :back
when :back
Wizard.HideReleaseNotesButton
Wizard.SetNextButton(:next, Label.NextButton) if Stage.initial
return :back
end
end # while input loop


# NOTREACHED

# EOF

nil
end

Expand Down Expand Up @@ -984,15 +987,25 @@ def build_dialog
)
)

if UI.TextMode()
change_point = ReplacePoint(
Id(:rep_menu),
# menu button
MenuButton(Id(:menu_dummy), _("&Change..."), [Item(Id(:dummy), "")])
)
else
change_point = PushButton(
Id(:export_config),
# menu button
_("&Export Configuration")
)
end

# change menu
menu_box = VBox(
HBox(
HStretch(),
ReplacePoint(
Id(:rep_menu),
# menu button
MenuButton(Id(:menu_dummy), _("&Change..."), [Item(Id(:dummy), "")])
),
change_point,
HStretch()
),
ReplacePoint(Id("inst_proposal_progress"), Empty())
Expand Down Expand Up @@ -1054,9 +1067,15 @@ def build_dialog
# May contain newlines, but don't make it very much longer than the original.
Left(
Label(
_(
"Click a headline to make changes or use the \"Change...\" menu below."
)
if UI.TextMode()
_(
"Click a headline to make changes or use the \"Change...\" menu below."
)
else
_(
"Click a headline to make changes."
)
end
)
),
rt,
Expand Down Expand Up @@ -1084,94 +1103,85 @@ def build_dialog

nil
end

def get_submod_descriptions_and_build_menu
menu_list = []
new_submodules = []
no = 1
@titles = []
descriptions = {}

Builtins.foreach(@submodules) do |submod|
@submodules.each do |submod|
description = submod_description(submod)
if description == nil
if description.nil?
Builtins.y2milestone(
"Submodule %1 not available (not installed?)",
submod
)
else
if description != {}
Ops.set(description, "no", no)
Ops.set(descriptions, submod, description)
new_submodules = Builtins.add(new_submodules, submod)
title = Ops.get_string(
description,
"rich_text_title",
Ops.get_string(description, "rich_text_raw_title", submod)
)
id = Ops.get_string(
description,
"id",
Builtins.sformat("module_%1", no)
)
description["no"] = no
descriptions[submod] = description
new_submodules << submod
title = description["rich_text_title"] ||
description["rich_text_raw_title"] ||
submod

id = description["id"] || Builtins.sformat("module_%1", no)

@titles = Builtins.add(@titles, title)
Ops.set(@submod2id, submod, id)
Ops.set(@id2submod, id, submod)
@titles << title
@submod2id[submod] = id
@id2submod[id] = submod

no = Ops.add(no, 1)
no += 1
end
end
end

@submodules = deep_copy(new_submodules) # maybe some submodules are not installed
Builtins.y2milestone("Execution order after rewrite: %1", @submodules)

# now build the menu button
Builtins.foreach(@submodules_presentation) do |submod|
descr = Ops.get_map(descriptions, submod, {})
if descr != {}
no2 = Ops.get_integer(descr, "no", 0)
id = Ops.get_string(descr, "id", Builtins.sformat("module_%1", no2))
if Builtins.haskey(descr, "menu_titles")
Builtins.foreach(Ops.get_list(descr, "menu_titles", [])) do |i|
id2 = Ops.get(i, "id", "")
title = Ops.get(i, "title", "")
if id2 != "" && title != ""
menu_list = Builtins.add(
menu_list,
Item(Id(id2), Ops.add(title, "..."))
)
if UI.TextMode
# now build the menu button
Builtins.foreach(@submodules_presentation) do |submod|
descr = descriptions[submod] || {}
next if descr.empty?

no2 = descr["no"] || 0
id = descr["id"] || Builtins.sformat("module_%1", no2)
if descr.has_key? "menu_titles"
descr["menu_titles"].each do |i|
id2 = i["id"]
title = i["title"]
if id2 && title
menu_list << Item(Id(id2), Ops.add(title, "..."))
else
Builtins.y2error("Invalid menu item: %1", i)
end
end
else
menu_title = Ops.get_string(
descr,
"menu_title",
Ops.get_string(descr, "rich_text_title", submod)
)
menu_list = Builtins.add(
menu_list,
Item(Id(id), Ops.add(menu_title, "..."))
)
menu_title = descr["menu_title"] ||
descr["rich_text_title"] ||
submod

menu_list << Item(Id(id), Ops.add(menu_title, "..."))
end
end
end

# menu button item
menu_list = Builtins.add(
menu_list,
Item(Id(:reset_to_defaults), _("&Reset to defaults"))
)
# menu button
UI.ReplaceWidget(
Id(:rep_menu),
MenuButton(Id(:menu), _("&Change..."), menu_list)
)
# menu button item
menu_list << Item(Id(:reset_to_defaults), _("&Reset to defaults")) <<
Item(Id(:export_config), _("&Export Configuration"))

Ops.greater_than(no, 1)
# menu button
UI.ReplaceWidget(
Id(:rep_menu),
MenuButton(Id(:menu), _("&Change..."), menu_list)
)
end

return no > 1
end

def set_icon
icon = "yast-software"

Expand Down

0 comments on commit 70b92d4

Please sign in to comment.