Documentation ¶
Index ¶
- func Error(ctx context.Context, errs ...error)
- func Fatal(ctx context.Context, errs ...error)
- func GTKWindowFromContext(ctx context.Context) *gtk.Window
- func Hook(f func(*Application))
- func IsActive(ctx context.Context) bool
- func IsDevel() bool
- func OpenURI(ctx context.Context, uri string)
- func SetTitle(ctx context.Context, title string)
- func WithApplication(ctx context.Context, app *Application) context.Context
- func WithWindow(ctx context.Context, win *Window) context.Context
- type Application
- func (app *Application) AddActionCallbacks(m map[string]gtkutil.ActionCallback)
- func (app *Application) AddActionShortcuts(m map[string]string)
- func (app *Application) AddActions(m map[string]func())
- func (app *Application) AddJSONActions(m map[string]interface{})
- func (app *Application) BaseID() string
- func (app *Application) CachePath(tails ...string) string
- func (app *Application) ConfigPath(tails ...string) string
- func (app *Application) Context() context.Context
- func (app *Application) Error(err ...error)
- func (app *Application) Fatal(err ...error)
- func (app *Application) ID() string
- func (app *Application) IDDot(parts ...string) string
- func (app *Application) Name() string
- func (app *Application) NewWindow() *Window
- func (app *Application) Quit()
- func (app *Application) Run(args []string) int
- func (app *Application) RunMain()
- func (app *Application) SuffixedTitle(title string) string
- type SingleStateKey
- type Statedeprecated
- func (s *State) Delete(key string)
- func (s *State) Each(f func(key string, unmarshal func(interface{}) bool) (done bool))
- func (s *State) Exists(key string) bool
- func (s *State) ExistsAsync(key string, done func(exists bool))
- func (s *State) Get(key string, dst interface{}) bool
- func (s *State) GetAsync(key string, dst interface{}, done func())
- func (s *State) Set(key string, val interface{})
- type StateKey
- type TypedSingleState
- type TypedState
- func (s *TypedState[StateT]) Delete(key string)
- func (s *TypedState[StateT]) Each(f func(key string, value StateT) (done bool))
- func (s *TypedState[StateT]) EachKey(f func(key string) (done bool))
- func (s *TypedState[StateT]) Exists(key string, f func(bool))
- func (s *TypedState[StateT]) Get(key string, f func(StateT))
- func (s *TypedState[StateT]) Set(key string, value StateT)
- type Window
- func (w *Window) Application() *Application
- func (w *Window) Error(err ...error)
- func (w *Window) Fatal(err ...error)
- func (w *Window) NewHeader() *gtk.HeaderBar
- func (w *Window) NewWindowHandle() *gtk.WindowHandle
- func (w *Window) NotifyChild(once bool, f func())
- func (w *Window) SetLoading()
- func (w *Window) SetSensitive(sensitive bool)
- func (w *Window) SetTitle(title string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
Error calls Error on the application inside the context. It panics if the context does not have the application.
func GTKWindowFromContext ¶
GTKWindowFromContext returns the context's window. If the context does not have a window, then the active window is returned.
func Hook ¶
func Hook(f func(*Application))
Hook adds a new hook callback to be called during construction of an Application. This function allows injecting initialization function calls such as Adwaita's without having to explicitly write it in main().
func IsDevel ¶
func IsDevel() bool
IsDevel returns true if the windows spawned using app will have the .devel class. This returns true if Go reports that vcs.modified is true.
func WithApplication ¶
func WithApplication(ctx context.Context, app *Application) context.Context
WithApplication injects the given application instance into a context. The returned context will also be cancelled if the application shuts down.
Types ¶
type Application ¶
type Application struct { *gtk.Application // contains filtered or unexported fields }
Application describes the state of a Matrix application.
func FromContext ¶
func FromContext(ctx context.Context) *Application
FromContext pulls the application from the given context. If the given context isn't derived from Application, then nil is returned.
func New ¶
func New(ctx context.Context, appID, appName string) *Application
New creates a new Application.
func NewWithFlags ¶
func NewWithFlags(ctx context.Context, appID, appName string, flags gio.ApplicationFlags) *Application
NewWithFlags creates a new Application with the given application flags.
func (*Application) AddActionCallbacks ¶
func (app *Application) AddActionCallbacks(m map[string]gtkutil.ActionCallback)
AddActionCallbacks is the ActionCallback variant of AddActions.
func (*Application) AddActionShortcuts ¶
func (app *Application) AddActionShortcuts(m map[string]string)
AddActionShortcuts binds accelerator strings to action strings.
func (*Application) AddActions ¶
func (app *Application) AddActions(m map[string]func())
AddActions adds the given map of actions into the Application.
func (*Application) AddJSONActions ¶
func (app *Application) AddJSONActions(m map[string]interface{})
AddJSONActions adds the given map of action functions with parameters into the Application. The value of the map is a function of type `func(T)`, where T is any type that is JSON-encoded using gtkutil.NewJSONVariant.
func (*Application) BaseID ¶
func (app *Application) BaseID() string
BaseID returns the last part of the application ID.
func (*Application) CachePath ¶
func (app *Application) CachePath(tails ...string) string
CacheDir returns the path to the cache directory of the application.
func (*Application) ConfigPath ¶
func (app *Application) ConfigPath(tails ...string) string
ConfigPath returns the path to the configuration directory with the given tails appended. If the path fails, then the function panics.
func (*Application) Context ¶
func (app *Application) Context() context.Context
Context returns the Application's context. This context contains the Application instance and will be cancelled on SIGINT once Run has been called. This method will panic if it's called before Run is called. Use it during initialization within signals.
func (*Application) Fatal ¶
func (app *Application) Fatal(err ...error)
Fatal shows a fatal error popup and closes the application afterwards.
func (*Application) IDDot ¶
func (app *Application) IDDot(parts ...string) string
IDDot creates a new application ID by joining all parts into the tail of the application ID. If no arguments are given, then the app ID is returned.
func (*Application) NewWindow ¶
func (app *Application) NewWindow() *Window
NewWindow creates a new Window bounded to the Application instance.
func (*Application) Quit ¶
func (app *Application) Quit()
Quit quits the application. The function is thread-safe.
func (*Application) Run ¶
func (app *Application) Run(args []string) int
Run runs the application for as long as the context is alive. If a SIGINT is sent, then the application is stopped.
func (*Application) RunMain ¶
func (app *Application) RunMain()
RunMain is a convenient function around Run that uses os.Args and os.Exit.
func (*Application) SuffixedTitle ¶
func (app *Application) SuffixedTitle(title string) string
SuffixedTitle suffixes the title with the application name and returns the string.
type SingleStateKey ¶
type SingleStateKey[StateT any] struct { // contains filtered or unexported fields }
SingleStateKey defines a constant key for a state that only has one value.
func NewSingleStateKey ¶
func NewSingleStateKey[StateT any](tails ...string) SingleStateKey[StateT]
NewSingleStateKey creates a new SingleStateKey with the given state type and the config path tails.
func (SingleStateKey[StateT]) Acquire ¶
func (s SingleStateKey[StateT]) Acquire(ctx context.Context) *TypedSingleState[StateT]
type State
deprecated
type State struct {
// contains filtered or unexported fields
}
State implements an easy API for storing persistent state that components can use.
Deprecated: prefer StateKey, which is a type-safe wrapper around this.
func AcquireState ¶
AcquireState creates a new Config instance.
func (*State) ExistsAsync ¶
type StateKey ¶
type StateKey[StateT any] struct { // contains filtered or unexported fields }
StateKey defines a constant key for a state. It exposes a type-safe API to acquire, get and restore state.
func NewStateKey ¶
NewStateKey creates a new StateKey with the given state type and the config path tails.
type TypedSingleState ¶
TypedSingleState is a type-safe wrapper around State that only has one value.
func (*TypedSingleState[StateT]) Delete ¶
func (s *TypedSingleState[StateT]) Delete()
Delete deletes the key.
func (*TypedSingleState[StateT]) Exists ¶
func (s *TypedSingleState[StateT]) Exists(f func(bool))
Exists returns true if key exists.
func (*TypedSingleState[StateT]) Get ¶
func (s *TypedSingleState[StateT]) Get(f func(StateT))
Get gets the value of the key. If the key does not exist, it does not call f.
func (*TypedSingleState[StateT]) Set ¶
func (s *TypedSingleState[StateT]) Set(value StateT)
Set sets the value of the key.
type TypedState ¶
TypedState is a type-safe wrapper around State.
func (*TypedState[StateT]) Delete ¶
func (s *TypedState[StateT]) Delete(key string)
Delete deletes the key.
func (*TypedState[StateT]) Each ¶
func (s *TypedState[StateT]) Each(f func(key string, value StateT) (done bool))
Each loops over each key in the map. It automatically unmarshals the value before calling f. To avoid this, use EachKey.
func (*TypedState[StateT]) EachKey ¶
func (s *TypedState[StateT]) EachKey(f func(key string) (done bool))
EachKey loops over each key in the map.
func (*TypedState[StateT]) Exists ¶
func (s *TypedState[StateT]) Exists(key string, f func(bool))
Exists returns true if key exists.
func (*TypedState[StateT]) Get ¶
func (s *TypedState[StateT]) Get(key string, f func(StateT))
Get gets the value of the key. If the key does not exist, it does not call f.
func (*TypedState[StateT]) Set ¶
func (s *TypedState[StateT]) Set(key string, value StateT)
Set sets the value of the key.
type Window ¶
type Window struct { gtk.Window // contains filtered or unexported fields }
Window wraps a gtk.ApplicationWindow.
func NewWindow ¶
func NewWindow(app *Application) *Window
NewWindow creates a new Window bounded to the Application instance.
func WindowFromContext ¶
WindowFromContext returns the context's window.
func WrapWindow ¶
func WrapWindow(app *Application, window *gtk.ApplicationWindow) *Window
WrapWindow wraps a gtk.ApplicationWindow into an app.Window.
func (*Window) Application ¶
func (w *Window) Application() *Application
Application returns the Window's parent Application instance.
func (*Window) NewHeader ¶
func (w *Window) NewHeader() *gtk.HeaderBar
NewHeader creates a new header and puts it into the application window.
func (*Window) NewWindowHandle ¶
func (w *Window) NewWindowHandle() *gtk.WindowHandle
NewWindowHeader creates a new blank header.
func (*Window) NotifyChild ¶
NotifyChild calls f if the main window's child is changed. If once is true, then f is never called again.
func (*Window) SetLoading ¶
func (w *Window) SetLoading()
SetLoading shows a spinning circle. It disables the window. Note that this function crashes when the base gtk.Window comes from adw.Window.
func (*Window) SetSensitive ¶
SetSensitive sets whether or not the application's window is enabled.
Directories ¶
Path | Synopsis |
---|---|
Package notify provides an API to send declarative notifications as well as playing sounds when they're sent.
|
Package notify provides an API to send declarative notifications as well as playing sounds when they're sent. |
Package prefs provides a publish-subscription API for global settinsg management.
|
Package prefs provides a publish-subscription API for global settinsg management. |