Optional application-level coordinator for larger Guppy apps.
Guppy.Window remains the per-window abstraction and can still be started on
its own. Guppy.App adds one OTP boundary for app-global configuration,
resource slots, command/menu dispatch, and app-supervised windows.
defmodule MyApp do
use Guppy.App,
windows: [
%{id: "main", module: MyApp.MainWindow, arg: %{}}
],
commands: [%{id: "new_file", label: "New File"}],
menus: [%{label: "File", items: [%{id: "new_file", label: "New", callback: "new_file"}]}]
@impl Guppy.App
def handle_command("new_file", _payload, state) do
{:noreply, state}
end
endApp modules usually start under the module name as the registered coordinator
process, similar to Ecto.Repo. The process is non-rendering; windows remain
Guppy.Window modules. App lifecycle events such as "app_activated" and
"app_deactivated" are delivered to optional handle_event/3 callbacks.
Summary
Types
Result shape for use Guppy.App callbacks.
App coordinator state threaded through use Guppy.App callbacks.
Functions
Returns the app-owned native badge label, or nil.
Closes an app-owned window by string id.
Returns Guppy.IR.div/2 action/shortcut options for the app command registry.
Returns the native action callback id that routes shortcut actions to handle_command/3.
Returns command registry entries keyed by id.
Returns the validated app configuration.
Returns the app ref for the current app-supervised window process, if any.
Returns the app window id for the current app-supervised window process, if any.
Dispatches an app command asynchronously.
Dispatches the command bound to an app keymap entry, if any.
Returns app-owned Dock/app-icon menu items.
Activates/focuses an app-owned window by string id.
Returns app keymap entries.
Returns app-owned menus.
Opens the built-in command-palette overlay for an app.
Opens an app-owned transient context-menu popup for command items.
Opens a configured or dynamic app window by string id.
Returns packaging/signing metadata hooks stored in app config.
Registers a theme family for later lookup by theme id.
Installs or clears the app-owned native badge label.
Updates one app command's enabled state.
Replaces the app command registry after validation.
Installs app-owned native Dock/app-icon menu items.
Replaces app keymap entries after validation against commands.
Installs app-owned native menus.
Replaces the app stylesheet cache after validation.
Replaces the app theme after validation.
Starts an app supervisor and a registered app coordinator.
Resolves app stylesheet class references to style option keyword entries.
Returns the app stylesheet cache.
Returns the active app theme.
Looks up a semantic color token in the active app theme.
Looks up a semantic color token or raises when it is unavailable.
Returns registered app theme families keyed by family id.
Looks up a resolved semantic style token in the active app theme.
Looks up a semantic style token or raises when it is unavailable.
Returns the pid for an app-owned window id, or nil.
Returns known app window ids and pids.
Types
@type app_ref() :: GenServer.server()
Result shape for use Guppy.App callbacks.
@opaque state()
App coordinator state threaded through use Guppy.App callbacks.
Treat it as opaque: pattern-match nothing out of it and return it (possibly
via the tuple shapes in callback_result/0) unchanged.
Callbacks
@callback handle_command(String.t(), map(), state()) :: callback_result()
@callback handle_event(String.t(), map(), state()) :: callback_result()
@callback handle_info(term(), state()) :: callback_result()
@callback init(keyword()) :: map() | keyword() | Guppy.App.Config.t() | {:ok, map() | keyword() | Guppy.App.Config.t()} | {:stop, term()}
Functions
Returns the app-owned native badge label, or nil.
Closes an app-owned window by string id.
Returns Guppy.IR.div/2 action/shortcut options for the app command registry.
Returns the native action callback id that routes shortcut actions to handle_command/3.
Returns command registry entries keyed by id.
Returns the validated app configuration.
Returns the app ref for the current app-supervised window process, if any.
Returns the app window id for the current app-supervised window process, if any.
Dispatches an app command asynchronously.
Dispatches the command bound to an app keymap entry, if any.
Activates/focuses an app-owned window by string id.
Returns app keymap entries.
Opens the built-in command-palette overlay for an app.
Opens a configured or dynamic app window by string id.
Returns packaging/signing metadata hooks stored in app config.
Registers a theme family for later lookup by theme id.
Installs or clears the app-owned native badge label.
Updates one app command's enabled state.
Replaces the app command registry after validation.
Replaces app keymap entries after validation against commands.
Replaces the app stylesheet cache after validation.
Replaces the app theme after validation.
Starts an app supervisor and a registered app coordinator.
Resolves app stylesheet class references to style option keyword entries.
Returns the app stylesheet cache.
Returns the active app theme.
Looks up a semantic color token in the active app theme.
Looks up a semantic color token or raises when it is unavailable.
Returns registered app theme families keyed by family id.
Looks up a resolved semantic style token in the active app theme.
Looks up a semantic style token or raises when it is unavailable.
Returns the pid for an app-owned window id, or nil.
Returns known app window ids and pids.