Class: Lich::Common::GUI::FrontendSelector
- Inherits:
-
Object
- Object
- Lich::Common::GUI::FrontendSelector
- Defined in:
- documented/common/gui/frontend_selector.rb
Overview
Shared GTK frontend selector backed by the non-GTK frontend locator. Every GUI surface receives the same discovered, catalog-defined set.
Instance Attribute Summary collapse
-
#resolutions ⇒ Object
readonly
Returns the value of attribute resolutions.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Checks whether no frontends were discovered.
-
#initialize(selected_id: nil, refresh: true, locator: FrontendLocator) ⇒ FrontendSelector
constructor
A new instance of FrontendSelector.
-
#native_launch_only? ⇒ Boolean
Whether the selected frontend disallows custom launch.
-
#on_change {|FrontendSelector| ... } ⇒ void
Registers a callback for changes to any generated frontend option.
-
#resolve_selected(refresh: true) ⇒ FrontendLocator::Resolution?
Revalidates the selected executable immediately before launch.
-
#selected_id ⇒ String?
Selected stable frontend identifier.
Constructor Details
#initialize(selected_id: nil, refresh: true, locator: FrontendLocator) ⇒ FrontendSelector
Returns a new instance of FrontendSelector.
20 21 22 23 24 25 |
# File 'documented/common/gui/frontend_selector.rb', line 20 def initialize(selected_id: nil, refresh: true, locator: FrontendLocator) @locator = locator @resolutions = locator.available(gui_selectable: true, refresh: refresh) @buttons = {} @widget = (selected_id) end |
Instance Attribute Details
#resolutions ⇒ Object (readonly)
Returns the value of attribute resolutions.
15 16 17 |
# File 'documented/common/gui/frontend_selector.rb', line 15 def resolutions @resolutions end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
15 16 17 |
# File 'documented/common/gui/frontend_selector.rb', line 15 def @widget end |
Instance Method Details
#empty? ⇒ Boolean
Checks whether no frontends were discovered.
62 63 64 |
# File 'documented/common/gui/frontend_selector.rb', line 62 def empty? @buttons.empty? end |
#native_launch_only? ⇒ Boolean
Returns whether the selected frontend disallows custom launch.
34 35 36 37 38 |
# File 'documented/common/gui/frontend_selector.rb', line 34 def native_launch_only? return false unless selected_id Frontend.definition_for(selected_id).dig(:metadata, :native_launch_only) == true end |
#on_change {|FrontendSelector| ... } ⇒ void
This method returns an undefined value.
Registers a callback for changes to any generated frontend option.
43 44 45 46 47 48 |
# File 'documented/common/gui/frontend_selector.rb', line 43 def on_change(&callback) @buttons.each_value do || .signal_connect('toggled') { callback.call(self) if .active? } end nil end |
#resolve_selected(refresh: true) ⇒ FrontendLocator::Resolution?
Revalidates the selected executable immediately before launch.
53 54 55 56 57 |
# File 'documented/common/gui/frontend_selector.rb', line 53 def resolve_selected(refresh: true) return nil unless selected_id @locator.resolve(selected_id, refresh: refresh) end |
#selected_id ⇒ String?
Returns selected stable frontend identifier.
28 29 30 31 |
# File 'documented/common/gui/frontend_selector.rb', line 28 def selected_id pair = @buttons.find { |_frontend_id, | .active? } pair && pair.first end |