Documentation
¶
Overview ¶
Package frontend is what the updater shares with the windows that show its sessions: package updater shows them in a web page, package native in native UI.
Index ¶
Constants ¶
const (
StatusWidth, StatusHeight = 480, 148
ReleaseWidth, ReleaseHeight = 620, 440
)
The size of the update window's content, for status views and for views with release notes.
Variables ¶
var Plugin func(opts any, open Open) golet.Plugin
Plugin returns the updater plugin with opts, an updater.Options, whose windows open creates. Package updater sets it.
Functions ¶
func Background ¶
func Background() (light, dark string)
Background returns the light and dark colors of the update window: the gray of dialogs on macOS, and white elsewhere, where the title bar above it is light.
func Show ¶
func Show(win *golet.Window, user bool)
Show shows win as Sparkle shows its update alert: in front, with the keyboard, when the user asked for the check or the app is active. A check in the background takes the keyboard from no other app: on macOS win waits until the app becomes active, unless the app has no Dock icon and so may never be, which comes to the front; elsewhere it shows without the keyboard.
Types ¶
type Button ¶
type Button struct {
Action Action `json:"action"`
Label string `json:"label"`
// Default is the button of Enter, Cancel the one of Escape.
Default bool `json:"default,omitzero"`
Cancel bool `json:"cancel,omitzero"`
// Aside sets the button apart, on the left.
Aside bool `json:"aside,omitzero"`
Disabled bool `json:"disabled,omitzero"`
}
Button is a button of a view.
type Open ¶
type Open func(s Session)
Open creates the window of a session and shows it, at once or once it is ready to.
type Session ¶
type Session interface {
// NewWindow creates the session's window, hidden, showing content, or
// a web page when content is nil. The session resizes it for its
// views and closes it when it ends.
NewWindow(content golet.Content) *golet.Window
// Current returns the view to show and a channel closed when it
// changes.
Current() (View, <-chan struct{})
// Done is closed when the session ends or its window closes.
Done() <-chan struct{}
// Respond answers the prompt of a view with a button, and tells
// whether updates may be installed automatically from now on. Only
// the first response to a prompt counts.
Respond(prompt int, a Action, automaticDownloads bool)
// Fit gives the window the width its buttons need, when they need
// more than the usual width, and a status view the height of its
// content, in DIPs.
Fit(width, height int)
// Texts returns the texts of the window that views leave out.
Texts() Texts
// Icon returns the PNG image of the window, or nil.
Icon() []byte
// User reports whether the user asked for the check: the window shows
// in front.
User() bool
}
Session is a check for updates and what follows it, as its window sees it.
type Texts ¶
type Texts struct {
// Title is the title of the window, ReleaseNotes the heading of the
// notes and AutomaticDownloads the label of the checkbox.
Title, ReleaseNotes, AutomaticDownloads string
// Lang is the language, such as "zh-Hans", and RTL is set for those
// written from right to left.
Lang string
RTL bool
}
Texts are the texts of the window around its views, in the language of the window.
type View ¶
type View struct {
// Prompt changes with the buttons: responses name the prompt they
// answer, so that none answers a later one.
Prompt int `json:"prompt"`
// Release views show release notes, in a larger window.
Release bool `json:"release,omitzero"`
Title string `json:"title"`
Message string `json:"message,omitzero"`
// Detail is the error of a failure.
Detail string `json:"detail,omitzero"`
// Notes are the release notes.
Notes []markdown.Block `json:"-"`
// Bar shows a progress bar with Progress, between 0 and 1, or -1 when
// the progress is unknown.
Bar bool `json:"bar,omitzero"`
Progress float64 `json:"progress,omitzero"`
// Checkbox offers to download and install updates automatically,
// Checked or not.
Checkbox bool `json:"checkbox,omitzero"`
Checked bool `json:"checked,omitzero"`
Buttons []Button `json:"buttons"`
}
View is what the update window shows.