2010-08-18 06:30:44 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2010 Codethink Limited
|
|
|
|
|
*
|
2022-05-18 10:12:45 +02:00
|
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
*
|
2017-05-27 18:21:30 +02:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General
|
2014-01-23 12:58:29 +01:00
|
|
|
|
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* Authors: Ryan Lortie <desrt@desrt.ca>
|
|
|
|
|
*/
|
|
|
|
|
|
2010-08-18 17:54:36 +02:00
|
|
|
|
#include "config.h"
|
2010-08-18 06:30:44 +02:00
|
|
|
|
#include "gactiongroup.h"
|
2010-08-18 17:54:36 +02:00
|
|
|
|
#include "gaction.h"
|
|
|
|
|
#include "glibintl.h"
|
2019-05-31 04:29:18 +02:00
|
|
|
|
#include "gmarshal-internal.h"
|
2010-08-18 06:30:44 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* GActionGroup:
|
|
|
|
|
*
|
|
|
|
|
* `GActionGroup` represents a group of actions.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* Actions can be used to expose functionality in a structured way, either
|
|
|
|
|
* from one part of a program to another, or to the outside world. Action
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* groups are often used together with a [type@Gio.MenuModel] that provides additional
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* representation data for displaying the actions to the user, e.g. in a menu.
|
2011-12-12 06:00:16 +01:00
|
|
|
|
*
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* The main way to interact with the actions in a `GActionGroup` is to
|
|
|
|
|
* activate them with [method@Gio.ActionGroup.activate_action]. Activating an
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* action may require a [type@GLib.Variant] parameter. The required type of the
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* parameter can be inquired with [method@Gio.ActionGroup.get_action_parameter_type].
|
|
|
|
|
* Actions may be disabled, see [method@Gio.ActionGroup.get_action_enabled].
|
2011-12-12 06:00:16 +01:00
|
|
|
|
* Activating a disabled action has no effect.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Actions may optionally have a state in the form of a [type@GLib.Variant]. The current
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* state of an action can be inquired with [method@Gio.ActionGroup.get_action_state].
|
|
|
|
|
* Activating a stateful action may change its state, but it is also possible to
|
|
|
|
|
* set the state by calling [method@Gio.ActionGroup.change_action_state].
|
2011-12-12 06:00:16 +01:00
|
|
|
|
*
|
|
|
|
|
* As typical example, consider a text editing application which has an
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* option to change the current font to ‘bold’. A good way to represent
|
2011-12-12 06:00:16 +01:00
|
|
|
|
* this would be a stateful action, with a boolean state. Activating the
|
|
|
|
|
* action would toggle the state.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* Each action in the group has a unique name (which is a string). All
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* method calls, except [method@Gio.ActionGroup.list_actions] take the name of
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* an action as an argument.
|
|
|
|
|
*
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* The `GActionGroup` API is meant to be the ‘public’ API to the action
|
|
|
|
|
* group. The calls here are exactly the interaction that ‘external
|
|
|
|
|
* forces’ (eg: UI, incoming D-Bus messages, etc.) are supposed to have
|
|
|
|
|
* with actions. ‘Internal’ APIs (ie: ones meant only to be accessed by
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* the action group implementation) are found on subclasses. This is
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* why you will find – for example – [method@Gio.ActionGroup.get_action_enabled]
|
|
|
|
|
* but not an equivalent `set_action_enabled()` method.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* Signals are emitted on the action group in response to state changes
|
|
|
|
|
* on individual actions.
|
2011-11-25 01:52:48 +01:00
|
|
|
|
*
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* Implementations of `GActionGroup` should provide implementations for
|
|
|
|
|
* the virtual functions [method@Gio.ActionGroup.list_actions] and
|
|
|
|
|
* [method@Gio.ActionGroup.query_action]. The other virtual functions should
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* not be implemented — their ‘wrappers’ are actually implemented with
|
2023-09-26 02:44:58 +02:00
|
|
|
|
* calls to [method@Gio.ActionGroup.query_action].
|
2011-12-12 06:00:16 +01:00
|
|
|
|
*/
|
2015-02-05 16:20:43 +01:00
|
|
|
|
|
2011-12-10 23:21:53 +01:00
|
|
|
|
/**
|
|
|
|
|
* GActionGroupInterface:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @has_action: the virtual function pointer for [method@Gio.ActionGroup.has_action]
|
|
|
|
|
* @list_actions: the virtual function pointer for [method@Gio.ActionGroup.list_actions]
|
|
|
|
|
* @get_action_parameter_type: the virtual function pointer for [method@Gio.ActionGroup.get_action_parameter_type]
|
|
|
|
|
* @get_action_state_type: the virtual function pointer for [method@Gio.ActionGroup.get_action_state_type]
|
|
|
|
|
* @get_action_state_hint: the virtual function pointer for [method@Gio.ActionGroup.get_action_state_hint]
|
|
|
|
|
* @get_action_enabled: the virtual function pointer for [method@Gio.ActionGroup.get_action_enabled]
|
|
|
|
|
* @get_action_state: the virtual function pointer for [method@Gio.ActionGroup.get_action_state]
|
|
|
|
|
* @change_action_state: the virtual function pointer for [method@Gio.ActionGroup.change_action_state]
|
|
|
|
|
* @activate_action: the virtual function pointer for [method@Gio.ActionGroup.activate_action]
|
|
|
|
|
* @action_added: the class closure for the [signal@Gio.ActionGroup::action-added] signal
|
|
|
|
|
* @action_removed: the class closure for the [signal@Gio.ActionGroup::action-removed] signal
|
|
|
|
|
* @action_enabled_changed: the class closure for the [signal@Gio.ActionGroup::action-enabled-changed] signal
|
|
|
|
|
* @action_state_changed: the class closure for the [signal@Gio.ActionGroup::action-enabled-changed] signal
|
|
|
|
|
* @query_action: the virtual function pointer for [method@Gio.ActionGroup.query_action]
|
|
|
|
|
*
|
|
|
|
|
* The virtual function table for [type@Gio.ActionGroup].
|
2011-12-10 23:21:53 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.28
|
|
|
|
|
**/
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_DEFINE_INTERFACE (GActionGroup, g_action_group, G_TYPE_OBJECT)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
SIGNAL_ACTION_ADDED,
|
|
|
|
|
SIGNAL_ACTION_REMOVED,
|
|
|
|
|
SIGNAL_ACTION_ENABLED_CHANGED,
|
|
|
|
|
SIGNAL_ACTION_STATE_CHANGED,
|
|
|
|
|
NR_SIGNALS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint g_action_group_signals[NR_SIGNALS];
|
|
|
|
|
|
2011-11-25 01:52:48 +01:00
|
|
|
|
static gboolean
|
|
|
|
|
g_action_group_real_has_action (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
|
|
|
|
return g_action_group_query_action (action_group, action_name, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
g_action_group_real_get_action_enabled (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2023-04-07 14:12:06 +02:00
|
|
|
|
gboolean enabled;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
2023-04-07 14:12:06 +02:00
|
|
|
|
if (!g_action_group_query_action (action_group, action_name, &enabled, NULL, NULL, NULL, NULL))
|
|
|
|
|
return FALSE;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const GVariantType *
|
|
|
|
|
g_action_group_real_get_action_parameter_type (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2023-04-07 14:12:06 +02:00
|
|
|
|
const GVariantType *type;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
2023-04-07 14:12:06 +02:00
|
|
|
|
if (!g_action_group_query_action (action_group, action_name, NULL, &type, NULL, NULL, NULL))
|
|
|
|
|
return NULL;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const GVariantType *
|
|
|
|
|
g_action_group_real_get_action_state_type (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2023-04-07 14:12:06 +02:00
|
|
|
|
const GVariantType *type;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
2023-04-07 14:12:06 +02:00
|
|
|
|
if (!g_action_group_query_action (action_group, action_name, NULL, NULL, &type, NULL, NULL))
|
|
|
|
|
return NULL;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
g_action_group_real_get_action_state_hint (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2023-04-07 14:12:06 +02:00
|
|
|
|
GVariant *hint;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
2023-04-07 14:12:06 +02:00
|
|
|
|
if (!g_action_group_query_action (action_group, action_name, NULL, NULL, NULL, &hint, NULL))
|
|
|
|
|
return NULL;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
return hint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
g_action_group_real_get_action_state (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2023-04-07 14:12:06 +02:00
|
|
|
|
GVariant *state;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
2023-04-07 14:12:06 +02:00
|
|
|
|
if (!g_action_group_query_action (action_group, action_name, NULL, NULL, NULL, NULL, &state))
|
|
|
|
|
return NULL;
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
g_action_group_real_query_action (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
gboolean *enabled,
|
|
|
|
|
const GVariantType **parameter_type,
|
|
|
|
|
const GVariantType **state_type,
|
|
|
|
|
GVariant **state_hint,
|
|
|
|
|
GVariant **state)
|
|
|
|
|
{
|
|
|
|
|
GActionGroupInterface *iface = G_ACTION_GROUP_GET_IFACE (action_group);
|
|
|
|
|
|
|
|
|
|
/* we expect implementations to override this method, but we also
|
|
|
|
|
* allow for implementations that existed before this method was
|
|
|
|
|
* introduced to override the individual accessors instead.
|
|
|
|
|
*
|
|
|
|
|
* detect the case that neither has happened and report it.
|
|
|
|
|
*/
|
|
|
|
|
if G_UNLIKELY (iface->has_action == g_action_group_real_has_action ||
|
|
|
|
|
iface->get_action_enabled == g_action_group_real_get_action_enabled ||
|
|
|
|
|
iface->get_action_parameter_type == g_action_group_real_get_action_parameter_type ||
|
|
|
|
|
iface->get_action_state_type == g_action_group_real_get_action_state_type ||
|
|
|
|
|
iface->get_action_state_hint == g_action_group_real_get_action_state_hint ||
|
|
|
|
|
iface->get_action_state == g_action_group_real_get_action_state)
|
|
|
|
|
{
|
2024-04-12 14:54:22 +02:00
|
|
|
|
g_critical ("Class ‘%s’ implements GActionGroup interface without overriding "
|
|
|
|
|
"query_action() method. Bailing out to avoid infinite recursion.",
|
2011-11-25 01:52:48 +01:00
|
|
|
|
G_OBJECT_TYPE_NAME (action_group));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(* iface->has_action) (action_group, action_name))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (enabled != NULL)
|
|
|
|
|
*enabled = (* iface->get_action_enabled) (action_group, action_name);
|
|
|
|
|
|
|
|
|
|
if (parameter_type != NULL)
|
|
|
|
|
*parameter_type = (* iface->get_action_parameter_type) (action_group, action_name);
|
|
|
|
|
|
|
|
|
|
if (state_type != NULL)
|
|
|
|
|
*state_type = (* iface->get_action_state_type) (action_group, action_name);
|
|
|
|
|
|
|
|
|
|
if (state_hint != NULL)
|
|
|
|
|
*state_hint = (* iface->get_action_state_hint) (action_group, action_name);
|
|
|
|
|
|
|
|
|
|
if (state != NULL)
|
|
|
|
|
*state = (* iface->get_action_state) (action_group, action_name);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
static void
|
2011-11-25 01:52:48 +01:00
|
|
|
|
g_action_group_default_init (GActionGroupInterface *iface)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2011-11-25 01:52:48 +01:00
|
|
|
|
iface->has_action = g_action_group_real_has_action;
|
|
|
|
|
iface->get_action_enabled = g_action_group_real_get_action_enabled;
|
|
|
|
|
iface->get_action_parameter_type = g_action_group_real_get_action_parameter_type;
|
|
|
|
|
iface->get_action_state_type = g_action_group_real_get_action_state_type;
|
|
|
|
|
iface->get_action_state_hint = g_action_group_real_get_action_state_hint;
|
|
|
|
|
iface->get_action_state = g_action_group_real_get_action_state;
|
|
|
|
|
iface->query_action = g_action_group_real_query_action;
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
/**
|
|
|
|
|
* GActionGroup::action-added:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: the [type@Gio.ActionGroup] that changed
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action in @action_group
|
|
|
|
|
*
|
2011-06-05 00:44:44 +02:00
|
|
|
|
* Signals that a new action was just added to the group.
|
2024-04-11 19:50:09 +02:00
|
|
|
|
*
|
2011-06-05 00:44:44 +02:00
|
|
|
|
* This signal is emitted after the action has been added
|
|
|
|
|
* and is now visible.
|
2010-08-18 17:54:36 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_ADDED] =
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_signal_new (I_("action-added"),
|
|
|
|
|
G_TYPE_ACTION_GROUP,
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_STRUCT_OFFSET (GActionGroupInterface, action_added),
|
2010-08-18 17:54:36 +02:00
|
|
|
|
NULL, NULL,
|
2019-05-31 04:13:37 +02:00
|
|
|
|
NULL,
|
2010-08-18 17:54:36 +02:00
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_STRING);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GActionGroup::action-removed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: the [type@Gio.ActionGroup] that changed
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action in @action_group
|
|
|
|
|
*
|
|
|
|
|
* Signals that an action is just about to be removed from the group.
|
2024-04-11 19:50:09 +02:00
|
|
|
|
*
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* This signal is emitted before the action is removed, so the action
|
|
|
|
|
* is still visible and can be queried from the signal handler.
|
2010-08-18 17:54:36 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_REMOVED] =
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_signal_new (I_("action-removed"),
|
|
|
|
|
G_TYPE_ACTION_GROUP,
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_STRUCT_OFFSET (GActionGroupInterface, action_removed),
|
2010-08-18 17:54:36 +02:00
|
|
|
|
NULL, NULL,
|
2019-05-31 04:13:37 +02:00
|
|
|
|
NULL,
|
2010-08-18 17:54:36 +02:00
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_STRING);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GActionGroup::action-enabled-changed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: the [type@Gio.ActionGroup] that changed
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action in @action_group
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* @enabled: whether the action is enabled
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* Signals that the enabled status of the named action has changed.
|
2010-08-18 17:54:36 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_ENABLED_CHANGED] =
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_signal_new (I_("action-enabled-changed"),
|
|
|
|
|
G_TYPE_ACTION_GROUP,
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_STRUCT_OFFSET (GActionGroupInterface,
|
|
|
|
|
action_enabled_changed),
|
2010-08-18 17:54:36 +02:00
|
|
|
|
NULL, NULL,
|
2019-05-31 04:29:18 +02:00
|
|
|
|
_g_cclosure_marshal_VOID__STRING_BOOLEAN,
|
2010-08-18 17:54:36 +02:00
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
|
G_TYPE_STRING,
|
|
|
|
|
G_TYPE_BOOLEAN);
|
2019-05-31 04:29:18 +02:00
|
|
|
|
g_signal_set_va_marshaller (g_action_group_signals[SIGNAL_ACTION_ENABLED_CHANGED],
|
|
|
|
|
G_TYPE_FROM_INTERFACE (iface),
|
|
|
|
|
_g_cclosure_marshal_VOID__STRING_BOOLEANv);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GActionGroup::action-state-changed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: the [type@Gio.ActionGroup] that changed
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action in @action_group
|
|
|
|
|
* @value: the new value of the state
|
|
|
|
|
*
|
|
|
|
|
* Signals that the state of the named action has changed.
|
2010-08-18 17:54:36 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_STATE_CHANGED] =
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_signal_new (I_("action-state-changed"),
|
|
|
|
|
G_TYPE_ACTION_GROUP,
|
2011-03-04 18:21:51 +01:00
|
|
|
|
G_SIGNAL_RUN_LAST |
|
|
|
|
|
G_SIGNAL_DETAILED |
|
|
|
|
|
G_SIGNAL_MUST_COLLECT,
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_STRUCT_OFFSET (GActionGroupInterface,
|
|
|
|
|
action_state_changed),
|
2010-08-18 17:54:36 +02:00
|
|
|
|
NULL, NULL,
|
2019-05-31 04:29:18 +02:00
|
|
|
|
_g_cclosure_marshal_VOID__STRING_VARIANT,
|
2010-08-18 17:54:36 +02:00
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
|
G_TYPE_STRING,
|
|
|
|
|
G_TYPE_VARIANT);
|
2019-05-31 04:29:18 +02:00
|
|
|
|
g_signal_set_va_marshaller (g_action_group_signals[SIGNAL_ACTION_STATE_CHANGED],
|
|
|
|
|
G_TYPE_FROM_INTERFACE (iface),
|
|
|
|
|
_g_cclosure_marshal_VOID__STRING_VARIANTv);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-08-21 21:34:18 +02:00
|
|
|
|
* g_action_group_list_actions:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* Lists the actions contained within @action_group.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* The caller is responsible for freeing the list with [func@GLib.strfreev] when
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* it is no longer required.
|
|
|
|
|
*
|
2024-04-12 14:54:56 +02:00
|
|
|
|
* Returns: (transfer full) (array zero-terminated=1): a `NULL`-terminated array
|
|
|
|
|
* of the names of the actions in the group
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
gchar **
|
|
|
|
|
g_action_group_list_actions (GActionGroup *action_group)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
|
|
|
|
->list_actions (action_group);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_has_action:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to check for
|
|
|
|
|
*
|
|
|
|
|
* Checks if the named action exists within @action_group.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the named action exists
|
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
g_action_group_has_action (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), FALSE);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
|
|
|
|
->has_action (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_get_action_parameter_type:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to query
|
|
|
|
|
*
|
|
|
|
|
* Queries the type of the parameter that must be given when activating
|
|
|
|
|
* the named action within @action_group.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* When activating the action using [method@Gio.ActionGroup.activate_action],
|
|
|
|
|
* the [type@GLib.Variant] given to that function must be of the type returned
|
2011-06-05 00:44:44 +02:00
|
|
|
|
* by this function.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* In the case that this function returns `NULL`, you must not give any
|
|
|
|
|
* [type@GLib.Variant], but `NULL` instead.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2014-05-21 09:27:36 +02:00
|
|
|
|
* Returns: (nullable): the parameter type
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
const GVariantType *
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_get_action_parameter_type (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->get_action_parameter_type (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_get_action_state_type:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to query
|
|
|
|
|
*
|
|
|
|
|
* Queries the type of the state of the named action within
|
|
|
|
|
* @action_group.
|
|
|
|
|
*
|
|
|
|
|
* If the action is stateful then this function returns the
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* [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]
|
2011-06-05 00:44:44 +02:00
|
|
|
|
* of the same type.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* 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].
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2014-05-25 11:21:06 +02:00
|
|
|
|
* Returns: (nullable): the state type, if the action is stateful
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
2010-08-18 17:54:36 +02:00
|
|
|
|
const GVariantType *
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_get_action_state_type (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->get_action_state_type (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_get_action_state_hint:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to query
|
|
|
|
|
*
|
|
|
|
|
* Requests a hint about the valid range of values for the state of the
|
|
|
|
|
* named action within @action_group.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* If `NULL` is returned it either means that the action is not stateful
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* or that there is no hint about the valid range of values for the
|
|
|
|
|
* state of the action.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* 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
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* 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.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* The return value (if non-`NULL`) should be freed with
|
|
|
|
|
* [method@GLib.Variant.unref] when it is no longer required.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2014-05-21 09:27:36 +02:00
|
|
|
|
* Returns: (nullable) (transfer full): the state range hint
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
GVariant *
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_get_action_state_hint (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->get_action_state_hint (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_get_action_enabled:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to query
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* Returns: whether the action is currently enabled
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_get_action_enabled (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), FALSE);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->get_action_enabled (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_get_action_state:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to query
|
|
|
|
|
*
|
|
|
|
|
* Queries the current state of the named action within @action_group.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* If the action is not stateful then `NULL` will be returned. If the
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* action is stateful then the type of the return value is the type
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* given by [method@Gio.ActionGroup.get_action_state_type].
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* The return value (if non-`NULL`) should be freed with
|
|
|
|
|
* [method@GLib.Variant.unref] when it is no longer required.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2019-12-10 21:15:13 +01:00
|
|
|
|
* Returns: (nullable) (transfer full): the current state of the action
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
GVariant *
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_get_action_state (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->get_action_state (action_group, action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 03:41:00 +01:00
|
|
|
|
* g_action_group_change_action_state:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to request the change on
|
|
|
|
|
* @value: the new state
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* See [method@Gio.ActionGroup.get_action_state_type].
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* This call merely requests a change. The action may refuse to change
|
|
|
|
|
* its state or may change its state to something other than @value.
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* See [method@Gio.ActionGroup.get_action_state_hint].
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-08-22 01:11:03 +02:00
|
|
|
|
* If the @value GVariant is floating, it is consumed.
|
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_change_action_state (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
GVariant *value)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->change_action_state (action_group, action_name, value);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-01 02:08:25 +01:00
|
|
|
|
* g_action_group_activate_action:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of the action to activate
|
2016-10-29 03:29:02 +02:00
|
|
|
|
* @parameter: (nullable): parameters to the activation
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* parameters then @parameter must be `NULL`. See
|
|
|
|
|
* [method@Gio.ActionGroup.get_action_parameter_type].
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* If the [type@Gio.ActionGroup] implementation supports asynchronous remote
|
2021-01-08 12:07:16 +01:00
|
|
|
|
* 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,
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* [method@Gio.DBusConnection.flush] should be called prior to the code, which
|
2021-01-08 12:07:16 +01:00
|
|
|
|
* 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
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* example of a ‘quit’ action being activated on the primary app
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* instance over D-Bus. Here [method@Gio.DBusConnection.flush] is called
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* before `exit()`. Without `g_dbus_connection_flush()`, the ‘quit’ action
|
2021-01-08 12:07:16 +01:00
|
|
|
|
* may fail to be activated on the primary instance.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* ```c
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* // call ‘quit’ action on primary instance
|
2021-01-08 12:07:16 +01:00
|
|
|
|
* g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);
|
|
|
|
|
*
|
|
|
|
|
* // make sure the action is activated now
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* g_dbus_connection_flush (…);
|
2021-01-08 12:07:16 +01:00
|
|
|
|
*
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* g_debug ("Application has been terminated. Exiting.");
|
2021-01-08 12:07:16 +01:00
|
|
|
|
*
|
|
|
|
|
* exit (0);
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* ```
|
2021-01-08 12:07:16 +01:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
2010-10-11 16:45:51 +02:00
|
|
|
|
g_action_group_activate_action (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
GVariant *parameter)
|
2010-08-18 06:30:44 +02:00
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
2010-08-30 17:31:06 +02:00
|
|
|
|
G_ACTION_GROUP_GET_IFACE (action_group)
|
2010-10-11 16:45:51 +02:00
|
|
|
|
->activate_action (action_group, action_name, parameter);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_action_added:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of an action in the group
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Emits the [signal@Gio.ActionGroup::action-added] signal on @action_group.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* This function should only be called by [type@Gio.ActionGroup] implementations.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
g_action_group_action_added (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
g_signal_emit (action_group,
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_ADDED],
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_quark_try_string (action_name),
|
|
|
|
|
action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_action_removed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of an action in the group
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Emits the [signal@Gio.ActionGroup::action-removed] signal on @action_group.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* This function should only be called by [type@Gio.ActionGroup] implementations.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
g_action_group_action_removed (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
g_signal_emit (action_group,
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_REMOVED],
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_quark_try_string (action_name),
|
|
|
|
|
action_name);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_action_enabled_changed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of an action in the group
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* @enabled: whether the action is now enabled
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Emits the [signal@Gio.ActionGroup::action-enabled-changed] signal on @action_group.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* This function should only be called by [type@Gio.ActionGroup] implementations.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
g_action_group_action_enabled_changed (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
gboolean enabled)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
|
|
|
|
enabled = !!enabled;
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
g_signal_emit (action_group,
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_ENABLED_CHANGED],
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_quark_try_string (action_name),
|
|
|
|
|
action_name,
|
|
|
|
|
enabled);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_action_state_changed:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2010-08-18 06:30:44 +02:00
|
|
|
|
* @action_name: the name of an action in the group
|
|
|
|
|
* @state: the new state of the named action
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Emits the [signal@Gio.ActionGroup::action-state-changed] signal on @action_group.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* This function should only be called by [type@Gio.ActionGroup] implementations.
|
2010-08-18 06:30:44 +02:00
|
|
|
|
*
|
2010-10-11 21:57:09 +02:00
|
|
|
|
* Since: 2.28
|
2010-08-18 06:30:44 +02:00
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
g_action_group_action_state_changed (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
GVariant *state)
|
|
|
|
|
{
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_return_if_fail (G_IS_ACTION_GROUP (action_group));
|
|
|
|
|
g_return_if_fail (action_name != NULL);
|
|
|
|
|
|
2010-08-18 06:30:44 +02:00
|
|
|
|
g_signal_emit (action_group,
|
|
|
|
|
g_action_group_signals[SIGNAL_ACTION_STATE_CHANGED],
|
2010-08-18 17:54:36 +02:00
|
|
|
|
g_quark_try_string (action_name),
|
|
|
|
|
action_name,
|
|
|
|
|
state);
|
2010-08-18 06:30:44 +02:00
|
|
|
|
}
|
2011-11-25 01:52:48 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_action_group_query_action:
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @action_group: a [type@Gio.ActionGroup]
|
2011-11-25 01:52:48 +01:00
|
|
|
|
* @action_name: the name of an action in the group
|
|
|
|
|
* @enabled: (out): if the action is presently enabled
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* @parameter_type: (out) (transfer none) (optional): the parameter type, or `NULL` if none needed
|
|
|
|
|
* @state_type: (out) (transfer none) (optional): the state type, or `NULL` if stateless
|
|
|
|
|
* @state_hint: (out) (optional): the state hint, or `NULL` if none
|
|
|
|
|
* @state: (out) (optional): the current state, or `NULL` if stateless
|
2011-11-25 01:52:48 +01:00
|
|
|
|
*
|
|
|
|
|
* Queries all aspects of the named action within an @action_group.
|
|
|
|
|
*
|
|
|
|
|
* This function acquires the information available from
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* [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.
|
2011-11-25 01:52:48 +01:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* [type@Gio.ActionGroup] can now be done by only overriding this one virtual
|
2011-11-25 01:52:48 +01:00
|
|
|
|
* 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.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* If the action exists, `TRUE` is returned and any of the requested
|
|
|
|
|
* fields (as indicated by having a non-`NULL` reference passed in) are
|
2024-04-12 14:54:22 +02:00
|
|
|
|
* filled. If the action doesn’t exist, `FALSE` is returned and the
|
2011-11-25 01:52:48 +01:00
|
|
|
|
* fields may or may not have been modified.
|
|
|
|
|
*
|
2024-04-11 19:50:09 +02:00
|
|
|
|
* Returns: `TRUE` if the action exists, else `FALSE`
|
2011-11-25 01:52:48 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.32
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
g_action_group_query_action (GActionGroup *action_group,
|
|
|
|
|
const gchar *action_name,
|
|
|
|
|
gboolean *enabled,
|
|
|
|
|
const GVariantType **parameter_type,
|
|
|
|
|
const GVariantType **state_type,
|
|
|
|
|
GVariant **state_hint,
|
|
|
|
|
GVariant **state)
|
|
|
|
|
{
|
|
|
|
|
return G_ACTION_GROUP_GET_IFACE (action_group)
|
|
|
|
|
->query_action (action_group, action_name, enabled, parameter_type, state_type, state_hint, state);
|
|
|
|
|
}
|