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// `GDBusActionGroup` is an implementation of the [iface@Gio.ActionGroup]
14// interface.
15//
16// `GDBusActionGroup` can be used as a proxy for an action group
17// that is exported over D-Bus with [method@Gio.DBusConnection.export_action_group].
18type DBusActionGroup struct {
19 gobject.Object
20}
21
22var xDBusActionGroupGLibType func() types.GType
23
24func DBusActionGroupGLibType() types.GType {
25 return xDBusActionGroupGLibType()
26}
27
28func DBusActionGroupNewFromInternalPtr(ptr uintptr) *DBusActionGroup {
29 cls := &DBusActionGroup{}
30 cls.Ptr = ptr
31 return cls
32}
33
34func (c *DBusActionGroup) GoPointer() uintptr {
35 if c == nil {
36 return 0
37 }
38 return c.Ptr
39}
40
41func (c *DBusActionGroup) SetGoPointer(ptr uintptr) {
42 c.Ptr = ptr
43}
44
45// Emits the [signal@Gio.ActionGroup::action-added] signal on @action_group.
46//
47// This function should only be called by [type@Gio.ActionGroup] implementations.
48func (x *DBusActionGroup) ActionAdded(ActionNameVar string) {
49
50 XGActionGroupActionAdded(x.GoPointer(), ActionNameVar)
51
52}
53
54// Emits the [signal@Gio.ActionGroup::action-enabled-changed] signal on @action_group.
55//
56// This function should only be called by [type@Gio.ActionGroup] implementations.
57func (x *DBusActionGroup) ActionEnabledChanged(ActionNameVar string, EnabledVar bool) {
58
59 XGActionGroupActionEnabledChanged(x.GoPointer(), ActionNameVar, EnabledVar)
60
61}
62
63// Emits the [signal@Gio.ActionGroup::action-removed] signal on @action_group.
64//
65// This function should only be called by [type@Gio.ActionGroup] implementations.
66func (x *DBusActionGroup) ActionRemoved(ActionNameVar string) {
67
68 XGActionGroupActionRemoved(x.GoPointer(), ActionNameVar)
69
70}
71
72// Emits the [signal@Gio.ActionGroup::action-state-changed] signal on @action_group.
73//
74// This function should only be called by [type@Gio.ActionGroup] implementations.
75func (x *DBusActionGroup) ActionStateChanged(ActionNameVar string, StateVar *glib.Variant) {
76
77 XGActionGroupActionStateChanged(x.GoPointer(), ActionNameVar, StateVar)
78
79}
80
81// Activate the named action within @action_group.
82//
83// If the action is expecting a parameter, then the correct type of
84// parameter must be given as @parameter. If the action is expecting no
85// parameters then @parameter must be `NULL`. See
86// [method@Gio.ActionGroup.get_action_parameter_type].
87//
88// If the [type@Gio.ActionGroup] implementation supports asynchronous remote
89// activation over D-Bus, this call may return before the relevant
90// D-Bus traffic has been sent, or any replies have been received. In
91// order to block on such asynchronous activation calls,
92// [method@Gio.DBusConnection.flush] should be called prior to the code, which
93// depends on the result of the action activation. Without flushing
94// the D-Bus connection, there is no guarantee that the action would
95// have been activated.
96//
97// The following code which runs in a remote app instance, shows an
98// example of a ‘quit’ action being activated on the primary app
99// instance over D-Bus. Here [method@Gio.DBusConnection.flush] is called
100// before `exit()`. Without `g_dbus_connection_flush()`, the ‘quit’ action
101// may fail to be activated on the primary instance.
102//
103// ```c
104// // call ‘quit’ action on primary instance
105// g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);
106//
107// // make sure the action is activated now
108// g_dbus_connection_flush (…);
109//
110// g_debug ("Application has been terminated. Exiting.");
111//
112// exit (0);
113// ```
114func (x *DBusActionGroup) ActivateAction(ActionNameVar string, ParameterVar *glib.Variant) {
115
116 XGActionGroupActivateAction(x.GoPointer(), ActionNameVar, ParameterVar)
117
118}
119
120// Request for the state of the named action within @action_group to be
121// changed to @value.
122//
123// The action must be stateful and @value must be of the correct type.
124// See [method@Gio.ActionGroup.get_action_state_type].
125//
126// This call merely requests a change. The action may refuse to change
127// its state or may change its state to something other than @value.
128// See [method@Gio.ActionGroup.get_action_state_hint].
129//
130// If the @value GVariant is floating, it is consumed.
131func (x *DBusActionGroup) ChangeActionState(ActionNameVar string, ValueVar *glib.Variant) {
132
133 XGActionGroupChangeActionState(x.GoPointer(), ActionNameVar, ValueVar)
134
135}
136
137// Checks if the named action within @action_group is currently enabled.
138//
139// An action must be enabled in order to be activated or in order to
140// have its state changed from outside callers.
141func (x *DBusActionGroup) GetActionEnabled(ActionNameVar string) bool {
142
143 cret := XGActionGroupGetActionEnabled(x.GoPointer(), ActionNameVar)
144 return cret
145}
146
147// Queries the type of the parameter that must be given when activating
148// the named action within @action_group.
149//
150// When activating the action using [method@Gio.ActionGroup.activate_action],
151// the [type@GLib.Variant] given to that function must be of the type returned
152// by this function.
153//
154// In the case that this function returns `NULL`, you must not give any
155// [type@GLib.Variant], but `NULL` instead.
156//
157// The parameter type of a particular action will never change but it is
158// possible for an action to be removed and for a new action to be added
159// with the same name but a different parameter type.
160func (x *DBusActionGroup) GetActionParameterType(ActionNameVar string) *glib.VariantType {
161
162 cret := XGActionGroupGetActionParameterType(x.GoPointer(), ActionNameVar)
163 return cret
164}
165
166// Queries the current state of the named action within @action_group.
167//
168// If the action is not stateful then `NULL` will be returned. If the
169// action is stateful then the type of the return value is the type
170// given by [method@Gio.ActionGroup.get_action_state_type].
171//
172// The return value (if non-`NULL`) should be freed with
173// [method@GLib.Variant.unref] when it is no longer required.
174func (x *DBusActionGroup) GetActionState(ActionNameVar string) *glib.Variant {
175
176 cret := XGActionGroupGetActionState(x.GoPointer(), ActionNameVar)
177 return cret
178}
179
180// Requests a hint about the valid range of values for the state of the
181// named action within @action_group.
182//
183// If `NULL` is returned it either means that the action is not stateful
184// or that there is no hint about the valid range of values for the
185// state of the action.
186//
187// If a [type@GLib.Variant] array is returned then each item in the array is a
188// possible value for the state. If a [type@GLib.Variant] pair (ie: two-tuple) is
189// returned then the tuple specifies the inclusive lower and upper bound
190// of valid values for the state.
191//
192// In any case, the information is merely a hint. It may be possible to
193// have a state value outside of the hinted range and setting a value
194// within the range may fail.
195//
196// The return value (if non-`NULL`) should be freed with
197// [method@GLib.Variant.unref] when it is no longer required.
198func (x *DBusActionGroup) GetActionStateHint(ActionNameVar string) *glib.Variant {
199
200 cret := XGActionGroupGetActionStateHint(x.GoPointer(), ActionNameVar)
201 return cret
202}
203
204// Queries the type of the state of the named action within
205// @action_group.
206//
207// If the action is stateful then this function returns the
208// [type@GLib.VariantType] of the state. All calls to
209// [method@Gio.ActionGroup.change_action_state] must give a [type@GLib.Variant] of this
210// type and [method@Gio.ActionGroup.get_action_state] will return a [type@GLib.Variant]
211// of the same type.
212//
213// If the action is not stateful then this function will return `NULL`.
214// In that case, [method@Gio.ActionGroup.get_action_state] will return `NULL`
215// and you must not call [method@Gio.ActionGroup.change_action_state].
216//
217// The state type of a particular action will never change but it is
218// possible for an action to be removed and for a new action to be added
219// with the same name but a different state type.
220func (x *DBusActionGroup) GetActionStateType(ActionNameVar string) *glib.VariantType {
221
222 cret := XGActionGroupGetActionStateType(x.GoPointer(), ActionNameVar)
223 return cret
224}
225
226// Checks if the named action exists within @action_group.
227func (x *DBusActionGroup) HasAction(ActionNameVar string) bool {
228
229 cret := XGActionGroupHasAction(x.GoPointer(), ActionNameVar)
230 return cret
231}
232
233// Lists the actions contained within @action_group.
234//
235// The caller is responsible for freeing the list with [func@GLib.strfreev] when
236// it is no longer required.
237func (x *DBusActionGroup) ListActions() []string {
238
239 cret := XGActionGroupListActions(x.GoPointer())
240 return cret
241}
242
243// Queries all aspects of the named action within an @action_group.
244//
245// This function acquires the information available from
246// [method@Gio.ActionGroup.has_action], [method@Gio.ActionGroup.get_action_enabled],
247// [method@Gio.ActionGroup.get_action_parameter_type],
248// [method@Gio.ActionGroup.get_action_state_type],
249// [method@Gio.ActionGroup.get_action_state_hint] and
250// [method@Gio.ActionGroup.get_action_state] with a single function call.
251//
252// This provides two main benefits.
253//
254// The first is the improvement in efficiency that comes with not having
255// to perform repeated lookups of the action in order to discover
256// different things about it. The second is that implementing
257// [type@Gio.ActionGroup] can now be done by only overriding this one virtual
258// function.
259//
260// The interface provides a default implementation of this function that
261// calls the individual functions, as required, to fetch the
262// information. The interface also provides default implementations of
263// those functions that call this function. All implementations,
264// therefore, must override either this function or all of the others.
265//
266// If the action exists, `TRUE` is returned and any of the requested
267// fields (as indicated by having a non-`NULL` reference passed in) are
268// filled. If the action doesn’t exist, `FALSE` is returned and the
269// fields may or may not have been modified.
270func (x *DBusActionGroup) QueryAction(ActionNameVar string, EnabledVar *bool, ParameterTypeVar **glib.VariantType, StateTypeVar **glib.VariantType, StateHintVar **glib.Variant, StateVar **glib.Variant) bool {
271
272 cret := XGActionGroupQueryAction(x.GoPointer(), ActionNameVar, EnabledVar, ParameterTypeVar, StateTypeVar, StateHintVar, StateVar)
273 return cret
274}
275
276// Activates the remote action.
277//
278// This is the same as g_action_group_activate_action() except that it
279// allows for provision of "platform data" to be sent along with the
280// activation request. This typically contains details such as the user
281// interaction timestamp or startup notification information.
282//
283// @platform_data must be non-%NULL and must have the type
284// %G_VARIANT_TYPE_VARDICT. If it is floating, it will be consumed.
285func (x *DBusActionGroup) ActivateActionFull(ActionNameVar string, ParameterVar *glib.Variant, PlatformDataVar *glib.Variant) {
286
287 XGRemoteActionGroupActivateActionFull(x.GoPointer(), ActionNameVar, ParameterVar, PlatformDataVar)
288
289}
290
291// Changes the state of a remote action.
292//
293// This is the same as g_action_group_change_action_state() except that
294// it allows for provision of "platform data" to be sent along with the
295// state change request. This typically contains details such as the
296// user interaction timestamp or startup notification information.
297//
298// @platform_data must be non-%NULL and must have the type
299// %G_VARIANT_TYPE_VARDICT. If it is floating, it will be consumed.
300func (x *DBusActionGroup) ChangeActionStateFull(ActionNameVar string, ValueVar *glib.Variant, PlatformDataVar *glib.Variant) {
301
302 XGRemoteActionGroupChangeActionStateFull(x.GoPointer(), ActionNameVar, ValueVar, PlatformDataVar)
303
304}
305
306var xDBusActionGroupGet func(uintptr, uintptr, string) uintptr
307
308// Obtains a #GDBusActionGroup for the action group which is exported at
309// the given @bus_name and @object_path.
310//
311// The thread default main context is taken at the time of this call.
312// All signals on the menu model (and any linked models) are reported
313// with respect to this context. All calls on the returned menu model
314// (and linked models) must also originate from this same context, with
315// the thread default main context unchanged.
316//
317// This call is non-blocking. The returned action group may or may not
318// already be filled in. The correct thing to do is connect the signals
319// for the action group to monitor for changes and then to call
320// g_action_group_list_actions() to get the initial list.
321func DBusActionGroupGet(ConnectionVar *DBusConnection, BusNameVar *string, ObjectPathVar string) *DBusActionGroup {
322 var cls *DBusActionGroup
323
324 BusNameVarPtr := core.GStrdupNullable(BusNameVar)
325 defer core.GFreeNullable(BusNameVarPtr)
326
327 cret := xDBusActionGroupGet(ConnectionVar.GoPointer(), BusNameVarPtr, ObjectPathVar)
328
329 if cret == 0 {
330 return nil
331 }
332 cls = &DBusActionGroup{}
333 cls.Ptr = cret
334 return cls
335}
336
337func init() {
338 core.SetPackageName("GIO", "gio-2.0")
339 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
340 var libs []uintptr
341 for _, libPath := range core.GetPaths("GIO") {
342 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
343 if err != nil {
344 panic(err)
345 }
346 libs = append(libs, lib)
347 }
348
349 core.PuregoSafeRegister(&xDBusActionGroupGLibType, libs, "g_dbus_action_group_get_type")
350
351 core.PuregoSafeRegister(&xDBusActionGroupGet, libs, "g_dbus_action_group_get")
352
353}