Documentation
¶
Overview ¶
Package settings is the desktop app's settings window, its first run, and the change between this computer's maild and lodge's (docs/specs/settings-ui.md; plan 0015, Phase 8). All of its state belongs to the UI thread; goroutines hand results back through Post.
Index ¶
- Constants
- func ChangeServer(options Options, flatpak bool, next conn.AppConfig) (moved bool, err error)
- func TrayPreference(configFile string) bool
- func WriteTrayPreference(configFile string, on bool) error
- type Options
- type ServerFacts
- type Window
- func (w *Window) CloseToTray() bool
- func (w *Window) Connect(ctx context.Context, c *api.Client, events *live.Events) error
- func (w *Window) Disconnect()
- func (w *Window) FirstRun(c *ui.Context)
- func (w *Window) NeedsFirstRun() bool
- func (w *Window) SetTray(shown bool)
- func (w *Window) Show(pane string)
- func (w *Window) View(c *ui.Context)
Constants ¶
const ( Width = 760 Height = 560 MinWidth = 640 MinHeight = 440 )
The window's size, and the smallest it may be (docs/specs/settings-ui.md, Window).
const ( PaneGeneral = "general" PaneAccounts = "accounts" PaneSignatures = "signatures" PaneSnippets = "snippets" PaneRules = "rules" PaneSignIn = "signin" PaneServer = "server" )
The panes, for Show.
Variables ¶
This section is empty.
Functions ¶
func ChangeServer ¶ added in v0.10.0
ChangeServer applies the desktop mode transition, including Flatpak stop and rollback. The caller serializes changes and retargets its connection when moved is true, including after a failed local start.
func TrayPreference ¶ added in v0.10.0
TrayPreference reports the persisted close-to-tray choice on this desktop.
func WriteTrayPreference ¶ added in v0.10.0
WriteTrayPreference persists the close-to-tray choice next to app.json.
Types ¶
type Options ¶
type Options struct {
// Post runs a function on the UI thread and redraws.
Post func(func())
// Wake asks for a redraw; it may be nil.
Wake func()
// Now is the clock [time.Now].
Now func() time.Time
// Toast shows what went wrong where no pane can say; it may be nil.
Toast func(title string, err error)
// ConfigFile is app.json's path.
ConfigFile string
// Facts are the Server pane's local facts (FactsFrom).
Facts ServerFacts
// LoadFacts, when set, reads them afresh each time the Server pane
// opens and after each change of mode, in place of Facts: a first start
// of this computer's maild makes its database.
LoadFacts func() ServerFacts
// SetTarget moves the session to the maild now chosen.
SetTarget func(conn.Target)
// LeaveLocal saves and closes what keeps this computer's maild's
// drafts open, the compose windows, and returns once they have saved:
// a change to lodge runs it before StopLocal. It may be nil.
LeaveLocal func()
// StopLocal stops this computer's maild and returns once it has
// stopped: mailctl shutdown.
StopLocal func(ctx context.Context) error
// StartLocal starts this computer's maild and returns once it answers:
// frostmail --start-maild. Its error is the launcher's last line.
StartLocal func(ctx context.Context) error
// OpenURL opens a sign-in in the system browser.
OpenURL func(url string) error
// EditRule opens the rule sheet: on rule, or a new rule for nil.
EditRule func(rule *api.Rule)
// Socket is this computer's maild, which a change to it connects to;
// empty is FROSTMAIL_SOCKET or the default socket.
Socket string
// OpenSettings shows the settings window on a pane, focusing it when
// it is open. First run calls it; nil only switches the pane.
OpenSettings func(pane string)
// Connection is the session's state, for the connecting text and to
// tell lodge's maild from this computer's; nil reads app.json.
Connection func() conn.State
// Announce shows the notes of message.announced, which a maild with no
// desktop to notify on sends; it runs on the events' goroutine, and may
// be nil.
Announce func(accountID int64, notes []api.Announcement)
}
Options configure a Window.
type ServerFacts ¶
type ServerFacts struct {
// Flatpak is true in this app's Flatpak: a change of mode stops or
// starts its maild.
Flatpak bool
// LocalData is true when maild's data directory holds a database.
LocalData bool
// HostMail is true when a Frostmail installed outside Flatpak has mail
// here, which the move note says how to bring in.
HostMail bool
}
ServerFacts are the Server pane's local facts: no request to maild, and none to lodge, so the pane says the same while either is unreachable.
func FactsFrom ¶
func FactsFrom(getenv func(string) string) ServerFacts
FactsFrom reads the facts from the environment, as the shell did. Only the files' metadata is read: the database belongs to maild.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is the settings window's state.
func (*Window) CloseToTray ¶ added in v0.8.0
CloseToTray reports this computer's setting: a close of the main window hides it in the tray, while a panel shows the icon (frostui's Tray.CloseToTray decides). It belongs to the UI thread.
func (*Window) Connect ¶
Connect shows the window on a new connection, whose events the caller subscribed to, and loads what the panes read. It may run on any goroutine. What the panes held of the last connection goes: another maild's ids mean other things here.
func (*Window) Disconnect ¶
func (w *Window) Disconnect()
Disconnect drops the connection that ended; it may run on any goroutine. The Server pane stays usable.
func (*Window) FirstRun ¶
FirstRun is the main window's welcome. The first time a connection finds no account it opens the settings window on Accounts itself; removing the last account later shows the welcome without opening it.
func (*Window) NeedsFirstRun ¶
NeedsFirstRun reports whether maild lists no account: the main window then shows FirstRun in place of its panes.
func (*Window) SetTray ¶ added in v0.8.0
SetTray says whether the app has a tray icon now. The app calls it with true once its icon exists: without one, the General pane has no close-to-tray row. It belongs to the UI thread.