![]() |
![]() |
![]() |
GIO Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces |
Synopsis
GSimpleActionGroup; GSimpleActionGroup * g_simple_action_group_new (void
); GAction * g_simple_action_group_lookup (GSimpleActionGroup *simple
,const gchar *action_name
); void g_simple_action_group_insert (GSimpleActionGroup *simple
,GAction *action
); void g_simple_action_group_remove (GSimpleActionGroup *simple
,const gchar *action_name
); struct GActionEntry; void g_simple_action_group_add_entries (GSimpleActionGroup *simple
,const GActionEntry *entries
,gint n_entries
,gpointer user_data
);
Description
GSimpleActionGroup is a hash table filled with GAction objects, implementing the GActionGroup interface.
Details
GSimpleActionGroup
typedef struct _GSimpleActionGroup GSimpleActionGroup;
The GSimpleActionGroup structure contains private data and should only be accessed using the provided API.
Since 2.28
g_simple_action_group_new ()
GSimpleActionGroup * g_simple_action_group_new (void
);
Creates a new, empty, GSimpleActionGroup.
Returns : |
a new GSimpleActionGroup |
Since 2.28
g_simple_action_group_lookup ()
GAction * g_simple_action_group_lookup (GSimpleActionGroup *simple
,const gchar *action_name
);
Looks up the action with the name action_name
in the group.
If no such action exists, returns NULL
.
|
a GSimpleActionGroup |
|
the name of an action |
Returns : |
a GAction, or NULL . [transfer none]
|
Since 2.28
g_simple_action_group_insert ()
void g_simple_action_group_insert (GSimpleActionGroup *simple
,GAction *action
);
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
.
|
a GSimpleActionGroup |
|
a GAction |
Since 2.28
g_simple_action_group_remove ()
void g_simple_action_group_remove (GSimpleActionGroup *simple
,const gchar *action_name
);
Removes the named action from the action group.
If no action of this name is in the group then nothing happens.
|
a GSimpleActionGroup |
|
the name of the action |
Since 2.28
struct GActionEntry
struct GActionEntry { const gchar *name; void (* activate) (GSimpleAction *action, GVariant *parameter, gpointer user_data); const gchar *parameter_type; const gchar *state; void (* change_state) (GSimpleAction *action, GVariant *value, gpointer user_data); };
This struct defines a single action. It is for use with
g_simple_action_group_add_entries()
.
The order of the items in the structure are intended to reflect
frequency of use. It is permissible to use an incomplete initialiser
in order to leave some of the later values as NULL
. All values
after name
are optional. Additional optional fields may be added in
the future.
See g_simple_action_group_add_entries()
for an example.
const gchar * |
the name of the action |
the callback to connect to the "activate" signal of the action | |
const gchar * |
the type of the parameter that must be passed to the
activate function for this action, given as a single
GVariant type string (or NULL for no parameter) |
const gchar * |
the initial state for this action, given in GVariant text format. The state is parsed with no extra type information, so type tags must be added to the string if they are necessary. |
the callback to connect to the "change-state" signal of the action |
g_simple_action_group_add_entries ()
void g_simple_action_group_add_entries (GSimpleActionGroup *simple
,const GActionEntry *entries
,gint n_entries
,gpointer user_data
);
A convenience function for creating multiple GSimpleAction instances and adding them to the action group.
Each action is constructed as per one GActionEntry.
Example 13. Using g_simple_action_group_add_entries()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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_simple_action_group_add_entries (group, entries, G_N_ELEMENTS (entries), NULL); return G_ACTION_GROUP (group); } |
|
a GSimpleActionGroup |
|
a pointer to the first item in an array of GActionEntry structs |
|
the length of entries , or -1 |
|
the user data for signal connections |
Since 2.30