// Package adw was automatically generated by github.com/bnema/puregotk DO NOT EDIT package adw import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gio" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/gtk" ) type ApplicationClass struct { _ structs.HostLayout ParentClass gtk.ApplicationClass Padding [4]uintptr } func (x *ApplicationClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // A base class for Adwaita applications. // // `AdwApplication` handles library initialization by calling [func@init] in the // default [signal@Gio.Application::startup] signal handler, in turn chaining up // as required by [class@Gtk.Application]. Therefore, any subclass of // `AdwApplication` should always chain up its `startup` handler before using // any Adwaita or GTK API. // // ## Automatic Resources // // ### Shortcuts Dialog // // If there's a resource located at `shortcuts-dialog.ui` which defines an // [class@ShortcutsDialog] with the ID `shortcuts_dialog`, `AdwApplication` // will set up an `app.shortcuts` action that creates and presents this dialog, // as well as a <kbd>Ctrl</kbd><kbd>?</kbd> accelerator for it. // // ### Stylesheet // // `AdwApplication` will automatically load stylesheets located in the // application's resource base path (see // [method@Gio.Application.set_resource_base_path], if they're present. // // They can be used to add custom styles to the application, as follows: // // - `style.css` contains styles that are always present. // // - `style-dark.css` contains styles only used when // [property@StyleManager:dark] is `TRUE`. // // - `style-hc.css` contains styles used when the system high contrast // preference is enabled. // // - `style-hc-dark.css` contains styles used when the system high contrast // preference is enabled and [property@StyleManager:dark] is `TRUE`. // // :::note // // `style.css` can contain styles for dark and high contrast appearance as // well, using media queries: // // - `prefers-color-scheme: dark` for styles used only for dark appearance. // - `prefers-contrast: more` for styles used only when the system high // contrast preference is enabled. type Application struct { gtk.Application } var xApplicationGLibType func() types.GType func ApplicationGLibType() types.GType { return xApplicationGLibType() } func ApplicationNewFromInternalPtr(ptr uintptr) *Application { cls := &Application{} cls.Ptr = ptr return cls } var xNewApplication func(uintptr, gio.ApplicationFlags) uintptr // Creates a new `AdwApplication`. // // If `application_id` is not `NULL`, then it must be valid. See // [func@Gio.Application.id_is_valid]. // // If no application ID is given then some features (most notably application // uniqueness) will be disabled. func NewApplication(ApplicationIdVar *string, FlagsVar gio.ApplicationFlags) *Application { var cls *Application ApplicationIdVarPtr := core.GStrdupNullable(ApplicationIdVar) defer core.GFreeNullable(ApplicationIdVarPtr) cret := xNewApplication(ApplicationIdVarPtr, FlagsVar) if cret == 0 { return nil } cls = &Application{} cls.Ptr = cret return cls } var xApplicationGetStyleManager func(uintptr) uintptr // Gets the style manager for @self. // // This is a convenience property allowing to access `AdwStyleManager` through // property bindings or expressions. func (x *Application) GetStyleManager() *StyleManager { var cls *StyleManager cret := xApplicationGetStyleManager(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &StyleManager{} cls.Ptr = cret return cls } func (c *Application) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *Application) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Emits the [signal@Gio.ActionGroup::action-added] signal on @action_group. // // This function should only be called by [type@Gio.ActionGroup] implementations. func (x *Application) ActionAdded(ActionNameVar string) { gio.XGActionGroupActionAdded(x.GoPointer(), ActionNameVar) } // Emits the [signal@Gio.ActionGroup::action-enabled-changed] signal on @action_group. // // This function should only be called by [type@Gio.ActionGroup] implementations. func (x *Application) ActionEnabledChanged(ActionNameVar string, EnabledVar bool) { gio.XGActionGroupActionEnabledChanged(x.GoPointer(), ActionNameVar, EnabledVar) } // Emits the [signal@Gio.ActionGroup::action-removed] signal on @action_group. // // This function should only be called by [type@Gio.ActionGroup] implementations. func (x *Application) ActionRemoved(ActionNameVar string) { gio.XGActionGroupActionRemoved(x.GoPointer(), ActionNameVar) } // Emits the [signal@Gio.ActionGroup::action-state-changed] signal on @action_group. // // This function should only be called by [type@Gio.ActionGroup] implementations. func (x *Application) ActionStateChanged(ActionNameVar string, StateVar *glib.Variant) { gio.XGActionGroupActionStateChanged(x.GoPointer(), ActionNameVar, StateVar) } // Activate the named action within @action_group. // // If the action is expecting a parameter, then the correct type of // parameter must be given as @parameter. If the action is expecting no // parameters then @parameter must be `NULL`. See // [method@Gio.ActionGroup.get_action_parameter_type]. // // If the [type@Gio.ActionGroup] implementation supports asynchronous remote // activation over D-Bus, this call may return before the relevant // D-Bus traffic has been sent, or any replies have been received. In // order to block on such asynchronous activation calls, // [method@Gio.DBusConnection.flush] should be called prior to the code, which // depends on the result of the action activation. Without flushing // the D-Bus connection, there is no guarantee that the action would // have been activated. // // The following code which runs in a remote app instance, shows an // example of a ‘quit’ action being activated on the primary app // instance over D-Bus. Here [method@Gio.DBusConnection.flush] is called // before `exit()`. Without `g_dbus_connection_flush()`, the ‘quit’ action // may fail to be activated on the primary instance. // // ```c // // call ‘quit’ action on primary instance // g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL); // // // make sure the action is activated now // g_dbus_connection_flush (…); // // g_debug ("Application has been terminated. Exiting."); // // exit (0); // ``` func (x *Application) ActivateAction(ActionNameVar string, ParameterVar *glib.Variant) { gio.XGActionGroupActivateAction(x.GoPointer(), ActionNameVar, ParameterVar) } // Request for the state of the named action within @action_group to be // changed to @value. // // The action must be stateful and @value must be of the correct type. // See [method@Gio.ActionGroup.get_action_state_type]. // // This call merely requests a change. The action may refuse to change // its state or may change its state to something other than @value. // See [method@Gio.ActionGroup.get_action_state_hint]. // // If the @value GVariant is floating, it is consumed. func (x *Application) ChangeActionState(ActionNameVar string, ValueVar *glib.Variant) { gio.XGActionGroupChangeActionState(x.GoPointer(), ActionNameVar, ValueVar) } // Checks if the named action within @action_group is currently enabled. // // An action must be enabled in order to be activated or in order to // have its state changed from outside callers. func (x *Application) GetActionEnabled(ActionNameVar string) bool { cret := gio.XGActionGroupGetActionEnabled(x.GoPointer(), ActionNameVar) return cret } // Queries the type of the parameter that must be given when activating // the named action within @action_group. // // When activating the action using [method@Gio.ActionGroup.activate_action], // the [type@GLib.Variant] given to that function must be of the type returned // by this function. // // In the case that this function returns `NULL`, you must not give any // [type@GLib.Variant], but `NULL` instead. // // The parameter type of a particular action will never change but it is // possible for an action to be removed and for a new action to be added // with the same name but a different parameter type. func (x *Application) GetActionParameterType(ActionNameVar string) *glib.VariantType { cret := gio.XGActionGroupGetActionParameterType(x.GoPointer(), ActionNameVar) return cret } // Queries the current state of the named action within @action_group. // // If the action is not stateful then `NULL` will be returned. If the // action is stateful then the type of the return value is the type // given by [method@Gio.ActionGroup.get_action_state_type]. // // The return value (if non-`NULL`) should be freed with // [method@GLib.Variant.unref] when it is no longer required. func (x *Application) GetActionState(ActionNameVar string) *glib.Variant { cret := gio.XGActionGroupGetActionState(x.GoPointer(), ActionNameVar) return cret } // Requests a hint about the valid range of values for the state of the // named action within @action_group. // // If `NULL` is returned it either means that the action is not stateful // or that there is no hint about the valid range of values for the // state of the action. // // If a [type@GLib.Variant] array is returned then each item in the array is a // possible value for the state. If a [type@GLib.Variant] pair (ie: two-tuple) is // returned then the tuple specifies the inclusive lower and upper bound // of valid values for the state. // // In any case, the information is merely a hint. It may be possible to // have a state value outside of the hinted range and setting a value // within the range may fail. // // The return value (if non-`NULL`) should be freed with // [method@GLib.Variant.unref] when it is no longer required. func (x *Application) GetActionStateHint(ActionNameVar string) *glib.Variant { cret := gio.XGActionGroupGetActionStateHint(x.GoPointer(), ActionNameVar) return cret } // Queries the type of the state of the named action within // @action_group. // // If the action is stateful then this function returns the // [type@GLib.VariantType] of the state. All calls to // [method@Gio.ActionGroup.change_action_state] must give a [type@GLib.Variant] of this // type and [method@Gio.ActionGroup.get_action_state] will return a [type@GLib.Variant] // of the same type. // // If the action is not stateful then this function will return `NULL`. // In that case, [method@Gio.ActionGroup.get_action_state] will return `NULL` // and you must not call [method@Gio.ActionGroup.change_action_state]. // // The state type of a particular action will never change but it is // possible for an action to be removed and for a new action to be added // with the same name but a different state type. func (x *Application) GetActionStateType(ActionNameVar string) *glib.VariantType { cret := gio.XGActionGroupGetActionStateType(x.GoPointer(), ActionNameVar) return cret } // Checks if the named action exists within @action_group. func (x *Application) HasAction(ActionNameVar string) bool { cret := gio.XGActionGroupHasAction(x.GoPointer(), ActionNameVar) return cret } // Lists the actions contained within @action_group. // // The caller is responsible for freeing the list with [func@GLib.strfreev] when // it is no longer required. func (x *Application) ListActions() []string { cret := gio.XGActionGroupListActions(x.GoPointer()) return cret } // Queries all aspects of the named action within an @action_group. // // This function acquires the information available from // [method@Gio.ActionGroup.has_action], [method@Gio.ActionGroup.get_action_enabled], // [method@Gio.ActionGroup.get_action_parameter_type], // [method@Gio.ActionGroup.get_action_state_type], // [method@Gio.ActionGroup.get_action_state_hint] and // [method@Gio.ActionGroup.get_action_state] with a single function call. // // This provides two main benefits. // // The first is the improvement in efficiency that comes with not having // to perform repeated lookups of the action in order to discover // different things about it. The second is that implementing // [type@Gio.ActionGroup] can now be done by only overriding this one virtual // function. // // The interface provides a default implementation of this function that // calls the individual functions, as required, to fetch the // information. The interface also provides default implementations of // those functions that call this function. All implementations, // therefore, must override either this function or all of the others. // // If the action exists, `TRUE` is returned and any of the requested // fields (as indicated by having a non-`NULL` reference passed in) are // filled. If the action doesn’t exist, `FALSE` is returned and the // fields may or may not have been modified. func (x *Application) QueryAction(ActionNameVar string, EnabledVar *bool, ParameterTypeVar **glib.VariantType, StateTypeVar **glib.VariantType, StateHintVar **glib.Variant, StateVar **glib.Variant) bool { cret := gio.XGActionGroupQueryAction(x.GoPointer(), ActionNameVar, EnabledVar, ParameterTypeVar, StateTypeVar, StateHintVar, StateVar) return cret } // Adds an action to the @action_map. // // If the action map already contains an action with the same name // as @action then the old action is dropped from the action map. // // The action map takes its own reference on @action. func (x *Application) AddAction(ActionVar gio.Action) { gio.XGActionMapAddAction(x.GoPointer(), ActionVar.GoPointer()) } // A convenience function for creating multiple [class@Gio.SimpleAction] // instances and adding them to a [iface@Gio.ActionMap]. // // Each action is constructed as per one [struct@Gio.ActionEntry]. // // ```c // static void // activate_quit (GSimpleAction *simple, // // GVariant *parameter, // gpointer user_data) // // { // exit (0); // } // // static void // activate_print_string (GSimpleAction *simple, // // GVariant *parameter, // gpointer user_data) // // { // g_print ("%s\n", g_variant_get_string (parameter, NULL)); // } // // static GActionGroup * // create_action_group (void) // // { // const GActionEntry entries[] = { // { "quit", activate_quit }, // { "print-string", activate_print_string, "s" } // }; // GSimpleActionGroup *group; // // group = g_simple_action_group_new (); // g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), NULL); // // return G_ACTION_GROUP (group); // } // // ``` func (x *Application) AddActionEntries(EntriesVar []gio.ActionEntry, NEntriesVar int, UserDataVar uintptr) { gio.XGActionMapAddActionEntries(x.GoPointer(), EntriesVar, NEntriesVar, UserDataVar) } // Looks up the action with the name @action_name in @action_map. // // If no such action exists, returns `NULL`. func (x *Application) LookupAction(ActionNameVar string) *gio.ActionBase { var cls *gio.ActionBase cret := gio.XGActionMapLookupAction(x.GoPointer(), ActionNameVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.ActionBase{} cls.Ptr = cret return cls } // Removes the named action from the action map. // // If no action of this name is in the map then nothing happens. func (x *Application) RemoveAction(ActionNameVar string) { gio.XGActionMapRemoveAction(x.GoPointer(), ActionNameVar) } // Remove actions from a [iface@Gio.ActionMap]. This is meant as the reverse of // [method@Gio.ActionMap.add_action_entries]. // // ```c // // static const GActionEntry entries[] = { // { "quit", activate_quit }, // { "print-string", activate_print_string, "s" } // }; // // void // add_actions (GActionMap *map) // // { // g_action_map_add_action_entries (map, entries, G_N_ELEMENTS (entries), NULL); // } // // void // remove_actions (GActionMap *map) // // { // g_action_map_remove_action_entries (map, entries, G_N_ELEMENTS (entries)); // } // // ``` func (x *Application) RemoveActionEntries(EntriesVar []gio.ActionEntry, NEntriesVar int) { gio.XGActionMapRemoveActionEntries(x.GoPointer(), EntriesVar, NEntriesVar) } func init() { core.SetPackageName("ADW", "libadwaita-1") core.SetSharedLibraries("ADW", []string{"libadwaita-1.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("ADW") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xApplicationGLibType, libs, "adw_application_get_type") core.PuregoSafeRegister(&xNewApplication, libs, "adw_application_new") core.PuregoSafeRegister(&xApplicationGetStyleManager, libs, "adw_application_get_style_manager") }