Guppy.Server (guppy v0.2.0)

Copy Markdown View Source

Central Guppy runtime server.

Owns view ids, window ownership, native request dispatch, event routing, menu ownership, and cleanup when owners or the native event target exit.

Summary

Functions

Returns a specification to start this module under a supervisor.

Activates a caller-owned native window.

Returns the full server state; intended for debugging and tests.

Validates IR and window options and opens a native window owned by owner (which must be the calling process).

Pings the native bridge through the server.

Reads text from the platform clipboard.

Validates a full IR tree and renders it into a caller-owned window.

Sets or clears (nil) the app badge; owner must be the calling process.

Validates and installs the Dock menu; owner must be the calling process.

Validates and installs the app menu bar; owner must be the calling process.

Starts the server; :native and :native_server select the bridge implementation.

Returns the native-side open view count.

Types

owner_entry()

@type owner_entry() :: %{monitor: reference(), views: MapSet.t(view_id())}

state()

@type state() :: %Guppy.Server{
  app_badge_monitor: reference() | nil,
  app_badge_owner: pid() | nil,
  app_owner: pid() | nil,
  app_owner_monitor: reference() | nil,
  dock_menu_monitor: reference() | nil,
  dock_menu_owner: pid() | nil,
  menu_monitor: reference() | nil,
  menu_owner: pid() | nil,
  monitors: %{optional(reference()) => pid()},
  native: module(),
  native_request_timeout: timeout(),
  native_server: GenServer.server(),
  next_view_id: pos_integer(),
  owners: %{optional(pid()) => owner_entry()},
  views: %{optional(view_id()) => pid()}
}

view_id()

@type view_id() :: pos_integer()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

choose_directory_dialog(server \\ __MODULE__, opts \\ [], timeout \\ 30000)

Opens a platform directory chooser; see Guppy.choose_directory_dialog/2.

close_window(server \\ __MODULE__, view_id, timeout \\ 5000)

Closes a caller-owned native window.

focus_window(server \\ __MODULE__, view_id, timeout \\ 5000)

Activates a caller-owned native window.

info(server \\ __MODULE__)

Returns the full server state; intended for debugging and tests.

open_file_dialog(server \\ __MODULE__, opts \\ [], timeout \\ 30000)

Opens a platform file-open dialog; see Guppy.open_file_dialog/2 for options.

open_window(server \\ __MODULE__, owner, ir, opts \\ [], timeout \\ 5000)

Validates IR and window options and opens a native window owned by owner (which must be the calling process).

ping(server \\ __MODULE__, timeout \\ 5000)

Pings the native bridge through the server.

read_clipboard_text(server \\ __MODULE__, timeout \\ 5000)

Reads text from the platform clipboard.

render(server \\ __MODULE__, view_id, ir, timeout \\ 5000)

Validates a full IR tree and renders it into a caller-owned window.

save_file_dialog(server \\ __MODULE__, opts \\ [], timeout \\ 30000)

Opens a platform save dialog; see Guppy.save_file_dialog/2.

set_app_badge(server \\ __MODULE__, owner, label, timeout \\ 5000)

Sets or clears (nil) the app badge; owner must be the calling process.

set_dock_menu(server \\ __MODULE__, owner, items, timeout \\ 5000)

Validates and installs the Dock menu; owner must be the calling process.

set_menus(server \\ __MODULE__, owner, menus, timeout \\ 5000)

Validates and installs the app menu bar; owner must be the calling process.

start_link(opts \\ [])

Starts the server; :native and :native_server select the bridge implementation.

view_count(server \\ __MODULE__, timeout \\ 5000)

Returns the native-side open view count.

write_clipboard_text(server \\ __MODULE__, text, timeout \\ 5000)

Writes text to the platform clipboard.