Class: Lich::Common::GUI::ManualFrontendSelector

Inherits:
Object
  • Object
show all
Defined in:
documented/common/gui/manual_frontend_selector.rb

Overview

Manual Login offers detected clients and an explicit custom-command path. Configuration surfaces use FrontendSelector to include unavailable clients.

Constant Summary collapse

CUSTOM_ID =
'__custom__'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selected_id: nil, refresh: true, locator: FrontendLocator) ⇒ ManualFrontendSelector

Parameters:

  • selected_id (String, nil) (defaults to: nil) —

    preferred frontend identity

  • refresh (Boolean) (defaults to: true) —

    refresh executable discovery

  • locator (FrontendLocator) (defaults to: FrontendLocator) —

    discovery API



24
25
26
27
28
29
# File 'documented/common/gui/manual_frontend_selector.rb', line 24

def initialize(selected_id: nil, refresh: true, locator: FrontendLocator)
  @locator = locator
  @callbacks = []
  @widget = Gtk::Box.new(:horizontal, 10)
  rebuild(selected_id, refresh: refresh)
end

Instance Attribute Details

#widget ⇒ Object (readonly)

Returns the value of attribute widget.



18
19
20
# File 'documented/common/gui/manual_frontend_selector.rb', line 18

def widget
  @widget
end

Instance Method Details

#custom? ⇒ Boolean

Returns whether an explicit custom command is required.

Returns:

  • (Boolean) —

    whether an explicit custom command is required



38
39
40
# File 'documented/common/gui/manual_frontend_selector.rb', line 38

def custom?
  @selection == CUSTOM_ID
end

#launchable?(refresh: true) ⇒ Boolean

Returns whether the native selection can launch.

Parameters:

  • refresh (Boolean) (defaults to: true) —

    refresh executable discovery

Returns:

  • (Boolean) —

    whether the native selection can launch



49
50
51
# File 'documented/common/gui/manual_frontend_selector.rb', line 49

def launchable?(refresh: true)
  !custom? && FrontendLauncher.launchable?(selected_id, locator: @locator, refresh: refresh)
end

#native_launch_only? ⇒ Boolean

Returns whether custom launch is unsupported for this client.

Returns:

  • (Boolean) —

    whether custom launch is unsupported for this client



43
44
45
# File 'documented/common/gui/manual_frontend_selector.rb', line 43

def native_launch_only?
  !custom? && Frontend.definition_for(selected_id).dig(:metadata, :native_launch_only) == true
end

#on_change {|ManualFrontendSelector| ... } ⇒ void

This method returns an undefined value.

Yields:



55
56
57
58
# File 'documented/common/gui/manual_frontend_selector.rb', line 55

def on_change(&callback)
  @callbacks << callback
  nil
end

#reload!(refresh: true) ⇒ ManualFrontendSelector

Retains the chosen client, or selects Custom if it disappears.

Parameters:

  • refresh (Boolean) (defaults to: true) —

    refresh executable discovery

Returns:



63
64
65
66
67
# File 'documented/common/gui/manual_frontend_selector.rb', line 63

def reload!(refresh: true)
  rebuild(@selection, refresh: refresh)
  @callbacks.each { |callback| callback.call(self) }
  self
end

#selected_id ⇒ String

Custom uses Wrayth's protocol identity, not its executable.

Returns:

  • (String) —

    stable frontend identity for authentication and storage



33
34
35
# File 'documented/common/gui/manual_frontend_selector.rb', line 33

def selected_id
  custom? ? 'stormfront' : @selection
end