1// Package adw was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package adw
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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15 "github.com/bnema/puregotk/v4/gtk"
16)
17
18type ApplicationClass struct {
19 _ structs.HostLayout
20
21 ParentClass gtk.ApplicationClass
22
23 Padding [4]uintptr
24}
25
26func (x *ApplicationClass) GoPointer() uintptr {
27 return uintptr(unsafe.Pointer(x))
28}
29
30// A base class for Adwaita applications.
31//
32// `AdwApplication` handles library initialization by calling [func@init] in the
33// default [signal@Gio.Application::startup] signal handler, in turn chaining up
34// as required by [class@Gtk.Application]. Therefore, any subclass of
35// `AdwApplication` should always chain up its `startup` handler before using
36// any Adwaita or GTK API.
37//
38// ## Automatic Resources
39//
40// ### Shortcuts Dialog
41//
42// If there's a resource located at `shortcuts-dialog.ui` which defines an
43// [class@ShortcutsDialog] with the ID `shortcuts_dialog`, `AdwApplication`
44// will set up an `app.shortcuts` action that creates and presents this dialog,
45// as well as a <kbd>Ctrl</kbd><kbd>?</kbd> accelerator for it.
46//
47// ### Stylesheet
48//
49// `AdwApplication` will automatically load stylesheets located in the
50// application's resource base path (see
51// [method@Gio.Application.set_resource_base_path], if they're present.
52//
53// They can be used to add custom styles to the application, as follows:
54//
55// - `style.css` contains styles that are always present.
56//
57// - `style-dark.css` contains styles only used when
58// [property@StyleManager:dark] is `TRUE`.
59//
60// - `style-hc.css` contains styles used when the system high contrast
61// preference is enabled.
62//
63// - `style-hc-dark.css` contains styles used when the system high contrast
64// preference is enabled and [property@StyleManager:dark] is `TRUE`.
65//
66// :::note
67//
68// `style.css` can contain styles for dark and high contrast appearance as
69// well, using media queries:
70//
71// - `prefers-color-scheme: dark` for styles used only for dark appearance.
72// - `prefers-contrast: more` for styles used only when the system high
73// contrast preference is enabled.
74type Application struct {
75 gtk.Application
76}
77
78var xApplicationGLibType func() types.GType
79
80func ApplicationGLibType() types.GType {
81 return xApplicationGLibType()
82}
83
84func ApplicationNewFromInternalPtr(ptr uintptr) *Application {
85 cls := &Application{}
86 cls.Ptr = ptr
87 return cls
88}
89
90var xNewApplication func(uintptr, gio.ApplicationFlags) uintptr
91
92// Creates a new `AdwApplication`.
93//
94// If `application_id` is not `NULL`, then it must be valid. See
95// [func@Gio.Application.id_is_valid].
96//
97// If no application ID is given then some features (most notably application
98// uniqueness) will be disabled.
99func NewApplication(ApplicationIdVar *string, FlagsVar gio.ApplicationFlags) *Application {
100 var cls *Application
101
102 ApplicationIdVarPtr := core.GStrdupNullable(ApplicationIdVar)
103 defer core.GFreeNullable(ApplicationIdVarPtr)
104
105 cret := xNewApplication(ApplicationIdVarPtr, FlagsVar)
106
107 if cret == 0 {
108 return nil
109 }
110 cls = &Application{}
111 cls.Ptr = cret
112 return cls
113}
114
115var xApplicationGetStyleManager func(uintptr) uintptr
116
117// Gets the style manager for @self.
118//
119// This is a convenience property allowing to access `AdwStyleManager` through
120// property bindings or expressions.
121func (x *Application) GetStyleManager() *StyleManager {
122 var cls *StyleManager
123
124 cret := xApplicationGetStyleManager(x.GoPointer())
125
126 if cret == 0 {
127 return nil
128 }
129 gobject.IncreaseRef(cret)
130 cls = &StyleManager{}
131 cls.Ptr = cret
132 return cls
133}
134
135func (c *Application) GoPointer() uintptr {
136 if c == nil {
137 return 0
138 }
139 return c.Ptr
140}
141
142func (c *Application) SetGoPointer(ptr uintptr) {
143 c.Ptr = ptr
144}
145
146// Emits the [signal@Gio.ActionGroup::action-added] signal on @action_group.
147//
148// This function should only be called by [type@Gio.ActionGroup] implementations.
149func (x *Application) ActionAdded(ActionNameVar string) {
150
151 gio.XGActionGroupActionAdded(x.GoPointer(), ActionNameVar)
152
153}
154
155// Emits the [signal@Gio.ActionGroup::action-enabled-changed] signal on @action_group.
156//
157// This function should only be called by [type@Gio.ActionGroup] implementations.
158func (x *Application) ActionEnabledChanged(ActionNameVar string, EnabledVar bool) {
159
160 gio.XGActionGroupActionEnabledChanged(x.GoPointer(), ActionNameVar, EnabledVar)
161
162}
163
164// Emits the [signal@Gio.ActionGroup::action-removed] signal on @action_group.
165//
166// This function should only be called by [type@Gio.ActionGroup] implementations.
167func (x *Application) ActionRemoved(ActionNameVar string) {
168
169 gio.XGActionGroupActionRemoved(x.GoPointer(), ActionNameVar)
170
171}
172
173// Emits the [signal@Gio.ActionGroup::action-state-changed] signal on @action_group.
174//
175// This function should only be called by [type@Gio.ActionGroup] implementations.
176func (x *Application) ActionStateChanged(ActionNameVar string, StateVar *glib.Variant) {
177
178 gio.XGActionGroupActionStateChanged(x.GoPointer(), ActionNameVar, StateVar)
179
180}
181
182// Activate the named action within @action_group.
183//
184// If the action is expecting a parameter, then the correct type of
185// parameter must be given as @parameter. If the action is expecting no
186// parameters then @parameter must be `NULL`. See
187// [method@Gio.ActionGroup.get_action_parameter_type].
188//
189// If the [type@Gio.ActionGroup] implementation supports asynchronous remote
190// activation over D-Bus, this call may return before the relevant
191// D-Bus traffic has been sent, or any replies have been received. In
192// order to block on such asynchronous activation calls,
193// [method@Gio.DBusConnection.flush] should be called prior to the code, which
194// depends on the result of the action activation. Without flushing
195// the D-Bus connection, there is no guarantee that the action would
196// have been activated.
197//
198// The following code which runs in a remote app instance, shows an
199// example of a ‘quit’ action being activated on the primary app
200// instance over D-Bus. Here [method@Gio.DBusConnection.flush] is called
201// before `exit()`. Without `g_dbus_connection_flush()`, the ‘quit’ action
202// may fail to be activated on the primary instance.
203//
204// ```c
205// // call ‘quit’ action on primary instance
206// g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);
207//
208// // make sure the action is activated now
209// g_dbus_connection_flush (…);
210//
211// g_debug ("Application has been terminated. Exiting.");
212//
213// exit (0);
214// ```
215func (x *Application) ActivateAction(ActionNameVar string, ParameterVar *glib.Variant) {
216
217 gio.XGActionGroupActivateAction(x.GoPointer(), ActionNameVar, ParameterVar)
218
219}
220
221// Request for the state of the named action within @action_group to be
222// changed to @value.
223//
224// The action must be stateful and @value must be of the correct type.
225// See [method@Gio.ActionGroup.get_action_state_type].
226//
227// This call merely requests a change. The action may refuse to change
228// its state or may change its state to something other than @value.
229// See [method@Gio.ActionGroup.get_action_state_hint].
230//
231// If the @value GVariant is floating, it is consumed.
232func (x *Application) ChangeActionState(ActionNameVar string, ValueVar *glib.Variant) {
233
234 gio.XGActionGroupChangeActionState(x.GoPointer(), ActionNameVar, ValueVar)
235
236}
237
238// Checks if the named action within @action_group is currently enabled.
239//
240// An action must be enabled in order to be activated or in order to
241// have its state changed from outside callers.
242func (x *Application) GetActionEnabled(ActionNameVar string) bool {
243
244 cret := gio.XGActionGroupGetActionEnabled(x.GoPointer(), ActionNameVar)
245 return cret
246}
247
248// Queries the type of the parameter that must be given when activating
249// the named action within @action_group.
250//
251// When activating the action using [method@Gio.ActionGroup.activate_action],
252// the [type@GLib.Variant] given to that function must be of the type returned
253// by this function.
254//
255// In the case that this function returns `NULL`, you must not give any
256// [type@GLib.Variant], but `NULL` instead.
257//
258// The parameter type of a particular action will never change but it is
259// possible for an action to be removed and for a new action to be added
260// with the same name but a different parameter type.
261func (x *Application) GetActionParameterType(ActionNameVar string) *glib.VariantType {
262
263 cret := gio.XGActionGroupGetActionParameterType(x.GoPointer(), ActionNameVar)
264 return cret
265}
266
267// Queries the current state of the named action within @action_group.
268//
269// If the action is not stateful then `NULL` will be returned. If the
270// action is stateful then the type of the return value is the type
271// given by [method@Gio.ActionGroup.get_action_state_type].
272//
273// The return value (if non-`NULL`) should be freed with
274// [method@GLib.Variant.unref] when it is no longer required.
275func (x *Application) GetActionState(ActionNameVar string) *glib.Variant {
276
277 cret := gio.XGActionGroupGetActionState(x.GoPointer(), ActionNameVar)
278 return cret
279}
280
281// Requests a hint about the valid range of values for the state of the
282// named action within @action_group.
283//
284// If `NULL` is returned it either means that the action is not stateful
285// or that there is no hint about the valid range of values for the
286// state of the action.
287//
288// If a [type@GLib.Variant] array is returned then each item in the array is a
289// possible value for the state. If a [type@GLib.Variant] pair (ie: two-tuple) is
290// returned then the tuple specifies the inclusive lower and upper bound
291// of valid values for the state.
292//
293// In any case, the information is merely a hint. It may be possible to
294// have a state value outside of the hinted range and setting a value
295// within the range may fail.
296//
297// The return value (if non-`NULL`) should be freed with
298// [method@GLib.Variant.unref] when it is no longer required.
299func (x *Application) GetActionStateHint(ActionNameVar string) *glib.Variant {
300
301 cret := gio.XGActionGroupGetActionStateHint(x.GoPointer(), ActionNameVar)
302 return cret
303}
304
305// Queries the type of the state of the named action within
306// @action_group.
307//
308// If the action is stateful then this function returns the
309// [type@GLib.VariantType] of the state. All calls to
310// [method@Gio.ActionGroup.change_action_state] must give a [type@GLib.Variant] of this
311// type and [method@Gio.ActionGroup.get_action_state] will return a [type@GLib.Variant]
312// of the same type.
313//
314// If the action is not stateful then this function will return `NULL`.
315// In that case, [method@Gio.ActionGroup.get_action_state] will return `NULL`
316// and you must not call [method@Gio.ActionGroup.change_action_state].
317//
318// The state type of a particular action will never change but it is
319// possible for an action to be removed and for a new action to be added
320// with the same name but a different state type.
321func (x *Application) GetActionStateType(ActionNameVar string) *glib.VariantType {
322
323 cret := gio.XGActionGroupGetActionStateType(x.GoPointer(), ActionNameVar)
324 return cret
325}
326
327// Checks if the named action exists within @action_group.
328func (x *Application) HasAction(ActionNameVar string) bool {
329
330 cret := gio.XGActionGroupHasAction(x.GoPointer(), ActionNameVar)
331 return cret
332}
333
334// Lists the actions contained within @action_group.
335//
336// The caller is responsible for freeing the list with [func@GLib.strfreev] when
337// it is no longer required.
338func (x *Application) ListActions() []string {
339
340 cret := gio.XGActionGroupListActions(x.GoPointer())
341 return cret
342}
343
344// Queries all aspects of the named action within an @action_group.
345//
346// This function acquires the information available from
347// [method@Gio.ActionGroup.has_action], [method@Gio.ActionGroup.get_action_enabled],
348// [method@Gio.ActionGroup.get_action_parameter_type],
349// [method@Gio.ActionGroup.get_action_state_type],
350// [method@Gio.ActionGroup.get_action_state_hint] and
351// [method@Gio.ActionGroup.get_action_state] with a single function call.
352//
353// This provides two main benefits.
354//
355// The first is the improvement in efficiency that comes with not having
356// to perform repeated lookups of the action in order to discover
357// different things about it. The second is that implementing
358// [type@Gio.ActionGroup] can now be done by only overriding this one virtual
359// function.
360//
361// The interface provides a default implementation of this function that
362// calls the individual functions, as required, to fetch the
363// information. The interface also provides default implementations of
364// those functions that call this function. All implementations,
365// therefore, must override either this function or all of the others.
366//
367// If the action exists, `TRUE` is returned and any of the requested
368// fields (as indicated by having a non-`NULL` reference passed in) are
369// filled. If the action doesn’t exist, `FALSE` is returned and the
370// fields may or may not have been modified.
371func (x *Application) QueryAction(ActionNameVar string, EnabledVar *bool, ParameterTypeVar **glib.VariantType, StateTypeVar **glib.VariantType, StateHintVar **glib.Variant, StateVar **glib.Variant) bool {
372
373 cret := gio.XGActionGroupQueryAction(x.GoPointer(), ActionNameVar, EnabledVar, ParameterTypeVar, StateTypeVar, StateHintVar, StateVar)
374 return cret
375}
376
377// Adds an action to the @action_map.
378//
379// If the action map already contains an action with the same name
380// as @action then the old action is dropped from the action map.
381//
382// The action map takes its own reference on @action.
383func (x *Application) AddAction(ActionVar gio.Action) {
384
385 gio.XGActionMapAddAction(x.GoPointer(), ActionVar.GoPointer())
386
387}
388
389// A convenience function for creating multiple [class@Gio.SimpleAction]
390// instances and adding them to a [iface@Gio.ActionMap].
391//
392// Each action is constructed as per one [struct@Gio.ActionEntry].
393//
394// ```c
395// static void
396// activate_quit (GSimpleAction *simple,
397//
398// GVariant *parameter,
399// gpointer user_data)
400//
401// {
402// exit (0);
403// }
404//
405// static void
406// activate_print_string (GSimpleAction *simple,
407//
408// GVariant *parameter,
409// gpointer user_data)
410//
411// {
412// g_print ("%s\n", g_variant_get_string (parameter, NULL));
413// }
414//
415// static GActionGroup *
416// create_action_group (void)
417//
418// {
419// const GActionEntry entries[] = {
420// { "quit", activate_quit },
421// { "print-string", activate_print_string, "s" }
422// };
423// GSimpleActionGroup *group;
424//
425// group = g_simple_action_group_new ();
426// g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), NULL);
427//
428// return G_ACTION_GROUP (group);
429// }
430//
431// ```
432func (x *Application) AddActionEntries(EntriesVar []gio.ActionEntry, NEntriesVar int, UserDataVar uintptr) {
433
434 gio.XGActionMapAddActionEntries(x.GoPointer(), EntriesVar, NEntriesVar, UserDataVar)
435
436}
437
438// Looks up the action with the name @action_name in @action_map.
439//
440// If no such action exists, returns `NULL`.
441func (x *Application) LookupAction(ActionNameVar string) *gio.ActionBase {
442 var cls *gio.ActionBase
443
444 cret := gio.XGActionMapLookupAction(x.GoPointer(), ActionNameVar)
445
446 if cret == 0 {
447 return nil
448 }
449 gobject.IncreaseRef(cret)
450 cls = &gio.ActionBase{}
451 cls.Ptr = cret
452 return cls
453}
454
455// Removes the named action from the action map.
456//
457// If no action of this name is in the map then nothing happens.
458func (x *Application) RemoveAction(ActionNameVar string) {
459
460 gio.XGActionMapRemoveAction(x.GoPointer(), ActionNameVar)
461
462}
463
464// Remove actions from a [iface@Gio.ActionMap]. This is meant as the reverse of
465// [method@Gio.ActionMap.add_action_entries].
466//
467// ```c
468//
469// static const GActionEntry entries[] = {
470// { "quit", activate_quit },
471// { "print-string", activate_print_string, "s" }
472// };
473//
474// void
475// add_actions (GActionMap *map)
476//
477// {
478// g_action_map_add_action_entries (map, entries, G_N_ELEMENTS (entries), NULL);
479// }
480//
481// void
482// remove_actions (GActionMap *map)
483//
484// {
485// g_action_map_remove_action_entries (map, entries, G_N_ELEMENTS (entries));
486// }
487//
488// ```
489func (x *Application) RemoveActionEntries(EntriesVar []gio.ActionEntry, NEntriesVar int) {
490
491 gio.XGActionMapRemoveActionEntries(x.GoPointer(), EntriesVar, NEntriesVar)
492
493}
494
495func init() {
496 core.SetPackageName("ADW", "libadwaita-1")
497 core.SetSharedLibraries("ADW", []string{"libadwaita-1.so.0"})
498 var libs []uintptr
499 for _, libPath := range core.GetPaths("ADW") {
500 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
501 if err != nil {
502 panic(err)
503 }
504 libs = append(libs, lib)
505 }
506
507 core.PuregoSafeRegister(&xApplicationGLibType, libs, "adw_application_get_type")
508
509 core.PuregoSafeRegister(&xNewApplication, libs, "adw_application_new")
510
511 core.PuregoSafeRegister(&xApplicationGetStyleManager, libs, "adw_application_get_style_manager")
512
513}