settings

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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).

View Source
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

This section is empty.

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 New

func New(o Options) *Window

New returns a window that is not connected yet.

func (*Window) Connect

func (w *Window) Connect(ctx context.Context, c *api.Client, events *live.Events) error

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

func (w *Window) FirstRun(c *ui.Context)

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

func (w *Window) NeedsFirstRun() bool

NeedsFirstRun reports whether maild lists no account: the main window then shows FirstRun in place of its panes.

func (*Window) Show

func (w *Window) Show(pane string)

Show switches the window to a pane; unknown names are ignored. It does not open the window.

func (*Window) View

func (w *Window) View(c *ui.Context)

View draws the settings window's content.

Jump to

Keyboard shortcuts

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