Documentation ¶
Index ¶
- Constants
- Variables
- func ActionGroup(data ...gio.Actioner) *gio.SimpleActionGroup
- func AddActionCallbacks(actionMapper gio.ActionMapper, m map[string]ActionCallback)
- func AddActionShortcuts(w gtk.Widgetter, shortcuts map[string]string)
- func AddActions(actionMapper gio.ActionMapper, m map[string]func())
- func AddCallbackShortcuts(w gtk.Widgetter, shortcuts map[string]func())
- func Async(ctx context.Context, asyncFn func() func())
- func BindActionCallbackMap(w gtk.Widgetter, m map[string]ActionCallback)
- func BindActionMap(w gtk.Widgetter, m map[string]func())
- func BindKeys(w gtk.Widgetter, accelFns map[string]func() bool)
- func BindPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string)
- func BindPopoverMenuAtMouse(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string)
- func BindPopoverMenuCustom(w gtk.Widgetter, pos gtk.PositionType, pairs []PopoverMenuItem)
- func BindPopoverMenuLazy(w gtk.Widgetter, pos gtk.PositionType, pairsFn func() []PopoverMenuItem)
- func BindRightClick(w gtk.Widgetter, f func())
- func BindRightClickAt(w gtk.Widgetter, f func(x, y float64))
- func BindSubscribe(widget gtk.Widgetter, f func() (unsub func()))
- func CustomMenu(items []PopoverMenuItem) *gio.Menu
- func CustomMenuItems(items ...PopoverMenuItem) *gio.Menu
- func EachChild(w gtk.Widgetter, f func(child gtk.Widgetter) bool)
- func EachList[T glib.Objector](list gio.ListModeller, f func(T))
- func ForwardTyping(w, dst gtk.Widgetter)
- func ForwardTypingFunc(w gtk.Widgetter, f func() gtk.Widgetter)
- func IdleCtx(ctx context.Context, f func())
- func InvokeMain(f func())
- func IsCancelled(cancellable Cancellable) bool
- func MenuPair(pairs [][2]string) *gio.Menu
- func MustUnmarshalBuilder(v any, builder *gtk.Builder)
- func NewCustomMenuItem(label locale.Localized, id string) *gio.MenuItem
- func NewDragSourceWithContent(w gtk.Widgetter, a gdk.DragAction, v interface{}) *gtk.DragSource
- func NewJSONVariant(v interface{}) *glib.Variant
- func NewKeybinds(accelFns map[string]func() bool) *gtk.EventControllerKey
- func NewListDropTarget(l *gtk.ListBox, typ coreglib.Type, actions gdk.DragAction) *gtk.DropTarget
- func NewPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string) *gtk.PopoverMenu
- func NewPopoverMenuCustom(w gtk.Widgetter, pos gtk.PositionType, items []PopoverMenuItem) *gtk.PopoverMenu
- func NewPopoverMenuFromPairs(pairs [][2]string) *gtk.PopoverMenu
- func NewRadioButtons(d RadioData, f func(int)) gtk.Widgetter
- func NotifyProperty(obj glib.Objector, property string, f func() bool)
- func OnFirstDraw(w gtk.Widgetter, f func())
- func OnFirstDrawUntil(w gtk.Widgetter, f func() bool)
- func OnFirstMap(w gtk.Widgetter, f func())
- func PopupFinally(p Popupper)
- func RecursiveUnfuck(w gtk.Widgetter)
- func RemoveChildren(w gtk.Widgetter)
- func RowAtY(list *gtk.ListBox, y float64) (*gtk.ListBoxRow, gtk.PositionType)
- func ScaleFactor() int
- func SetScaleFactor(maxScale int)
- func ShowPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string) *gtk.PopoverMenu
- func ShowPopoverMenuCustom(w gtk.Widgetter, pos gtk.PositionType, items []PopoverMenuItem) bool
- func SignalToggler(signal string, f interface{}) func(obj coreglib.Objector)
- func UnmarshalBuilder(dst any, builder *gtk.Builder) error
- func WalkWidget(w gtk.Widgetter, f func(w gtk.Widgetter) bool)
- type ActionCallback
- type ActionData
- type CallbackAction
- type Cancellable
- type Canceller
- type FuncBatch
- type PopoverMenuItem
- func MenuItem(label locale.Localized, action string, ands ...bool) PopoverMenuItem
- func MenuItemIcon(label locale.Localized, action, icon string) PopoverMenuItem
- func MenuSeparator(label locale.Localized) PopoverMenuItem
- func MenuWidget(action string, w gtk.Widgetter) PopoverMenuItem
- func Submenu(label locale.Localized, sub []PopoverMenuItem) PopoverMenuItem
- type Popupper
- type RadioData
Constants ¶
const PopoverWidth = 150
PopoverWidth is the default popover width.
Variables ¶
var JSONVariantType = glib.NewVariantType("ay") // array of bytes
JSONVariantType is the GVariantType that describes the JSON argument that NewJSONActionCallback outputs.
Functions ¶
func ActionGroup ¶
func ActionGroup(data ...gio.Actioner) *gio.SimpleActionGroup
ActionGroup constructs an action group from the diven action data.
func AddActionCallbacks ¶
func AddActionCallbacks(actionMapper gio.ActionMapper, m map[string]ActionCallback)
AddActionCallbacks adds the given action callbacks to the given widget. Unlike BindActionCallbackMap, this function does not need prefixed action names.
func AddActionShortcuts ¶
AddActionShortcuts adds the given shortcuts to the widget. The shortcuts are given as a map of keybindings to action names.
func AddActions ¶
func AddActions(actionMapper gio.ActionMapper, m map[string]func())
AddActions adds the given actions to the given widget. Unlike BindActionMap, this function does not need prefixed action names.
func AddCallbackShortcuts ¶
func AddCallbackShortcuts(w gtk.Widgetter, shortcuts map[string]func())
AddCallbackShortcuts adds the given shortcuts to the widget. The shortcuts are given as a map of keybindings to callbacks.
func Async ¶
Async runs asyncFn in a goroutine and runs the returned callback in the main thread. If ctx is cancelled during, the returned callback will not be called.
func BindActionCallbackMap ¶
func BindActionCallbackMap(w gtk.Widgetter, m map[string]ActionCallback)
BindActionCallbackMap is a more verbose variant of BindActionMap.
func BindActionMap ¶
func BindActionMap(w gtk.Widgetter, m map[string]func())
BindActionMap binds the given map of actions (of key prefixed appropriately) to the given widget.
func BindKeys ¶
BindKeys binds the event controller returned from NewKeybinds being given the map to the given widget.
func BindPopoverMenu ¶
func BindPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string)
BindPopoverMenu binds the given widget to a popover menu to be displayed on right-clicking.
func BindPopoverMenuAtMouse ¶
func BindPopoverMenuAtMouse(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string)
BindPopoverMenuAtMouse binds the given widget to a popover menu to be displayed on right-clicking, but at the mouse position.
func BindPopoverMenuCustom ¶
func BindPopoverMenuCustom(w gtk.Widgetter, pos gtk.PositionType, pairs []PopoverMenuItem)
BindPopoverMenuCustom works similarly to BindPopoverMenu, but the value type can be more than just an action string. The key must be a string.
func BindPopoverMenuLazy ¶
func BindPopoverMenuLazy(w gtk.Widgetter, pos gtk.PositionType, pairsFn func() []PopoverMenuItem)
BindPopoverMenuLazy is similarl to BindPopoverMenuCustom, except the menu items are lazily created.
func BindRightClick ¶
func BindRightClick(w gtk.Widgetter, f func())
BindRightClick binds the given widget to take in right-click gestures. The function will also check for long-hold gestures.
func BindRightClickAt ¶
func BindRightClickAt(w gtk.Widgetter, f func(x, y float64))
BindRightClickAt is a version of BindRightClick with accurate coordinates given to the callback.
func BindSubscribe ¶
func BindSubscribe(widget gtk.Widgetter, f func() (unsub func()))
BindSubscribe calls f when w gets mapped.
func CustomMenu ¶
func CustomMenu(items []PopoverMenuItem) *gio.Menu
CustomMenu returns a new Menu from the given popover menu items. All menu items that have widgets are ignored.
func CustomMenuItems ¶
func CustomMenuItems(items ...PopoverMenuItem) *gio.Menu
CustomMenuItems is the variadic arguments variant of CustomMenu.
func EachChild ¶
func EachChild(w gtk.Widgetter, f func(child gtk.Widgetter) bool)
EachChild iterates over w's children.
func EachList ¶
func EachList[T glib.Objector](list gio.ListModeller, f func(T))
EachList calls f for each item in the list.
func ForwardTyping ¶
func ForwardTyping(w, dst gtk.Widgetter)
ForwardTyping forwards all typing events from w to dst.
func ForwardTypingFunc ¶
func ForwardTypingFunc(w gtk.Widgetter, f func() gtk.Widgetter)
func IdleCtx ¶
IdleCtx runs the given callback inside the main loop only if the context has not expired.
func InvokeMain ¶
func InvokeMain(f func())
InvokeMain invokes f in the main loop. It is useful in global helper functions where it's unclear where the caller will invoke it from, but it should be used carefully, since it's easy to be abused.
func IsCancelled ¶
func IsCancelled(cancellable Cancellable) bool
IsCancelled returns true if the cancellable is cancelled.
func MenuPair ¶
func MenuPair(pairs [][2]string) *gio.Menu
MenuPair creates a gtk.Menu out of the given menu pair. The returned Menu instance satisfies gio.MenuModeller. The first value of a pair should be the name.
func MustUnmarshalBuilder ¶
func MustUnmarshalBuilder(v any, builder *gtk.Builder)
MustUnmarshalBuilder calls UnmarshalBuilder and panics on any error.
func NewCustomMenuItem ¶
func NewDragSourceWithContent ¶
func NewDragSourceWithContent(w gtk.Widgetter, a gdk.DragAction, v interface{}) *gtk.DragSource
NewDragSourceWithContent creates a new DragSource with the given Go value.
func NewJSONVariant ¶
func NewJSONVariant(v interface{}) *glib.Variant
NewJSONVariant creates a new GVariant instance from any Go value that can be encoded into JSON. If the value cannot be encoded, then the function panics.
func NewKeybinds ¶
NewKeybinds binds all accelerators given in the map with their respective functions to the returned EventControllerKey. If any of the accelerators are invalid, then the function panics.
func NewListDropTarget ¶
NewListDropTarget creates a new DropTarget that highlights the row.
func NewPopoverMenu ¶
func NewPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string) *gtk.PopoverMenu
NewPopoverMenu creates a new Popover menu.
func NewPopoverMenuCustom ¶
func NewPopoverMenuCustom( w gtk.Widgetter, pos gtk.PositionType, items []PopoverMenuItem) *gtk.PopoverMenu
NewPopoverMenuCustom creates a new Popover containing the given items.
func NewPopoverMenuFromPairs ¶
func NewPopoverMenuFromPairs(pairs [][2]string) *gtk.PopoverMenu
NewPopoverMenuFromPairs is a convenient function for NewPopoverMenuFromModel and MenuPairs.
func NewRadioButtons ¶
NewRadioButtons creates a new box of radio buttons.
func NotifyProperty ¶
NotifyProperty calls f everytime the object's property changes until it returns true.
func OnFirstDraw ¶
func OnFirstDraw(w gtk.Widgetter, f func())
OnFirstDraw attaches f to be called on the first time the widget is drawn on the screen.
func OnFirstDrawUntil ¶
func OnFirstDrawUntil(w gtk.Widgetter, f func() bool)
OnFirstDrawUntil attaches f to be called on the first time the widget is drawn on the screen. f is called again until it returns false.
func OnFirstMap ¶
func OnFirstMap(w gtk.Widgetter, f func())
OnFirstMap attaches f to be called on the first time the widget is mapped on the screen.
func PopupFinally ¶
func PopupFinally(p Popupper)
PopupFinally pops up the Popover and schedules it to destroy itself when it's closed.
func RecursiveUnfuck ¶
func RecursiveUnfuck(w gtk.Widgetter)
RecursiveUnfuck calls WipeAllClosures on the widget tree.
func RemoveChildren ¶
func RemoveChildren(w gtk.Widgetter)
RemoveChildren removes all children from w.
func RowAtY ¶
func RowAtY(list *gtk.ListBox, y float64) (*gtk.ListBoxRow, gtk.PositionType)
RowAtY returns the row as well as the position type (top or bottom) relative to that row.
func ScaleFactor ¶
func ScaleFactor() int
ScaleFactor returns the largest scale factor from all the displays. It is thread-safe.
func SetScaleFactor ¶
func SetScaleFactor(maxScale int)
SetScaleFactor sets the global maximum scale factor. This function is useful of GDK fails to update the scale factor in time.
func ShowPopoverMenu ¶
func ShowPopoverMenu(w gtk.Widgetter, pos gtk.PositionType, pairs [][2]string) *gtk.PopoverMenu
ShowPopoverMenu is like ShowPopoverMenuCustom but uses a regular string pair list.
func ShowPopoverMenuCustom ¶
func ShowPopoverMenuCustom(w gtk.Widgetter, pos gtk.PositionType, items []PopoverMenuItem) bool
ShowPopoverMenuCustom is like BindPopoverMenuCustom, but it does not bind a handler. This is useful if the caller does not want pairs to be in memory all the time. If any of the menus cannot be added in, then false is returned, and the popover isn't shown.
func SignalToggler ¶
SignalToggler is a small helper to allow binding the same signal to different objects while unbinding the previous one.
func UnmarshalBuilder ¶
UnmarshalBuilder unmarshals the given gtk.Builder instance into the given struct pointer dst. It uses the `name` struct tag to query for objects in the builder. A missing object is an error. An object with mismatching type is an error.
Below is a minimal example of this function:
var built struct { Window *gtk.Window `name:"window"` Close *gtk.Button `name:"close"` } builder := gtk.NewBuilderFromString(windowUI, -1) err := UnmarshalBuilder(&built, builder)
func WalkWidget ¶
func WalkWidget(w gtk.Widgetter, f func(w gtk.Widgetter) bool)
WalkWidget walks w and its children recursively down the widget tree.
Types ¶
type ActionCallback ¶
type ActionCallback struct { Func func(*glib.Variant) ArgType *glib.VariantType }
ActionCallback is a type holding a callback with a GVariant argument and a GVariantType field describing its internal structure.
func NewJSONActionCallback ¶
func NewJSONActionCallback(f interface{}) ActionCallback
NewJSONActionCallback creates a new ActionCallback that uses JSON to marshal and unmarshal data.
type ActionData ¶
type ActionData struct { Name string Func func() }
ActionData describes a CallbackAction's data.
type CallbackAction ¶
type CallbackAction struct {
*gio.SimpleAction
}
CallbackAction extends SimpleAction to provide idiomatic callback APIs.
func ActionFunc ¶
func ActionFunc(name string, f func()) *CallbackAction
ActionFunc creates a CallbackActionFunc from a function.
func NewCallbackAction ¶
func NewCallbackAction(name string) *CallbackAction
NewCallbackAction creates a new CallbackAction.
func NewCallbackActionParam ¶
func NewCallbackActionParam(name string, paramType *glib.VariantType) *CallbackAction
NewCallbackActionParam creates a new CallbackAction with a single parameter.
func (*CallbackAction) OnActivate ¶
func (a *CallbackAction) OnActivate(f interface{})
OnActivate binds the given function callback to be called when the action is activated.
type Cancellable ¶
type Cancellable interface { // Take returns the current context. This is useful for dropping this // context into a background task. Take() context.Context // OnRenew adds a function to be called once the context is renewed. If the // callback returns a non-nil function, then that function is called once // the context is cancelled. OnRenew(func(context.Context) (undo func())) (remove func()) }
Cancellable describes a renewable and cancelable context. It is primarily used to box a context inside a widget for convenience.
type Canceller ¶
type Canceller interface { Cancellable // Renew cancels the previous context, if any, and restarts that context // using the one given into WithCanceller. Renew() // Cancel cancels the canceler. If the canceler is a zero-value, then this // method does nothing. Cancel() }
Canceller extends Cancellable to allow the user to control the context.
func WithCanceller ¶
WithCanceller wraps around a context.
func WithVisibility ¶
WithVisibility creates a new context that is canceled when the widget is hidden.
type PopoverMenuItem ¶
type PopoverMenuItem interface {
// contains filtered or unexported methods
}
PopoverMenuItem defines a popover menu item constructed from one of the constructors.
func MenuItem ¶
func MenuItem(label locale.Localized, action string, ands ...bool) PopoverMenuItem
MenuItem creates a simple popover menu item. If action is empty, then the item is disabled; if action is "---", then a new section is created.
func MenuItemIcon ¶
func MenuItemIcon(label locale.Localized, action, icon string) PopoverMenuItem
MenuItemIcon is an icon variant of MenuItem.
func MenuSeparator ¶
func MenuSeparator(label locale.Localized) PopoverMenuItem
MenuSeparator creates a new menu separator.
func MenuWidget ¶
func MenuWidget(action string, w gtk.Widgetter) PopoverMenuItem
MenuWidget creates a new menu item that contains a widget.
func Submenu ¶
func Submenu(label locale.Localized, sub []PopoverMenuItem) PopoverMenuItem
Submenu creates a popover menu item that is a submenu.
Directories ¶
Path | Synopsis |
---|---|
Package aggressivegc enforces a GC every minute.
|
Package aggressivegc enforces a GC every minute. |
Package textutil contains utilities for handling Pango markup and TextBuffer shenanigans.
|
Package textutil contains utilities for handling Pango markup and TextBuffer shenanigans. |