Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Jan 19, 2020
1 parent ebc5b9f commit e1905aa
Showing 1 changed file with 67 additions and 9 deletions.
76 changes: 67 additions & 9 deletions src/lib/y2packager/dialogs/addon_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require "erb"
require "ui/installation_dialog"
require "y2packager/resolvable"
require "ui/text_helpers"

Yast.import "AddOnProduct"
Yast.import "Mode"
Expand Down Expand Up @@ -120,22 +121,79 @@ def selection_content
products.map { |p| Item(Id(p.dir), p.summary || p.name, defaults.include?(p)) }
end

# Build the items to be used by the addons selector
#
# @see #addons_box
#
# @return [Array<Yast::Term>] items for the addons selector.
def addons_items
products.map do |p|
Item(
Id(p.dir),
p.summary || p.name,
product_description(p),
)
end
end

# Build the map of addons states
#
# @see #show_addons
#
# @return [Hash<String => Integer>]
def addons_states
@addons.reduce({}) do |states, addon|
states[addon_widget_id(addon)] =
case addon.status
when :selected, :registered
MOD_INSTALL
when :auto_selected
MOD_AUTOINSTALL
else
MOD_DONT_INSTALL
end

states
end
end


MOD_DONT_INSTALL = 0
private_constant :MOD_DONT_INSTALL
MOD_INSTALL = 1
private_constant :MOD_INSTALL
MOD_AUTOINSTALL = 2
private_constant :MOD_AUTOINSTALL

def custom_states
[
# icon, NCurses indicator, next status (optional)
["checkbox-off", "[ ]", MOD_INSTALL ],
["checkbox-on", "[x]", MOD_DONT_INSTALL],
["checkbox-auto-selected", "[a]", MOD_DONT_INSTALL]
]
end

# Create the UI box with addon check boxes
#
# @return [Yast::Term] the main UI dialog term
def addons_box
# FIXME: the items will be added via UI.ChangeWidget; see #show_addons and
# AddonSelectionRegistratioDialog#run
content = CustomStatusItemSelector(Id(:items), Opt(:notify), custom_states, addons_items)

content
end


# Dialog content
#
# @see ::UI::Dialog
def dialog_content
VBox(
# TRANSLATORS: Product selection label (above a multi-selection box)
Left(Heading(_("Available Extensions and Modules"))),
VWeight(60, MinHeight(8,
MultiSelectionBox(
Id(:addon_repos),
Opt(:notify, :immediate),
"",
selection_content
))),
VSpacing(0.4),
details_widget
addons_box
)
end

Expand Down

0 comments on commit e1905aa

Please sign in to comment.