1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The virtual function table for [type@Gio.Action].
17type ActionInterface struct {
18 _ structs.HostLayout
19
20 GIface uintptr
21
22 xGetName uintptr
23
24 xGetParameterType uintptr
25
26 xGetStateType uintptr
27
28 xGetStateHint uintptr
29
30 xGetEnabled uintptr
31
32 xGetState uintptr
33
34 xChangeState uintptr
35
36 xActivate uintptr
37}
38
39func (x *ActionInterface) GoPointer() uintptr {
40 return uintptr(unsafe.Pointer(x))
41}
42
43// OverrideGetName sets the "get_name" callback function.
44// the virtual function pointer for [method@Gio.Action.get_name]
45func (x *ActionInterface) OverrideGetName(cb func(Action) string) {
46 if cb == nil {
47 x.xGetName = 0
48 } else {
49 x.xGetName = purego.NewCallback(func(ActionVarp uintptr) string {
50 return cb(&ActionBase{Ptr: ActionVarp})
51 })
52 }
53}
54
55// GetGetName gets the "get_name" callback function.
56// the virtual function pointer for [method@Gio.Action.get_name]
57func (x *ActionInterface) GetGetName() func(Action) string {
58 if x.xGetName == 0 {
59 return nil
60 }
61 var rawCallback func(ActionVarp uintptr) string
62 purego.RegisterFunc(&rawCallback, x.xGetName)
63 return func(ActionVar Action) string {
64 return rawCallback(ActionVar.GoPointer())
65 }
66}
67
68// OverrideGetParameterType sets the "get_parameter_type" callback function.
69// the virtual function pointer for [method@Gio.Action.get_parameter_type]
70func (x *ActionInterface) OverrideGetParameterType(cb func(Action) *glib.VariantType) {
71 if cb == nil {
72 x.xGetParameterType = 0
73 } else {
74 x.xGetParameterType = purego.NewCallback(func(ActionVarp uintptr) *glib.VariantType {
75 return cb(&ActionBase{Ptr: ActionVarp})
76 })
77 }
78}
79
80// GetGetParameterType gets the "get_parameter_type" callback function.
81// the virtual function pointer for [method@Gio.Action.get_parameter_type]
82func (x *ActionInterface) GetGetParameterType() func(Action) *glib.VariantType {
83 if x.xGetParameterType == 0 {
84 return nil
85 }
86 var rawCallback func(ActionVarp uintptr) *glib.VariantType
87 purego.RegisterFunc(&rawCallback, x.xGetParameterType)
88 return func(ActionVar Action) *glib.VariantType {
89 return rawCallback(ActionVar.GoPointer())
90 }
91}
92
93// OverrideGetStateType sets the "get_state_type" callback function.
94// the virtual function pointer for [method@Gio.Action.get_state_type]
95func (x *ActionInterface) OverrideGetStateType(cb func(Action) *glib.VariantType) {
96 if cb == nil {
97 x.xGetStateType = 0
98 } else {
99 x.xGetStateType = purego.NewCallback(func(ActionVarp uintptr) *glib.VariantType {
100 return cb(&ActionBase{Ptr: ActionVarp})
101 })
102 }
103}
104
105// GetGetStateType gets the "get_state_type" callback function.
106// the virtual function pointer for [method@Gio.Action.get_state_type]
107func (x *ActionInterface) GetGetStateType() func(Action) *glib.VariantType {
108 if x.xGetStateType == 0 {
109 return nil
110 }
111 var rawCallback func(ActionVarp uintptr) *glib.VariantType
112 purego.RegisterFunc(&rawCallback, x.xGetStateType)
113 return func(ActionVar Action) *glib.VariantType {
114 return rawCallback(ActionVar.GoPointer())
115 }
116}
117
118// OverrideGetStateHint sets the "get_state_hint" callback function.
119// the virtual function pointer for [method@Gio.Action.get_state_hint]
120func (x *ActionInterface) OverrideGetStateHint(cb func(Action) *glib.Variant) {
121 if cb == nil {
122 x.xGetStateHint = 0
123 } else {
124 x.xGetStateHint = purego.NewCallback(func(ActionVarp uintptr) *glib.Variant {
125 return cb(&ActionBase{Ptr: ActionVarp})
126 })
127 }
128}
129
130// GetGetStateHint gets the "get_state_hint" callback function.
131// the virtual function pointer for [method@Gio.Action.get_state_hint]
132func (x *ActionInterface) GetGetStateHint() func(Action) *glib.Variant {
133 if x.xGetStateHint == 0 {
134 return nil
135 }
136 var rawCallback func(ActionVarp uintptr) *glib.Variant
137 purego.RegisterFunc(&rawCallback, x.xGetStateHint)
138 return func(ActionVar Action) *glib.Variant {
139 return rawCallback(ActionVar.GoPointer())
140 }
141}
142
143// OverrideGetEnabled sets the "get_enabled" callback function.
144// the virtual function pointer for [method@Gio.Action.get_enabled]
145func (x *ActionInterface) OverrideGetEnabled(cb func(Action) bool) {
146 if cb == nil {
147 x.xGetEnabled = 0
148 } else {
149 x.xGetEnabled = purego.NewCallback(func(ActionVarp uintptr) bool {
150 return cb(&ActionBase{Ptr: ActionVarp})
151 })
152 }
153}
154
155// GetGetEnabled gets the "get_enabled" callback function.
156// the virtual function pointer for [method@Gio.Action.get_enabled]
157func (x *ActionInterface) GetGetEnabled() func(Action) bool {
158 if x.xGetEnabled == 0 {
159 return nil
160 }
161 var rawCallback func(ActionVarp uintptr) bool
162 purego.RegisterFunc(&rawCallback, x.xGetEnabled)
163 return func(ActionVar Action) bool {
164 return rawCallback(ActionVar.GoPointer())
165 }
166}
167
168// OverrideGetState sets the "get_state" callback function.
169// the virtual function pointer for [method@Gio.Action.get_state]
170func (x *ActionInterface) OverrideGetState(cb func(Action) *glib.Variant) {
171 if cb == nil {
172 x.xGetState = 0
173 } else {
174 x.xGetState = purego.NewCallback(func(ActionVarp uintptr) *glib.Variant {
175 return cb(&ActionBase{Ptr: ActionVarp})
176 })
177 }
178}
179
180// GetGetState gets the "get_state" callback function.
181// the virtual function pointer for [method@Gio.Action.get_state]
182func (x *ActionInterface) GetGetState() func(Action) *glib.Variant {
183 if x.xGetState == 0 {
184 return nil
185 }
186 var rawCallback func(ActionVarp uintptr) *glib.Variant
187 purego.RegisterFunc(&rawCallback, x.xGetState)
188 return func(ActionVar Action) *glib.Variant {
189 return rawCallback(ActionVar.GoPointer())
190 }
191}
192
193// OverrideChangeState sets the "change_state" callback function.
194// the virtual function pointer for [method@Gio.Action.change_state]
195func (x *ActionInterface) OverrideChangeState(cb func(Action, *glib.Variant)) {
196 if cb == nil {
197 x.xChangeState = 0
198 } else {
199 x.xChangeState = purego.NewCallback(func(ActionVarp uintptr, ValueVarp *glib.Variant) {
200 cb(&ActionBase{Ptr: ActionVarp}, ValueVarp)
201 })
202 }
203}
204
205// GetChangeState gets the "change_state" callback function.
206// the virtual function pointer for [method@Gio.Action.change_state]
207func (x *ActionInterface) GetChangeState() func(Action, *glib.Variant) {
208 if x.xChangeState == 0 {
209 return nil
210 }
211 var rawCallback func(ActionVarp uintptr, ValueVarp *glib.Variant)
212 purego.RegisterFunc(&rawCallback, x.xChangeState)
213 return func(ActionVar Action, ValueVar *glib.Variant) {
214 rawCallback(ActionVar.GoPointer(), ValueVar)
215 }
216}
217
218// OverrideActivate sets the "activate" callback function.
219// the virtual function pointer for [method@Gio.Action.activate]. Note that [type@Gio.Action] does not have an
220//
221// 'activate' signal but that implementations of it may have one.
222func (x *ActionInterface) OverrideActivate(cb func(Action, *glib.Variant)) {
223 if cb == nil {
224 x.xActivate = 0
225 } else {
226 x.xActivate = purego.NewCallback(func(ActionVarp uintptr, ParameterVarp *glib.Variant) {
227 cb(&ActionBase{Ptr: ActionVarp}, ParameterVarp)
228 })
229 }
230}
231
232// GetActivate gets the "activate" callback function.
233// the virtual function pointer for [method@Gio.Action.activate]. Note that [type@Gio.Action] does not have an
234//
235// 'activate' signal but that implementations of it may have one.
236func (x *ActionInterface) GetActivate() func(Action, *glib.Variant) {
237 if x.xActivate == 0 {
238 return nil
239 }
240 var rawCallback func(ActionVarp uintptr, ParameterVarp *glib.Variant)
241 purego.RegisterFunc(&rawCallback, x.xActivate)
242 return func(ActionVar Action, ParameterVar *glib.Variant) {
243 rawCallback(ActionVar.GoPointer(), ParameterVar)
244 }
245}
246
247// `GAction` represents a single named action.
248//
249// The main interface to an action is that it can be activated with
250// [method@Gio.Action.activate]. This results in the 'activate' signal being
251// emitted. An activation has a `GVariant` parameter (which may be
252// `NULL`). The correct type for the parameter is determined by a static
253// parameter type (which is given at construction time).
254//
255// An action may optionally have a state, in which case the state may be
256// set with [method@Gio.Action.change_state]. This call takes a [type@GLib.Variant]. The
257// correct type for the state is determined by a static state type
258// (which is given at construction time).
259//
260// The state may have a hint associated with it, specifying its valid
261// range.
262//
263// `GAction` is merely the interface to the concept of an action, as
264// described above. Various implementations of actions exist, including
265// [class@Gio.SimpleAction].
266//
267// In all cases, the implementing class is responsible for storing the
268// name of the action, the parameter type, the enabled state, the optional
269// state type and the state and emitting the appropriate signals when these
270// change. The implementor is responsible for filtering calls to
271// [method@Gio.Action.activate] and [method@Gio.Action.change_state]
272// for type safety and for the state being enabled.
273//
274// Probably the only useful thing to do with a `GAction` is to put it
275// inside of a [class@Gio.SimpleActionGroup].
276type Action interface {
277 GoPointer() uintptr
278 SetGoPointer(uintptr)
279 Activate(ParameterVar *glib.Variant)
280 ChangeState(ValueVar *glib.Variant)
281 GetEnabled() bool
282 GetName() string
283 GetParameterType() *glib.VariantType
284 GetState() *glib.Variant
285 GetStateHint() *glib.Variant
286 GetStateType() *glib.VariantType
287}
288
289var xActionGLibType func() types.GType
290
291func ActionGLibType() types.GType {
292 return xActionGLibType()
293}
294
295type ActionBase struct {
296 Ptr uintptr
297}
298
299func (x *ActionBase) GoPointer() uintptr {
300 if x == nil {
301 return 0
302 }
303 return x.Ptr
304}
305
306func (x *ActionBase) SetGoPointer(ptr uintptr) {
307 x.Ptr = ptr
308}
309
310// Activates the action.
311//
312// @parameter must be the correct type of parameter for the action (ie:
313// the parameter type given at construction time). If the parameter
314// type was `NULL` then @parameter must also be `NULL`.
315//
316// If the @parameter [type@GLib.Variant] is floating, it is consumed.
317func (x *ActionBase) Activate(ParameterVar *glib.Variant) {
318
319 XGActionActivate(x.GoPointer(), ParameterVar)
320
321}
322
323// Request for the state of @action to be changed to @value.
324//
325// The action must be stateful and @value must be of the correct type.
326// See [method@Gio.Action.get_state_type].
327//
328// This call merely requests a change. The action may refuse to change
329// its state or may change its state to something other than @value.
330// See [method@Gio.Action.get_state_hint].
331//
332// If the @value [type@GLib.Variant] is floating, it is consumed.
333func (x *ActionBase) ChangeState(ValueVar *glib.Variant) {
334
335 XGActionChangeState(x.GoPointer(), ValueVar)
336
337}
338
339// Checks if @action is currently enabled.
340//
341// An action must be enabled in order to be activated or in order to
342// have its state changed from outside callers.
343func (x *ActionBase) GetEnabled() bool {
344
345 cret := XGActionGetEnabled(x.GoPointer())
346 return cret
347}
348
349// Queries the name of @action.
350func (x *ActionBase) GetName() string {
351
352 cret := XGActionGetName(x.GoPointer())
353 return cret
354}
355
356// Queries the type of the parameter that must be given when activating
357// @action.
358//
359// When activating the action using [method@Gio.Action.activate], the
360// [type@GLib.Variant] given to that function must be of the type returned by
361// this function.
362//
363// In the case that this function returns `NULL`, you must not give any
364// [type@GLib.Variant], but `NULL` instead.
365func (x *ActionBase) GetParameterType() *glib.VariantType {
366
367 cret := XGActionGetParameterType(x.GoPointer())
368 return cret
369}
370
371// Queries the current state of @action.
372//
373// If the action is not stateful then `NULL` will be returned. If the
374// action is stateful then the type of the return value is the type
375// given by [method@Gio.Action.get_state_type].
376//
377// The return value (if non-`NULL`) should be freed with
378// [method@GLib.Variant.unref] when it is no longer required.
379func (x *ActionBase) GetState() *glib.Variant {
380
381 cret := XGActionGetState(x.GoPointer())
382 return cret
383}
384
385// Requests a hint about the valid range of values for the state of
386// @action.
387//
388// If `NULL` is returned it either means that the action is not stateful
389// or that there is no hint about the valid range of values for the
390// state of the action.
391//
392// If a [type@GLib.Variant] array is returned then each item in the array is a
393// possible value for the state. If a [type@GLib.Variant] pair (ie: two-tuple) is
394// returned then the tuple specifies the inclusive lower and upper bound
395// of valid values for the state.
396//
397// In any case, the information is merely a hint. It may be possible to
398// have a state value outside of the hinted range and setting a value
399// within the range may fail.
400//
401// The return value (if non-`NULL`) should be freed with
402// [method@GLib.Variant.unref] when it is no longer required.
403func (x *ActionBase) GetStateHint() *glib.Variant {
404
405 cret := XGActionGetStateHint(x.GoPointer())
406 return cret
407}
408
409// Queries the type of the state of @action.
410//
411// If the action is stateful (e.g. created with
412// [ctor@Gio.SimpleAction.new_stateful]) then this function returns the
413// [type@GLib.VariantType] of the state. This is the type of the initial value
414// given as the state. All calls to [method@Gio.Action.change_state] must give a
415// [type@GLib.Variant] of this type and [method@Gio.Action.get_state] will return a
416// [type@GLib.Variant] of the same type.
417//
418// If the action is not stateful (e.g. created with [ctor@Gio.SimpleAction.new])
419// then this function will return `NULL`. In that case, [method@Gio.Action.get_state]
420// will return `NULL` and you must not call [method@Gio.Action.change_state].
421func (x *ActionBase) GetStateType() *glib.VariantType {
422
423 cret := XGActionGetStateType(x.GoPointer())
424 return cret
425}
426
427// GetPropertyEnabled gets the "enabled" property.
428// If @action is currently enabled.
429//
430// If the action is disabled then calls to [method@Gio.Action.activate] and
431// [method@Gio.Action.change_state] have no effect.
432func (x *ActionBase) GetPropertyEnabled() bool {
433 obj := gobject.Object{}
434 obj.Ptr = x.GoPointer()
435 var v gobject.Value
436 obj.GetProperty("enabled", &v)
437 return v.GetBoolean()
438}
439
440// GetPropertyName gets the "name" property.
441// The name of the action. This is mostly meaningful for identifying
442// the action once it has been added to a [type@Gio.ActionGroup]. It is immutable.
443func (x *ActionBase) GetPropertyName() string {
444 obj := gobject.Object{}
445 obj.Ptr = x.GoPointer()
446 var v gobject.Value
447 obj.GetProperty("name", &v)
448 return v.GetString()
449}
450
451// GetPropertyParameterType gets the "parameter-type" property.
452// The type of the parameter that must be given when activating the
453// action. This is immutable, and may be `NULL` if no parameter is needed when
454// activating the action.
455func (x *ActionBase) GetPropertyParameterType() uintptr {
456 obj := gobject.Object{}
457 obj.Ptr = x.GoPointer()
458 var v gobject.Value
459 obj.GetProperty("parameter-type", &v)
460 return v.GetPointer()
461}
462
463// GetPropertyState gets the "state" property.
464// The state of the action, or `NULL` if the action is stateless.
465func (x *ActionBase) GetPropertyState() uintptr {
466 obj := gobject.Object{}
467 obj.Ptr = x.GoPointer()
468 var v gobject.Value
469 obj.GetProperty("state", &v)
470 return v.GetPointer()
471}
472
473// GetPropertyStateType gets the "state-type" property.
474// The [type@GLib.VariantType] of the state that the action has, or `NULL` if the
475// action is stateless. This is immutable.
476func (x *ActionBase) GetPropertyStateType() uintptr {
477 obj := gobject.Object{}
478 obj.Ptr = x.GoPointer()
479 var v gobject.Value
480 obj.GetProperty("state-type", &v)
481 return v.GetPointer()
482}
483
484var XGActionActivate func(uintptr, *glib.Variant)
485var XGActionChangeState func(uintptr, *glib.Variant)
486var XGActionGetEnabled func(uintptr) bool
487var XGActionGetName func(uintptr) string
488var XGActionGetParameterType func(uintptr) *glib.VariantType
489var XGActionGetState func(uintptr) *glib.Variant
490var XGActionGetStateHint func(uintptr) *glib.Variant
491var XGActionGetStateType func(uintptr) *glib.VariantType
492
493var xActionNameIsValid func(string) bool
494
495// Checks if @action_name is valid.
496//
497// @action_name is valid if it consists only of alphanumeric characters,
498// plus `-` and `.`. The empty string is not a valid action name.
499//
500// It is an error to call this function with a non-UTF-8 @action_name.
501// @action_name must not be `NULL`.
502func ActionNameIsValid(ActionNameVar string) bool {
503
504 cret := xActionNameIsValid(ActionNameVar)
505 return cret
506}
507
508var xActionParseDetailedName func(string, *string, **glib.Variant, **glib.Error) bool
509
510// Parses a detailed action name into its separate name and target
511// components.
512//
513// Detailed action names can have three formats.
514//
515// The first format is used to represent an action name with no target
516// value and consists of just an action name containing no whitespace
517// nor the characters `:`, `(` or `)`. For example: `app.action`.
518//
519// The second format is used to represent an action with a target value
520// that is a non-empty string consisting only of alphanumerics, plus `-`
521// and `.`. In that case, the action name and target value are
522// separated by a double colon (`::`). For example:
523// `app.action::target`.
524//
525// The third format is used to represent an action with any type of
526// target value, including strings. The target value follows the action
527// name, surrounded in parens. For example: `app.action(42)`. The
528// target value is parsed using [func@GLib.Variant.parse]. If a tuple-typed
529// value is desired, it must be specified in the same way, resulting in
530// two sets of parens, for example: `app.action((1,2,3))`. A string
531// target can be specified this way as well: `app.action('target')`.
532// For strings, this third format must be used if target value is
533// empty or contains characters other than alphanumerics, `-` and `.`.
534//
535// If this function returns `TRUE`, a non-`NULL` value is guaranteed to be returned
536// in @action_name (if a pointer is passed in). A `NULL` value may still be
537// returned in @target_value, as the @detailed_name may not contain a target.
538//
539// If returned, the [type@GLib.Variant] in @target_value is guaranteed to not be floating.
540func ActionParseDetailedName(DetailedNameVar string, ActionNameVar *string, TargetValueVar **glib.Variant) (bool, error) {
541 var cerr *glib.Error
542
543 cret := xActionParseDetailedName(DetailedNameVar, ActionNameVar, TargetValueVar, &cerr)
544 if cerr == nil {
545 return cret, nil
546 }
547 return cret, cerr
548
549}
550
551var xActionPrintDetailedName func(string, *glib.Variant) string
552
553// Formats a detailed action name from @action_name and @target_value.
554//
555// It is an error to call this function with an invalid action name.
556//
557// This function is the opposite of [func@Gio.Action.parse_detailed_name].
558// It will produce a string that can be parsed back to the @action_name
559// and @target_value by that function.
560//
561// See that function for the types of strings that will be printed by
562// this function.
563func ActionPrintDetailedName(ActionNameVar string, TargetValueVar *glib.Variant) string {
564
565 cret := xActionPrintDetailedName(ActionNameVar, TargetValueVar)
566 return cret
567}
568
569func init() {
570 core.SetPackageName("GIO", "gio-2.0")
571 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
572 var libs []uintptr
573 for _, libPath := range core.GetPaths("GIO") {
574 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
575 if err != nil {
576 panic(err)
577 }
578 libs = append(libs, lib)
579 }
580
581 core.PuregoSafeRegister(&xActionNameIsValid, libs, "g_action_name_is_valid")
582 core.PuregoSafeRegister(&xActionParseDetailedName, libs, "g_action_parse_detailed_name")
583 core.PuregoSafeRegister(&xActionPrintDetailedName, libs, "g_action_print_detailed_name")
584
585 core.PuregoSafeRegister(&xActionGLibType, libs, "g_action_get_type")
586
587 core.PuregoSafeRegister(&XGActionActivate, libs, "g_action_activate")
588 core.PuregoSafeRegister(&XGActionChangeState, libs, "g_action_change_state")
589 core.PuregoSafeRegister(&XGActionGetEnabled, libs, "g_action_get_enabled")
590 core.PuregoSafeRegister(&XGActionGetName, libs, "g_action_get_name")
591 core.PuregoSafeRegister(&XGActionGetParameterType, libs, "g_action_get_parameter_type")
592 core.PuregoSafeRegister(&XGActionGetState, libs, "g_action_get_state")
593 core.PuregoSafeRegister(&XGActionGetStateHint, libs, "g_action_get_state_hint")
594 core.PuregoSafeRegister(&XGActionGetStateType, libs, "g_action_get_state_type")
595
596}