// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type SimpleActionGroupClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass Padding [12]uintptr } func (x *SimpleActionGroupClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } type SimpleActionGroupPrivate struct { _ structs.HostLayout } func (x *SimpleActionGroupPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // `GSimpleActionGroup` is a hash table filled with [iface@Gio.Action] objects, // implementing the [iface@Gio.ActionGroup] and [iface@Gio.ActionMap] // interfaces. type SimpleActionGroup struct { gobject.Object } var xSimpleActionGroupGLibType func() types.GType func SimpleActionGroupGLibType() types.GType { return xSimpleActionGroupGLibType() } func SimpleActionGroupNewFromInternalPtr(ptr uintptr) *SimpleActionGroup { cls := &SimpleActionGroup{} cls.Ptr = ptr return cls } var xNewSimpleActionGroup func() uintptr // Creates a new, empty, #GSimpleActionGroup. func NewSimpleActionGroup() *SimpleActionGroup { var cls *SimpleActionGroup cret := xNewSimpleActionGroup() if cret == 0 { return nil } cls = &SimpleActionGroup{} cls.Ptr = cret return cls } var xSimpleActionGroupAddEntries func(uintptr, []ActionEntry, int, uintptr) // A convenience function for creating multiple #GSimpleAction instances // and adding them to the action group. func (x *SimpleActionGroup) AddEntries(EntriesVar []ActionEntry, NEntriesVar int, UserDataVar uintptr) { xSimpleActionGroupAddEntries(x.GoPointer(), EntriesVar, NEntriesVar, UserDataVar) } var xSimpleActionGroupInsert func(uintptr, uintptr) // Adds an action to the action group. // // If the action group already contains an action with the same name as // @action then the old action is dropped from the group. // // The action group takes its own reference on @action. func (x *SimpleActionGroup) Insert(ActionVar Action) { xSimpleActionGroupInsert(x.GoPointer(), ActionVar.GoPointer()) } var xSimpleActionGroupLookup func(uintptr, string) uintptr // Looks up the action with the name @action_name in the group. // // If no such action exists, returns %NULL. func (x *SimpleActionGroup) Lookup(ActionNameVar string) *ActionBase { var cls *ActionBase cret := xSimpleActionGroupLookup(x.GoPointer(), ActionNameVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ActionBase{} cls.Ptr = cret return cls } var xSimpleActionGroupRemove func(uintptr, string) // Removes the named action from the action group. // // If no action of this name is in the group then nothing happens. func (x *SimpleActionGroup) Remove(ActionNameVar string) { xSimpleActionGroupRemove(x.GoPointer(), ActionNameVar) } func (c *SimpleActionGroup) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *SimpleActionGroup) 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 *SimpleActionGroup) ActionAdded(ActionNameVar string) { 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 *SimpleActionGroup) ActionEnabledChanged(ActionNameVar string, EnabledVar bool) { 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 *SimpleActionGroup) ActionRemoved(ActionNameVar string) { 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 *SimpleActionGroup) ActionStateChanged(ActionNameVar string, StateVar *glib.Variant) { 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 *SimpleActionGroup) ActivateAction(ActionNameVar string, ParameterVar *glib.Variant) { 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 *SimpleActionGroup) ChangeActionState(ActionNameVar string, ValueVar *glib.Variant) { 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 *SimpleActionGroup) GetActionEnabled(ActionNameVar string) bool { cret := 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 *SimpleActionGroup) GetActionParameterType(ActionNameVar string) *glib.VariantType { cret := 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 *SimpleActionGroup) GetActionState(ActionNameVar string) *glib.Variant { cret := 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 *SimpleActionGroup) GetActionStateHint(ActionNameVar string) *glib.Variant { cret := 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 *SimpleActionGroup) GetActionStateType(ActionNameVar string) *glib.VariantType { cret := XGActionGroupGetActionStateType(x.GoPointer(), ActionNameVar) return cret } // Checks if the named action exists within @action_group. func (x *SimpleActionGroup) HasAction(ActionNameVar string) bool { cret := 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 *SimpleActionGroup) ListActions() []string { cret := 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 *SimpleActionGroup) QueryAction(ActionNameVar string, EnabledVar *bool, ParameterTypeVar **glib.VariantType, StateTypeVar **glib.VariantType, StateHintVar **glib.Variant, StateVar **glib.Variant) bool { cret := 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 *SimpleActionGroup) AddAction(ActionVar Action) { 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 *SimpleActionGroup) AddActionEntries(EntriesVar []ActionEntry, NEntriesVar int, UserDataVar uintptr) { 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 *SimpleActionGroup) LookupAction(ActionNameVar string) *ActionBase { var cls *ActionBase cret := XGActionMapLookupAction(x.GoPointer(), ActionNameVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &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 *SimpleActionGroup) RemoveAction(ActionNameVar string) { 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 *SimpleActionGroup) RemoveActionEntries(EntriesVar []ActionEntry, NEntriesVar int) { XGActionMapRemoveActionEntries(x.GoPointer(), EntriesVar, NEntriesVar) } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xSimpleActionGroupGLibType, libs, "g_simple_action_group_get_type") core.PuregoSafeRegister(&xNewSimpleActionGroup, libs, "g_simple_action_group_new") core.PuregoSafeRegister(&xSimpleActionGroupAddEntries, libs, "g_simple_action_group_add_entries") core.PuregoSafeRegister(&xSimpleActionGroupInsert, libs, "g_simple_action_group_insert") core.PuregoSafeRegister(&xSimpleActionGroupLookup, libs, "g_simple_action_group_lookup") core.PuregoSafeRegister(&xSimpleActionGroupRemove, libs, "g_simple_action_group_remove") }