* Authors: Ryan Lortie <desrt@desrt.ca>
*/
+#include "config.h"
#include "gaction.h"
+#include "glibintl.h"
G_DEFINE_TYPE (GAction, g_action, G_TYPE_OBJECT)
*
* @parameter will always be of the expected type. In the event that
* an incorrect type was given, no signal will be emitted.
- **/
+ *
+ * Since: 2.26
+ */
g_action_signals[SIGNAL_ACTIVATE] =
- g_signal_new ("activate", G_TYPE_ACTION, G_SIGNAL_RUN_LAST,
+ g_signal_new (I_("activate"),
+ G_TYPE_ACTION,
+ G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GActionClass, activate),
- NULL, NULL, g_cclosure_marshal_VOID__VARIANT,
- G_TYPE_NONE, 1, G_TYPE_VARIANT);
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VARIANT,
+ G_TYPE_NONE, 1,
+ G_TYPE_VARIANT);
/**
* GAction:name:
*
* The name of the action. This is mostly meaningful for identifying
* the action once it has been added to a #GActionGroup.
+ *
+ * Since: 2.26
**/
g_object_class_install_property (object_class, PROP_NAME,
- g_param_spec_string ("name", "action name",
- "the name used to invoke the action",
- NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ g_param_spec_string ("name",
+ P_("Action Name"),
+ P_("The name used to invoke the action"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GAction:parameter-type:
*
* The type of the parameter that must be given when activating the
* action.
+ *
+ * Since: 2.26
**/
g_object_class_install_property (object_class, PROP_PARAMETER_TYPE,
- g_param_spec_boxed ("parameter-type", "parameter type",
- "the type of GVariant passed to activate()",
- G_TYPE_VARIANT_TYPE, G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ g_param_spec_boxed ("parameter-type",
+ P_("Parameter Type"),
+ P_("The type of GVariant passed to activate()"),
+ G_TYPE_VARIANT_TYPE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GAction:enabled:
*
* If the action is disabled then calls to g_action_activate() and
* g_action_set_state() have no effect.
+ *
+ * Since: 2.26
**/
g_object_class_install_property (object_class, PROP_ENABLED,
- g_param_spec_boolean ("enabled", "enabled",
- "if the action can be activated", TRUE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ g_param_spec_boolean ("enabled",
+ P_("Enabled"),
+ P_("If the action can be activated"),
+ TRUE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* GAction:state-type:
*
* The #GVariantType of the state that the action has, or %NULL if the
* action is stateless.
+ *
+ * Since: 2.26
**/
g_object_class_install_property (object_class, PROP_STATE_TYPE,
- g_param_spec_boxed ("state-type", "state type",
- "the type of the state kept by the action",
- G_TYPE_VARIANT_TYPE, G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ g_param_spec_boxed ("state-type",
+ P_("State Type"),
+ P_("The type of the state kept by the action"),
+ G_TYPE_VARIANT_TYPE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GAction:state:
*
* The state of the action, or %NULL if the action is stateless.
+ *
+ * Since: 2.26
**/
g_object_class_install_property (object_class, PROP_STATE,
- g_param_spec_variant ("state", "state", "the state the action is in",
- G_VARIANT_TYPE_ANY, NULL,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ g_param_spec_variant ("state",
+ P_("State"),
+ P_("The state the action is in"),
+ G_VARIANT_TYPE_ANY,
+ NULL,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
g_type_class_add_private (class, sizeof (GActionPrivate));
}
{
g_return_val_if_fail (G_IS_ACTION (action), NULL);
- return G_ACTION_GET_CLASS (action)
- ->get_state_hint (action);
+ return G_ACTION_GET_CLASS (action)->get_state_hint (action);
}
/**
g_variant_is_of_type (parameter,
action->priv->parameter_type)));
- if (parameter)
+ if (parameter != NULL)
g_variant_ref_sink (parameter);
if (action->priv->enabled)
g_signal_emit (action, g_action_signals[SIGNAL_ACTIVATE], 0, parameter);
- if (parameter)
+ if (parameter != NULL)
g_variant_unref (parameter);
}
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
+#include "config.h"
#include "gactiongroup.h"
+#include "gaction.h"
#include "gio-marshal.h"
+#include "glibintl.h"
/**
* SECTION:gactiongroup
*
* Signals that a new action was just added to the group. This signal
* is emitted after the action has been added and is now visible.
+ *
+ * Since: 2.26
**/
g_action_group_signals[SIGNAL_ACTION_ADDED] =
- g_signal_new ("action-added",
- G_TYPE_ACTION_GROUP, G_SIGNAL_RUN_LAST,
+ g_signal_new (I_("action-added"),
+ G_TYPE_ACTION_GROUP,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GActionGroupClass, action_added),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
/**
* GActionGroup::action-removed:
* Signals that an action is just about to be removed from the group.
* This signal is emitted before the action is removed, so the action
* is still visible and can be queried from the signal handler.
+ *
+ * Since: 2.26
**/
g_action_group_signals[SIGNAL_ACTION_REMOVED] =
- g_signal_new ("action-removed",
- G_TYPE_ACTION_GROUP, G_SIGNAL_RUN_LAST,
+ g_signal_new (I_("action-removed"),
+ G_TYPE_ACTION_GROUP,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GActionGroupClass, action_removed),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
/**
* @enabled: whether the action is enabled or not
*
* Signals that the enabled status of the named action has changed.
+ *
+ * Since: 2.26
**/
g_action_group_signals[SIGNAL_ACTION_ENABLED_CHANGED] =
- g_signal_new ("action-enabled-changed",
- G_TYPE_ACTION_GROUP, G_SIGNAL_RUN_LAST,
+ g_signal_new (I_("action-enabled-changed"),
+ G_TYPE_ACTION_GROUP,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GActionGroupClass, action_enabled_changed),
- NULL, NULL, _gio_marshal_VOID__STRING_BOOLEAN,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ NULL, NULL,
+ _gio_marshal_VOID__STRING_BOOLEAN,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
/**
* GActionGroup::action-state-changed:
* @value: the new value of the state
*
* Signals that the state of the named action has changed.
+ *
+ * Since: 2.26
**/
g_action_group_signals[SIGNAL_ACTION_STATE_CHANGED] =
- g_signal_new ("action-state-changed",
- G_TYPE_ACTION_GROUP, G_SIGNAL_RUN_LAST,
+ g_signal_new (I_("action-state-changed"),
+ G_TYPE_ACTION_GROUP,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (GActionGroupClass, action_state_changed),
- NULL, NULL, _gio_marshal_VOID__STRING_VARIANT,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT);
-
+ NULL, NULL,
+ _gio_marshal_VOID__STRING_VARIANT,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_VARIANT);
}
/**
gchar **
g_action_group_list_actions (GActionGroup *action_group)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->list_actions (action_group);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->list_actions (action_group);
}
/**
g_action_group_has_action (GActionGroup *action_group,
const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->has_action (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), FALSE);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->has_action (action_group, action_name);
}
/**
* possible for an action to be removed and for a new action to be added
* with the same name but a different parameter type.
*
- * Returns: (allow-none): the parameter type
+ * Return value: the parameter type
*
* Since: 2.26
**/
g_action_group_get_parameter_type (GActionGroup *action_group,
const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->get_parameter_type (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->get_parameter_type (action_group, action_name);
}
/**
*
* Since: 2.26
**/
- const GVariantType *
+const GVariantType *
g_action_group_get_state_type (GActionGroup *action_group,
const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->get_state_type (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->get_state_type (action_group, action_name);
}
/**
* The return value (if non-%NULL) should be freed with
* g_variant_unref() when it is no longer required.
*
- * Returns: (allow-none): the state range hint
+ * Return value: the state range hint
*
* Since: 2.26
**/
GVariant *
g_action_group_get_state_hint (GActionGroup *action_group,
- const gchar *action_name)
+ const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->get_state_hint (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->get_state_hint (action_group, action_name);
}
/**
* An action must be enabled in order to be activated or in order to
* have its state changed from outside callers.
*
- * Returns: whether or not the action is currently enabled
+ * Return value: whether or not the action is currently enabled
*
* Since: 2.26
**/
g_action_group_get_enabled (GActionGroup *action_group,
const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->get_enabled (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), FALSE);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->get_enabled (action_group, action_name);
}
/**
* The return value (if non-%NULL) should be freed with
* g_variant_unref() when it is no longer required.
*
- * Returns: (allow-none): the current state of the action
+ * Return value: the current state of the action
*
* Since: 2.26
**/
g_action_group_get_state (GActionGroup *action_group,
const gchar *action_name)
{
- return G_ACTION_GROUP_GET_CLASS (action_group)
- ->get_state (action_group, action_name);
+ g_return_val_if_fail (G_IS_ACTION_GROUP (action_group), NULL);
+
+ return G_ACTION_GROUP_GET_CLASS (action_group)->get_state (action_group, action_name);
}
/**
const gchar *action_name,
GVariant *value)
{
- G_ACTION_GROUP_GET_CLASS (action_group)
- ->set_state (action_group, action_name, value);
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+ g_return_if_fail (value != NULL);
+
+ G_ACTION_GROUP_GET_CLASS (action_group)->set_state (action_group, action_name, value);
}
/**
const gchar *action_name,
GVariant *parameter)
{
- G_ACTION_GROUP_GET_CLASS (action_group)
- ->activate (action_group, action_name, parameter);
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+
+ G_ACTION_GROUP_GET_CLASS (action_group)->activate (action_group, action_name, parameter);
}
/**
* @action_group: a #GActionGroup
* @action_name: the name of an action in the group
*
- * Emits the "action-added" signal on @action_group.
+ * Emits the #GActionGroup::action-added signal on @action_group.
*
* This function should only be called by #GActionGroup implementations.
*
g_action_group_action_added (GActionGroup *action_group,
const gchar *action_name)
{
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+
g_signal_emit (action_group,
g_action_group_signals[SIGNAL_ACTION_ADDED],
- g_quark_try_string (action_name), action_name);
+ g_quark_try_string (action_name),
+ action_name);
}
/**
* @action_group: a #GActionGroup
* @action_name: the name of an action in the group
*
- * Emits the "action-removed" signal on @action_group.
+ * Emits the #GActionGroup::action-removed signal on @action_group.
*
* This function should only be called by #GActionGroup implementations.
*
g_action_group_action_removed (GActionGroup *action_group,
const gchar *action_name)
{
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+
g_signal_emit (action_group,
g_action_group_signals[SIGNAL_ACTION_REMOVED],
- g_quark_try_string (action_name), action_name);
+ g_quark_try_string (action_name),
+ action_name);
}
/**
* @action_name: the name of an action in the group
* @enabled: whether or not the action is now enabled
*
- * Emits the "action-enabled-changed" signal on @action_group.
+ * Emits the #GActionGroup::action-enabled-changed signal on @action_group.
*
* This function should only be called by #GActionGroup implementations.
*
const gchar *action_name,
gboolean enabled)
{
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+
+ enabled = !!enabled;
+
g_signal_emit (action_group,
g_action_group_signals[SIGNAL_ACTION_ENABLED_CHANGED],
- g_quark_try_string (action_name), action_name);
+ g_quark_try_string (action_name),
+ action_name,
+ enabled);
}
/**
* @action_name: the name of an action in the group
* @state: the new state of the named action
*
- * Emits the "action-state-changed" signal on @action_group.
+ * Emits the #GActionGroup::action-state-changed signal on @action_group.
*
* This function should only be called by #GActionGroup implementations.
*
const gchar *action_name,
GVariant *state)
{
+ g_return_if_fail (G_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (action_name != NULL);
+
g_signal_emit (action_group,
g_action_group_signals[SIGNAL_ACTION_STATE_CHANGED],
- g_quark_try_string (action_name), action_name);
+ g_quark_try_string (action_name),
+ action_name,
+ state);
}