// Package adw was automatically generated by github.com/bnema/puregotk DO NOT EDIT package adw import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/gtk" ) type ToastClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass } func (x *ToastClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // [class@Toast] behavior when another toast is already displayed. type ToastPriority int var xToastPriorityGLibType func() types.GType func ToastPriorityGLibType() types.GType { return xToastPriorityGLibType() } const ( // the toast will be queued if another toast is // already displayed. ToastPriorityNormalValue ToastPriority = 0 // the toast will be displayed immediately, pushing // the previous toast into the queue instead. ToastPriorityHighValue ToastPriority = 1 ) // A helper object for [class@ToastOverlay]. // // Toasts are meant to be passed into [method@ToastOverlay.add_toast] as // follows: // // ```c // adw_toast_overlay_add_toast (overlay, adw_toast_new (_("Simple Toast"))); // ``` // // <picture> // // <source srcset="toast-simple-dark.png" media="(prefers-color-scheme: dark)"> // <img src="toast-simple.png" alt="toast-simple"> // // </picture> // // Toasts always have a close button. They emit the [signal@Toast::dismissed] // signal when disappearing. // // [property@Toast:timeout] determines how long the toast stays on screen, while // [property@Toast:priority] determines how it behaves if another toast is // already being displayed. // // Toast titles use Pango markup by default, set [property@Toast:use-markup] to // `FALSE` if this is unwanted. // // [property@Toast:custom-title] can be used to replace the title label with a // custom widget. // // ## Actions // // Toasts can have one button on them, with a label and an attached // [iface@Gio.Action]. // // ```c // AdwToast *toast = adw_toast_new (_("Toast with Action")); // // adw_toast_set_button_label (toast, _("_Example")); // adw_toast_set_action_name (toast, "win.example"); // // adw_toast_overlay_add_toast (overlay, toast); // ``` // // <picture> // // <source srcset="toast-action-dark.png" media="(prefers-color-scheme: dark)"> // <img src="toast-action.png" alt="toast-action"> // // </picture> // // ## Modifying toasts // // Toasts can be modified after they have been shown. For this, an `AdwToast` // reference must be kept around while the toast is visible. // // A common use case for this is using toasts as undo prompts that stack with // each other, allowing to batch undo the last deleted items: // // ```c // // static void // toast_undo_cb (GtkWidget *sender, // // const char *action, // GVariant *param) // // { // // Undo the deletion // } // // static void // dismissed_cb (MyWindow *self) // // { // self->undo_toast = NULL; // // // Permanently delete the items // } // // static void // delete_item (MyWindow *self, // // MyItem *item) // // { // g_autofree char *title = NULL; // int n_items; // // // Mark the item as waiting for deletion // n_items = ... // The number of waiting items // // if (!self->undo_toast) { // self->undo_toast = adw_toast_new_format (_("ā€˜%s’ deleted"), ...); // // adw_toast_set_priority (self->undo_toast, ADW_TOAST_PRIORITY_HIGH); // adw_toast_set_button_label (self->undo_toast, _("_Undo")); // adw_toast_set_action_name (self->undo_toast, "toast.undo"); // // g_signal_connect_swapped (self->undo_toast, "dismissed", // G_CALLBACK (dismissed_cb), self); // // adw_toast_overlay_add_toast (self->toast_overlay, self->undo_toast); // // return; // } // // title = // g_strdup_printf (ngettext ("<span font_features='tnum=1'>%d</span> item deleted", // "<span font_features='tnum=1'>%d</span> items deleted", // n_items), n_items); // // adw_toast_set_title (self->undo_toast, title); // // // Bump the toast timeout // adw_toast_overlay_add_toast (self->toast_overlay, g_object_ref (self->undo_toast)); // } // // static void // my_window_class_init (MyWindowClass *klass) // // { // GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); // // gtk_widget_class_install_action (widget_class, "toast.undo", NULL, toast_undo_cb); // } // // ``` // // <picture> // // <source srcset="toast-undo-dark.png" media="(prefers-color-scheme: dark)"> // <img src="toast-undo.png" alt="toast-undo"> // // </picture> type Toast struct { gobject.Object } var xToastGLibType func() types.GType func ToastGLibType() types.GType { return xToastGLibType() } func ToastNewFromInternalPtr(ptr uintptr) *Toast { cls := &Toast{} cls.Ptr = ptr return cls } var xNewToast func(string) uintptr // Creates a new `AdwToast`. // // The toast will use @title as its title. // // @title can be marked up with the Pango text markup language. func NewToast(TitleVar string) *Toast { var cls *Toast cret := xNewToast(TitleVar) if cret == 0 { return nil } cls = &Toast{} cls.Ptr = cret return cls } var xNewToastFormat func(string, ...interface{}) uintptr // Creates a new `AdwToast`. // // The toast will use the format string as its title. // // See also: [ctor@Toast.new] func NewToastFormat(FormatVar string, varArgs ...interface{}) *Toast { var cls *Toast cret := xNewToastFormat(FormatVar, varArgs...) if cret == 0 { return nil } cls = &Toast{} cls.Ptr = cret return cls } var xToastDismiss func(uintptr) // Dismisses @self. // // Does nothing if @self has already been dismissed, or hasn't been added to an // [class@ToastOverlay]. func (x *Toast) Dismiss() { xToastDismiss(x.GoPointer()) } var xToastGetActionName func(uintptr) string // Gets the name of the associated action. func (x *Toast) GetActionName() string { cret := xToastGetActionName(x.GoPointer()) return cret } var xToastGetActionTargetValue func(uintptr) *glib.Variant // Gets the parameter for action invocations. func (x *Toast) GetActionTargetValue() *glib.Variant { cret := xToastGetActionTargetValue(x.GoPointer()) return cret } var xToastGetButtonLabel func(uintptr) string // Gets the label to show on the button. func (x *Toast) GetButtonLabel() string { cret := xToastGetButtonLabel(x.GoPointer()) return cret } var xToastGetCustomTitle func(uintptr) uintptr // Gets the custom title widget of @self. func (x *Toast) GetCustomTitle() *gtk.Widget { var cls *gtk.Widget cret := xToastGetCustomTitle(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = >k.Widget{} cls.Ptr = cret return cls } var xToastGetPriority func(uintptr) ToastPriority // Gets priority for @self. func (x *Toast) GetPriority() ToastPriority { cret := xToastGetPriority(x.GoPointer()) return cret } var xToastGetTimeout func(uintptr) uint // Gets timeout for @self. func (x *Toast) GetTimeout() uint { cret := xToastGetTimeout(x.GoPointer()) return cret } var xToastGetTitle func(uintptr) string // Gets the title that will be displayed on the toast. // // If a custom title has been set with [method@Adw.Toast.set_custom_title] // the return value will be %NULL. func (x *Toast) GetTitle() string { cret := xToastGetTitle(x.GoPointer()) return cret } var xToastGetUseMarkup func(uintptr) bool // Gets whether to use Pango markup for the toast title. func (x *Toast) GetUseMarkup() bool { cret := xToastGetUseMarkup(x.GoPointer()) return cret } var xToastSetActionName func(uintptr, uintptr) // Sets the name of the associated action. // // It will be activated when clicking the button. // // See [property@Toast:action-target]. func (x *Toast) SetActionName(ActionNameVar *string) { ActionNameVarPtr := core.GStrdupNullable(ActionNameVar) defer core.GFreeNullable(ActionNameVarPtr) xToastSetActionName(x.GoPointer(), ActionNameVarPtr) } var xToastSetActionTarget func(uintptr, uintptr, ...interface{}) // Sets the parameter for action invocations. // // This is a convenience function that calls [ctor@GLib.Variant.new] for // @format_string and uses the result to call // [method@Toast.set_action_target_value]. // // If you are setting a string-valued target and want to set // the action name at the same time, you can use // [method@Toast.set_detailed_action_name]. func (x *Toast) SetActionTarget(FormatStringVar *string, varArgs ...interface{}) { FormatStringVarPtr := core.GStrdupNullable(FormatStringVar) defer core.GFreeNullable(FormatStringVarPtr) xToastSetActionTarget(x.GoPointer(), FormatStringVarPtr, varArgs...) } var xToastSetActionTargetValue func(uintptr, *glib.Variant) // Sets the parameter for action invocations. // // If the @action_target variant has a floating reference this function // will sink it. func (x *Toast) SetActionTargetValue(ActionTargetVar *glib.Variant) { xToastSetActionTargetValue(x.GoPointer(), ActionTargetVar) } var xToastSetButtonLabel func(uintptr, uintptr) // Sets the label to show on the button. // // Underlines in the button text can be used to indicate a mnemonic. // // If set to `NULL`, the button won't be shown. // // See [property@Toast:action-name]. func (x *Toast) SetButtonLabel(ButtonLabelVar *string) { ButtonLabelVarPtr := core.GStrdupNullable(ButtonLabelVar) defer core.GFreeNullable(ButtonLabelVarPtr) xToastSetButtonLabel(x.GoPointer(), ButtonLabelVarPtr) } var xToastSetCustomTitle func(uintptr, uintptr) // Sets the custom title widget of @self. // // It will be displayed instead of the title if set. In this case, // [property@Toast:title] is ignored. // // Setting a custom title will unset [property@Toast:title]. func (x *Toast) SetCustomTitle(WidgetVar *gtk.Widget) { xToastSetCustomTitle(x.GoPointer(), WidgetVar.GoPointer()) } var xToastSetDetailedActionName func(uintptr, uintptr) // Sets the action name and its parameter. // // @detailed_action_name is a string in the format accepted by // [func@Gio.Action.parse_detailed_name]. func (x *Toast) SetDetailedActionName(DetailedActionNameVar *string) { DetailedActionNameVarPtr := core.GStrdupNullable(DetailedActionNameVar) defer core.GFreeNullable(DetailedActionNameVarPtr) xToastSetDetailedActionName(x.GoPointer(), DetailedActionNameVarPtr) } var xToastSetPriority func(uintptr, ToastPriority) // Sets priority for @self. // // Priority controls how the toast behaves when another toast is already // being displayed. // // If @priority is `ADW_TOAST_PRIORITY_NORMAL`, the toast will be queued. // // If @priority is `ADW_TOAST_PRIORITY_HIGH`, the toast will be displayed // immediately, pushing the previous toast into the queue instead. func (x *Toast) SetPriority(PriorityVar ToastPriority) { xToastSetPriority(x.GoPointer(), PriorityVar) } var xToastSetTimeout func(uintptr, uint) // Sets timeout for @self. // // If @timeout is 0, the toast is displayed indefinitely until manually // dismissed. // // Toasts cannot disappear while being hovered, pressed (on touchscreen), or // have keyboard focus inside them. func (x *Toast) SetTimeout(TimeoutVar uint) { xToastSetTimeout(x.GoPointer(), TimeoutVar) } var xToastSetTitle func(uintptr, string) // Sets the title that will be displayed on the toast. // // The title can be marked up with the Pango text markup language. // // Setting a title will unset [property@Toast:custom-title]. // // If [property@Toast:custom-title] is set, it will be used instead. func (x *Toast) SetTitle(TitleVar string) { xToastSetTitle(x.GoPointer(), TitleVar) } var xToastSetUseMarkup func(uintptr, bool) // Whether to use Pango markup for the toast title. // // See also [func@Pango.parse_markup]. func (x *Toast) SetUseMarkup(UseMarkupVar bool) { xToastSetUseMarkup(x.GoPointer(), UseMarkupVar) } func (c *Toast) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *Toast) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyActionName sets the "action-name" property. // The name of the associated action. // // It will be activated when clicking the button. // // See [property@Toast:action-target]. func (x *Toast) SetPropertyActionName(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("action-name", &v) } // GetPropertyActionName gets the "action-name" property. // The name of the associated action. // // It will be activated when clicking the button. // // See [property@Toast:action-target]. func (x *Toast) GetPropertyActionName() string { var v gobject.Value x.GetProperty("action-name", &v) return v.GetString() } // SetPropertyActionTarget sets the "action-target" property. // The parameter for action invocations. func (x *Toast) SetPropertyActionTarget(value uintptr) { var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) x.SetProperty("action-target", &v) } // GetPropertyActionTarget gets the "action-target" property. // The parameter for action invocations. func (x *Toast) GetPropertyActionTarget() uintptr { var v gobject.Value x.GetProperty("action-target", &v) return v.GetPointer() } // SetPropertyButtonLabel sets the "button-label" property. // The label to show on the button. // // Underlines in the button text can be used to indicate a mnemonic. // // If set to `NULL`, the button won't be shown. // // See [property@Toast:action-name]. func (x *Toast) SetPropertyButtonLabel(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("button-label", &v) } // GetPropertyButtonLabel gets the "button-label" property. // The label to show on the button. // // Underlines in the button text can be used to indicate a mnemonic. // // If set to `NULL`, the button won't be shown. // // See [property@Toast:action-name]. func (x *Toast) GetPropertyButtonLabel() string { var v gobject.Value x.GetProperty("button-label", &v) return v.GetString() } // SetPropertyTimeout sets the "timeout" property. // The timeout of the toast, in seconds. // // If timeout is 0, the toast is displayed indefinitely until manually // dismissed. // // Toasts cannot disappear while being hovered, pressed (on touchscreen), or // have keyboard focus inside them. func (x *Toast) SetPropertyTimeout(value uint) { var v gobject.Value v.Init(gobject.TypeUintVal) v.SetUint(value) x.SetProperty("timeout", &v) } // GetPropertyTimeout gets the "timeout" property. // The timeout of the toast, in seconds. // // If timeout is 0, the toast is displayed indefinitely until manually // dismissed. // // Toasts cannot disappear while being hovered, pressed (on touchscreen), or // have keyboard focus inside them. func (x *Toast) GetPropertyTimeout() uint { var v gobject.Value x.GetProperty("timeout", &v) return v.GetUint() } // SetPropertyTitle sets the "title" property. // The title of the toast. // // The title can be marked up with the Pango text markup language. // // Setting a title will unset [property@Toast:custom-title]. // // If [property@Toast:custom-title] is set, it will be used instead. func (x *Toast) SetPropertyTitle(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("title", &v) } // GetPropertyTitle gets the "title" property. // The title of the toast. // // The title can be marked up with the Pango text markup language. // // Setting a title will unset [property@Toast:custom-title]. // // If [property@Toast:custom-title] is set, it will be used instead. func (x *Toast) GetPropertyTitle() string { var v gobject.Value x.GetProperty("title", &v) return v.GetString() } // SetPropertyUseMarkup sets the "use-markup" property. // Whether to use Pango markup for the toast title. // // See also [func@Pango.parse_markup]. func (x *Toast) SetPropertyUseMarkup(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("use-markup", &v) } // GetPropertyUseMarkup gets the "use-markup" property. // Whether to use Pango markup for the toast title. // // See also [func@Pango.parse_markup]. func (x *Toast) GetPropertyUseMarkup() bool { var v gobject.Value x.GetProperty("use-markup", &v) return v.GetBoolean() } // Emitted after the button has been clicked. // // It can be used as an alternative to setting an action. func (x *Toast) ConnectButtonClicked(cb *func(Toast)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := Toast{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted when the toast has been dismissed. func (x *Toast) ConnectDismissed(cb *func(Toast)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "dismissed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := Toast{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "dismissed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } func init() { core.SetPackageName("ADW", "libadwaita-1") core.SetSharedLibraries("ADW", []string{"libadwaita-1.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("ADW") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xToastPriorityGLibType, libs, "adw_toast_priority_get_type") core.PuregoSafeRegister(&xToastGLibType, libs, "adw_toast_get_type") core.PuregoSafeRegister(&xNewToast, libs, "adw_toast_new") core.PuregoSafeRegister(&xNewToastFormat, libs, "adw_toast_new_format") core.PuregoSafeRegister(&xToastDismiss, libs, "adw_toast_dismiss") core.PuregoSafeRegister(&xToastGetActionName, libs, "adw_toast_get_action_name") core.PuregoSafeRegister(&xToastGetActionTargetValue, libs, "adw_toast_get_action_target_value") core.PuregoSafeRegister(&xToastGetButtonLabel, libs, "adw_toast_get_button_label") core.PuregoSafeRegister(&xToastGetCustomTitle, libs, "adw_toast_get_custom_title") core.PuregoSafeRegister(&xToastGetPriority, libs, "adw_toast_get_priority") core.PuregoSafeRegister(&xToastGetTimeout, libs, "adw_toast_get_timeout") core.PuregoSafeRegister(&xToastGetTitle, libs, "adw_toast_get_title") core.PuregoSafeRegister(&xToastGetUseMarkup, libs, "adw_toast_get_use_markup") core.PuregoSafeRegister(&xToastSetActionName, libs, "adw_toast_set_action_name") core.PuregoSafeRegister(&xToastSetActionTarget, libs, "adw_toast_set_action_target") core.PuregoSafeRegister(&xToastSetActionTargetValue, libs, "adw_toast_set_action_target_value") core.PuregoSafeRegister(&xToastSetButtonLabel, libs, "adw_toast_set_button_label") core.PuregoSafeRegister(&xToastSetCustomTitle, libs, "adw_toast_set_custom_title") core.PuregoSafeRegister(&xToastSetDetailedActionName, libs, "adw_toast_set_detailed_action_name") core.PuregoSafeRegister(&xToastSetPriority, libs, "adw_toast_set_priority") core.PuregoSafeRegister(&xToastSetTimeout, libs, "adw_toast_set_timeout") core.PuregoSafeRegister(&xToastSetTitle, libs, "adw_toast_set_title") core.PuregoSafeRegister(&xToastSetUseMarkup, libs, "adw_toast_set_use_markup") }