// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk 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" ) // The interface vtable for `GtkActionable`. type ActionableInterface struct { _ structs.HostLayout GIface uintptr xGetActionName uintptr xSetActionName uintptr xGetActionTargetValue uintptr xSetActionTargetValue uintptr } func (x *ActionableInterface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideGetActionName sets the "get_action_name" callback function. // virtual function for [method@Actionable.get_action_name] func (x *ActionableInterface) OverrideGetActionName(cb func(Actionable) string) { if cb == nil { x.xGetActionName = 0 } else { x.xGetActionName = purego.NewCallback(func(ActionableVarp uintptr) string { return cb(&ActionableBase{Ptr: ActionableVarp}) }) } } // GetGetActionName gets the "get_action_name" callback function. // virtual function for [method@Actionable.get_action_name] func (x *ActionableInterface) GetGetActionName() func(Actionable) string { if x.xGetActionName == 0 { return nil } var rawCallback func(ActionableVarp uintptr) string purego.RegisterFunc(&rawCallback, x.xGetActionName) return func(ActionableVar Actionable) string { return rawCallback(ActionableVar.GoPointer()) } } // OverrideSetActionName sets the "set_action_name" callback function. // virtual function for [method@Actionable.set_action_name] func (x *ActionableInterface) OverrideSetActionName(cb func(Actionable, string)) { if cb == nil { x.xSetActionName = 0 } else { x.xSetActionName = purego.NewCallback(func(ActionableVarp uintptr, ActionNameVarp string) { cb(&ActionableBase{Ptr: ActionableVarp}, ActionNameVarp) }) } } // GetSetActionName gets the "set_action_name" callback function. // virtual function for [method@Actionable.set_action_name] func (x *ActionableInterface) GetSetActionName() func(Actionable, string) { if x.xSetActionName == 0 { return nil } var rawCallback func(ActionableVarp uintptr, ActionNameVarp string) purego.RegisterFunc(&rawCallback, x.xSetActionName) return func(ActionableVar Actionable, ActionNameVar string) { rawCallback(ActionableVar.GoPointer(), ActionNameVar) } } // OverrideGetActionTargetValue sets the "get_action_target_value" callback function. // virtual function for [method@Actionable.get_action_target_value] func (x *ActionableInterface) OverrideGetActionTargetValue(cb func(Actionable) *glib.Variant) { if cb == nil { x.xGetActionTargetValue = 0 } else { x.xGetActionTargetValue = purego.NewCallback(func(ActionableVarp uintptr) *glib.Variant { return cb(&ActionableBase{Ptr: ActionableVarp}) }) } } // GetGetActionTargetValue gets the "get_action_target_value" callback function. // virtual function for [method@Actionable.get_action_target_value] func (x *ActionableInterface) GetGetActionTargetValue() func(Actionable) *glib.Variant { if x.xGetActionTargetValue == 0 { return nil } var rawCallback func(ActionableVarp uintptr) *glib.Variant purego.RegisterFunc(&rawCallback, x.xGetActionTargetValue) return func(ActionableVar Actionable) *glib.Variant { return rawCallback(ActionableVar.GoPointer()) } } // OverrideSetActionTargetValue sets the "set_action_target_value" callback function. // virtual function for [method@Actionable.set_action_target_value] func (x *ActionableInterface) OverrideSetActionTargetValue(cb func(Actionable, *glib.Variant)) { if cb == nil { x.xSetActionTargetValue = 0 } else { x.xSetActionTargetValue = purego.NewCallback(func(ActionableVarp uintptr, TargetValueVarp *glib.Variant) { cb(&ActionableBase{Ptr: ActionableVarp}, TargetValueVarp) }) } } // GetSetActionTargetValue gets the "set_action_target_value" callback function. // virtual function for [method@Actionable.set_action_target_value] func (x *ActionableInterface) GetSetActionTargetValue() func(Actionable, *glib.Variant) { if x.xSetActionTargetValue == 0 { return nil } var rawCallback func(ActionableVarp uintptr, TargetValueVarp *glib.Variant) purego.RegisterFunc(&rawCallback, x.xSetActionTargetValue) return func(ActionableVar Actionable, TargetValueVar *glib.Variant) { rawCallback(ActionableVar.GoPointer(), TargetValueVar) } } // Provides a way to associate widgets with actions. // // It primarily consists of two properties: [property@Gtk.Actionable:action-name] // and [property@Gtk.Actionable:action-target]. There are also some convenience // APIs for setting these properties. // // The action will be looked up in action groups that are found among // the widgets ancestors. Most commonly, these will be the actions with // the “win.” or “app.” prefix that are associated with the // `GtkApplicationWindow` or `GtkApplication`, but other action groups that // are added with [method@Gtk.Widget.insert_action_group] will be consulted // as well. type Actionable interface { GoPointer() uintptr SetGoPointer(uintptr) GetActionName() string GetActionTargetValue() *glib.Variant SetActionName(ActionNameVar *string) SetActionTarget(FormatStringVar string, varArgs ...interface{}) SetActionTargetValue(TargetValueVar *glib.Variant) SetDetailedActionName(DetailedActionNameVar string) } var xActionableGLibType func() types.GType func ActionableGLibType() types.GType { return xActionableGLibType() } type ActionableBase struct { Ptr uintptr } func (x *ActionableBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *ActionableBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Gets the action name for @actionable. func (x *ActionableBase) GetActionName() string { cret := XGtkActionableGetActionName(x.GoPointer()) return cret } // Gets the current target value of @actionable. func (x *ActionableBase) GetActionTargetValue() *glib.Variant { cret := XGtkActionableGetActionTargetValue(x.GoPointer()) return cret } // Specifies the name of the action with which this widget should be // associated. // // If @action_name is %NULL then the widget will be unassociated from // any previous action. // // Usually this function is used when the widget is located (or will be // located) within the hierarchy of a `GtkApplicationWindow`. // // Names are of the form “win.save” or “app.quit” for actions on the // containing [class@ApplicationWindow] or its associated [class@Application], // respectively. This is the same form used for actions in the [class@Gio.Menu] // associated with the window. func (x *ActionableBase) SetActionName(ActionNameVar *string) { ActionNameVarPtr := core.GStrdupNullable(ActionNameVar) defer core.GFreeNullable(ActionNameVarPtr) XGtkActionableSetActionName(x.GoPointer(), ActionNameVarPtr) } // Sets the target of an actionable widget. // // This is a convenience function that calls [ctor@GLib.Variant.new] for // @format_string and uses the result to call // [method@Gtk.Actionable.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@Gtk.Actionable.set_detailed_action_name]. func (x *ActionableBase) SetActionTarget(FormatStringVar string, varArgs ...interface{}) { XGtkActionableSetActionTarget(x.GoPointer(), FormatStringVar, varArgs...) } // Sets the target value of an actionable widget. // // If @target_value is %NULL then the target value is unset. // // The target value has two purposes. First, it is used as the parameter // to activation of the action associated with the `GtkActionable` widget. // Second, it is used to determine if the widget should be rendered as // “active” — the widget is active if the state is equal to the given target. // // Consider the example of associating a set of buttons with a [iface@Gio.Action] // with string state in a typical “radio button” situation. Each button // will be associated with the same action, but with a different target // value for that action. Clicking on a particular button will activate // the action with the target of that button, which will typically cause // the action’s state to change to that value. Since the action’s state // is now equal to the target value of the button, the button will now // be rendered as active (and the other buttons, with different targets, // rendered inactive). func (x *ActionableBase) SetActionTargetValue(TargetValueVar *glib.Variant) { XGtkActionableSetActionTargetValue(x.GoPointer(), TargetValueVar) } // Sets the action-name and associated string target value of an // actionable widget. // // @detailed_action_name is a string in the format accepted by // [func@Gio.Action.parse_detailed_name]. func (x *ActionableBase) SetDetailedActionName(DetailedActionNameVar string) { XGtkActionableSetDetailedActionName(x.GoPointer(), DetailedActionNameVar) } // SetPropertyActionName sets the "action-name" property. // The name of the action with which this widget should be associated. func (x *ActionableBase) SetPropertyActionName(value string) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) obj.SetProperty("action-name", &v) } // GetPropertyActionName gets the "action-name" property. // The name of the action with which this widget should be associated. func (x *ActionableBase) GetPropertyActionName() string { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("action-name", &v) return v.GetString() } // SetPropertyActionTarget sets the "action-target" property. // The target value of the actionable widget's action. func (x *ActionableBase) SetPropertyActionTarget(value uintptr) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) obj.SetProperty("action-target", &v) } // GetPropertyActionTarget gets the "action-target" property. // The target value of the actionable widget's action. func (x *ActionableBase) GetPropertyActionTarget() uintptr { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("action-target", &v) return v.GetPointer() } var XGtkActionableGetActionName func(uintptr) string var XGtkActionableGetActionTargetValue func(uintptr) *glib.Variant var XGtkActionableSetActionName func(uintptr, uintptr) var XGtkActionableSetActionTarget func(uintptr, string, ...interface{}) var XGtkActionableSetActionTargetValue func(uintptr, *glib.Variant) var XGtkActionableSetDetailedActionName func(uintptr, string) func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xActionableGLibType, libs, "gtk_actionable_get_type") core.PuregoSafeRegister(&XGtkActionableGetActionName, libs, "gtk_actionable_get_action_name") core.PuregoSafeRegister(&XGtkActionableGetActionTargetValue, libs, "gtk_actionable_get_action_target_value") core.PuregoSafeRegister(&XGtkActionableSetActionName, libs, "gtk_actionable_set_action_name") core.PuregoSafeRegister(&XGtkActionableSetActionTarget, libs, "gtk_actionable_set_action_target") core.PuregoSafeRegister(&XGtkActionableSetActionTargetValue, libs, "gtk_actionable_set_action_target_value") core.PuregoSafeRegister(&XGtkActionableSetDetailedActionName, libs, "gtk_actionable_set_detailed_action_name") }