1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8 "github.com/bnema/puregotk/v4/glib"
9 "github.com/bnema/puregotk/v4/gobject"
10 "github.com/bnema/puregotk/v4/gobject/types"
11)
12
13// A `GPropertyAction` is a way to get a [iface@Gio.Action] with a state value
14// reflecting and controlling the value of a [class@GObject.Object] property.
15//
16// The state of the action will correspond to the value of the property.
17// Changing it will change the property (assuming the requested value
18// matches the requirements as specified in the [type@GObject.ParamSpec]).
19//
20// Only the most common types are presently supported. Booleans are
21// mapped to booleans, strings to strings, signed/unsigned integers to
22// int32/uint32 and floats and doubles to doubles.
23//
24// If the property is an enum then the state will be string-typed and
25// conversion will automatically be performed between the enum value and
26// ‘nick’ string as per the [type@GObject.EnumValue] table.
27//
28// Flags types are not currently supported.
29//
30// Properties of object types, boxed types and pointer types are not
31// supported and probably never will be.
32//
33// Properties of [type@GLib.Variant] types are not currently supported.
34//
35// If the property is boolean-valued then the action will have a `NULL`
36// parameter type, and activating the action (with no parameter) will
37// toggle the value of the property.
38//
39// In all other cases, the parameter type will correspond to the type of
40// the property.
41//
42// The general idea here is to reduce the number of locations where a
43// particular piece of state is kept (and therefore has to be synchronised
44// between). `GPropertyAction` does not have a separate state that is kept
45// in sync with the property value — its state is the property value.
46//
47// For example, it might be useful to create a [iface@Gio.Action] corresponding
48// to the `visible-child-name` property of a [`GtkStack`](https://docs.gtk.org/gtk4/class.Stack.html)
49// so that the current page can be switched from a menu. The active radio
50// indication in the menu is then directly determined from the active page of
51// the `GtkStack`.
52//
53// An anti-example would be binding the `active-id` property on a
54// [`GtkComboBox`](https://docs.gtk.org/gtk4/class.ComboBox.html). This is
55// because the state of the combo box itself is probably uninteresting and is
56// actually being used to control something else.
57//
58// Another anti-example would be to bind to the `visible-child-name`
59// property of a [`GtkStack`](https://docs.gtk.org/gtk4/class.Stack.html) if
60// this value is actually stored in [class@Gio.Settings]. In that case, the
61// real source of the value is* [class@Gio.Settings]. If you want
62// a [iface@Gio.Action] to control a setting stored in [class@Gio.Settings],
63// see [method@Gio.Settings.create_action] instead, and possibly combine its
64// use with [method@Gio.Settings.bind].
65type PropertyAction struct {
66 gobject.Object
67}
68
69var xPropertyActionGLibType func() types.GType
70
71func PropertyActionGLibType() types.GType {
72 return xPropertyActionGLibType()
73}
74
75func PropertyActionNewFromInternalPtr(ptr uintptr) *PropertyAction {
76 cls := &PropertyAction{}
77 cls.Ptr = ptr
78 return cls
79}
80
81var xNewPropertyAction func(string, uintptr, string) uintptr
82
83// Creates a #GAction corresponding to the value of property
84// @property_name on @object.
85//
86// The property must be existent and readable and writable (and not
87// construct-only).
88//
89// This function takes a reference on @object and doesn't release it
90// until the action is destroyed.
91func NewPropertyAction(NameVar string, ObjectVar *gobject.Object, PropertyNameVar string) *PropertyAction {
92 var cls *PropertyAction
93
94 cret := xNewPropertyAction(NameVar, ObjectVar.GoPointer(), PropertyNameVar)
95
96 if cret == 0 {
97 return nil
98 }
99 cls = &PropertyAction{}
100 cls.Ptr = cret
101 return cls
102}
103
104func (c *PropertyAction) GoPointer() uintptr {
105 if c == nil {
106 return 0
107 }
108 return c.Ptr
109}
110
111func (c *PropertyAction) SetGoPointer(ptr uintptr) {
112 c.Ptr = ptr
113}
114
115// GetPropertyEnabled gets the "enabled" property.
116// If @action is currently enabled.
117//
118// If the action is disabled then calls to g_action_activate() and
119// g_action_change_state() have no effect.
120func (x *PropertyAction) GetPropertyEnabled() bool {
121 var v gobject.Value
122 x.GetProperty("enabled", &v)
123 return v.GetBoolean()
124}
125
126// SetPropertyInvertBoolean sets the "invert-boolean" property.
127// If %TRUE, the state of the action will be the negation of the
128// property value, provided the property is boolean.
129func (x *PropertyAction) SetPropertyInvertBoolean(value bool) {
130 var v gobject.Value
131 v.Init(gobject.TypeBooleanVal)
132 v.SetBoolean(value)
133 x.SetProperty("invert-boolean", &v)
134}
135
136// GetPropertyInvertBoolean gets the "invert-boolean" property.
137// If %TRUE, the state of the action will be the negation of the
138// property value, provided the property is boolean.
139func (x *PropertyAction) GetPropertyInvertBoolean() bool {
140 var v gobject.Value
141 x.GetProperty("invert-boolean", &v)
142 return v.GetBoolean()
143}
144
145// SetPropertyName sets the "name" property.
146// The name of the action. This is mostly meaningful for identifying
147// the action once it has been added to a #GActionMap.
148func (x *PropertyAction) SetPropertyName(value string) {
149 var v gobject.Value
150 v.Init(gobject.TypeStringVal)
151 v.SetString(&value)
152 x.SetProperty("name", &v)
153}
154
155// GetPropertyName gets the "name" property.
156// The name of the action. This is mostly meaningful for identifying
157// the action once it has been added to a #GActionMap.
158func (x *PropertyAction) GetPropertyName() string {
159 var v gobject.Value
160 x.GetProperty("name", &v)
161 return v.GetString()
162}
163
164// GetPropertyParameterType gets the "parameter-type" property.
165// The type of the parameter that must be given when activating the
166// action.
167func (x *PropertyAction) GetPropertyParameterType() uintptr {
168 var v gobject.Value
169 x.GetProperty("parameter-type", &v)
170 return v.GetPointer()
171}
172
173// SetPropertyPropertyName sets the "property-name" property.
174// The name of the property to wrap on the object.
175//
176// The property must exist on the passed-in object and it must be
177// readable and writable (and not construct-only).
178func (x *PropertyAction) SetPropertyPropertyName(value string) {
179 var v gobject.Value
180 v.Init(gobject.TypeStringVal)
181 v.SetString(&value)
182 x.SetProperty("property-name", &v)
183}
184
185// GetPropertyState gets the "state" property.
186// The state of the action, or %NULL if the action is stateless.
187func (x *PropertyAction) GetPropertyState() uintptr {
188 var v gobject.Value
189 x.GetProperty("state", &v)
190 return v.GetPointer()
191}
192
193// GetPropertyStateType gets the "state-type" property.
194// The #GVariantType of the state that the action has, or %NULL if the
195// action is stateless.
196func (x *PropertyAction) GetPropertyStateType() uintptr {
197 var v gobject.Value
198 x.GetProperty("state-type", &v)
199 return v.GetPointer()
200}
201
202// Activates the action.
203//
204// @parameter must be the correct type of parameter for the action (ie:
205// the parameter type given at construction time). If the parameter
206// type was `NULL` then @parameter must also be `NULL`.
207//
208// If the @parameter [type@GLib.Variant] is floating, it is consumed.
209func (x *PropertyAction) Activate(ParameterVar *glib.Variant) {
210
211 XGActionActivate(x.GoPointer(), ParameterVar)
212
213}
214
215// Request for the state of @action to be changed to @value.
216//
217// The action must be stateful and @value must be of the correct type.
218// See [method@Gio.Action.get_state_type].
219//
220// This call merely requests a change. The action may refuse to change
221// its state or may change its state to something other than @value.
222// See [method@Gio.Action.get_state_hint].
223//
224// If the @value [type@GLib.Variant] is floating, it is consumed.
225func (x *PropertyAction) ChangeState(ValueVar *glib.Variant) {
226
227 XGActionChangeState(x.GoPointer(), ValueVar)
228
229}
230
231// Checks if @action is currently enabled.
232//
233// An action must be enabled in order to be activated or in order to
234// have its state changed from outside callers.
235func (x *PropertyAction) GetEnabled() bool {
236
237 cret := XGActionGetEnabled(x.GoPointer())
238 return cret
239}
240
241// Queries the name of @action.
242func (x *PropertyAction) GetName() string {
243
244 cret := XGActionGetName(x.GoPointer())
245 return cret
246}
247
248// Queries the type of the parameter that must be given when activating
249// @action.
250//
251// When activating the action using [method@Gio.Action.activate], the
252// [type@GLib.Variant] given to that function must be of the type returned by
253// this function.
254//
255// In the case that this function returns `NULL`, you must not give any
256// [type@GLib.Variant], but `NULL` instead.
257func (x *PropertyAction) GetParameterType() *glib.VariantType {
258
259 cret := XGActionGetParameterType(x.GoPointer())
260 return cret
261}
262
263// Queries the current state of @action.
264//
265// If the action is not stateful then `NULL` will be returned. If the
266// action is stateful then the type of the return value is the type
267// given by [method@Gio.Action.get_state_type].
268//
269// The return value (if non-`NULL`) should be freed with
270// [method@GLib.Variant.unref] when it is no longer required.
271func (x *PropertyAction) GetState() *glib.Variant {
272
273 cret := XGActionGetState(x.GoPointer())
274 return cret
275}
276
277// Requests a hint about the valid range of values for the state of
278// @action.
279//
280// If `NULL` is returned it either means that the action is not stateful
281// or that there is no hint about the valid range of values for the
282// state of the action.
283//
284// If a [type@GLib.Variant] array is returned then each item in the array is a
285// possible value for the state. If a [type@GLib.Variant] pair (ie: two-tuple) is
286// returned then the tuple specifies the inclusive lower and upper bound
287// of valid values for the state.
288//
289// In any case, the information is merely a hint. It may be possible to
290// have a state value outside of the hinted range and setting a value
291// within the range may fail.
292//
293// The return value (if non-`NULL`) should be freed with
294// [method@GLib.Variant.unref] when it is no longer required.
295func (x *PropertyAction) GetStateHint() *glib.Variant {
296
297 cret := XGActionGetStateHint(x.GoPointer())
298 return cret
299}
300
301// Queries the type of the state of @action.
302//
303// If the action is stateful (e.g. created with
304// [ctor@Gio.SimpleAction.new_stateful]) then this function returns the
305// [type@GLib.VariantType] of the state. This is the type of the initial value
306// given as the state. All calls to [method@Gio.Action.change_state] must give a
307// [type@GLib.Variant] of this type and [method@Gio.Action.get_state] will return a
308// [type@GLib.Variant] of the same type.
309//
310// If the action is not stateful (e.g. created with [ctor@Gio.SimpleAction.new])
311// then this function will return `NULL`. In that case, [method@Gio.Action.get_state]
312// will return `NULL` and you must not call [method@Gio.Action.change_state].
313func (x *PropertyAction) GetStateType() *glib.VariantType {
314
315 cret := XGActionGetStateType(x.GoPointer())
316 return cret
317}
318
319func init() {
320 core.SetPackageName("GIO", "gio-2.0")
321 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
322 var libs []uintptr
323 for _, libPath := range core.GetPaths("GIO") {
324 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
325 if err != nil {
326 panic(err)
327 }
328 libs = append(libs, lib)
329 }
330
331 core.PuregoSafeRegister(&xPropertyActionGLibType, libs, "g_property_action_get_type")
332
333 core.PuregoSafeRegister(&xNewPropertyAction, libs, "g_property_action_new")
334
335}