gui

package
v0.1.708 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 64 Imported by: 0

Documentation

Overview

Package gui hosts the desktop app: a tray panel and a regular window that share one small web UI. The UI talks to Go over a tiny JSON API served by the same handler that serves the static assets, so no binding generator or bundler is involved.

Index

Constants

This section is empty.

Variables

View Source
var OpenPanel bool

OpenPanel has Run open the quick panel once it starts, as `magpie panel` does; a second `magpie panel` toggles it in the running one. Omarchy's bar icon runs it (see omarchy.AddWidget).

View Source
var OpenView string

OpenView is the tab the window opens on, as `magpie gui settings` asks: a restart to update comes back where it was asked for.

View Source
var Started func()

Started is called once the app has started, by when Wails handles SIGINT and SIGTERM itself (it starts listening as it runs, before the app is said to have started); until then a signal is magpie's to handle.

View Source
var Version = "dev"

Version is the build's version string, shown in Settings.

Functions

func Handler

func Handler(w Windows, gw *gateway.Server) http.Handler

Handler serves the embedded UI and the JSON API. gw is the gateway this process serves, or nil when another magpie has it (for now: see startBackend).

func ImportLink(args []string) string

ImportLink is the link among a launch's arguments, if any.

func LANAddrs added in v0.1.180

func LANAddrs() []string

LANAddrs are this computer's addresses on the local network, for the links to print when the page is served there: MAGPIE_PUBLIC_URL's host when set (in a container, whose own addresses the network can't reach).

func NetworkLinks(port, key string) []string

NetworkLinks are the links to the page, served on port, that other machines open; key is the link's "/?k=…". MAGPIE_PUBLIC_URL with a port of its own names the host the container's ports are published on, so the page is at that host on its own port; one without (a reverse proxy's https://magpie.example.com, #372) is where the page is, path and all.

func Run

func Run(version string, showMain bool, link string) error

Run starts the desktop app: a menu bar icon whose click drops down a compact panel, plus a regular window for when you want it to stay around. showMain opens the window immediately; otherwise only the tray icon appears. link is a magpie:// link the app was started with, to confirm and import.

Types

type Glide added in v0.1.38

type Glide struct {
	MS    int
	Curve [4]float64
}

Glide is how the panel moves to a new height: over MS milliseconds on a CSS cubic-bezier, so it keeps pace with what the page animates inside it. A zero Glide is a jump.

type Web added in v0.1.180

type Web struct {
	Addr, Link string
	// contains filtered or unexported fields
}

Web is a started `magpie web`: its address and the link that signs a browser in.

func StartWeb added in v0.1.180

func StartWeb(addr, version string) (*Web, error)

StartWeb serves the page on addr (host:port), as the given version of magpie, which keeps itself up to date as the app does. Every request needs the key the link carries, taken once into a cookie other sites' pages can't send with a POST (every change is one), so neither a page elsewhere nor anyone else on the network reaches the settings and keys behind it.

func (*Web) Wait added in v0.1.180

func (w *Web) Wait() error

Wait returns once the page's Quit is used. After a restart to update it runs the new version in this one's place, with the same arguments and key, so the page open in the browser finds it where it was.

type Windows

type Windows interface {
	HidePanel()
	// ShowMain brings the window up, on the named tab when view is set.
	ShowMain(view string)
	Quit()
	// OpenURL hands a link to the system browser.
	OpenURL(url string)
	// OpenFolder shows a folder in the system file manager.
	OpenFolder(path string) error
	// ChooseFolder asks for a folder in the system's picker: "" when the
	// user cancels it.
	ChooseFolder(title string) (string, error)
	// Copy puts text on the system clipboard, which the page's own
	// navigator.clipboard can't always reach from inside the app.
	Copy(text string) bool
	// FitPanel asks for the panel to be tall enough for its content.
	FitPanel(height int, g Glide)
	// TintPanel paints the panel's tint behind the page, where the system
	// keeps up with the panel's size; false when it can't, for the page to
	// go on painting it itself.
	TintPanel(rgba [4]uint8, ms int) bool
	// TintTitleBar paints the window's title bar the page's colour, where
	// the system draws one (Windows); false where there is none to paint.
	TintTitleBar(rgba [4]uint8, dark bool) bool
	// SetTextSize zooms the window's and the panel's pages to percent
	// (settings.TextSizes), the panel's size with them.
	SetTextSize(percent int)
}

Windows is what the API needs from the host application.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL