![]() | ![]() | ![]() | GTK+ Reference Manual | ![]() |
---|
GtkActionGroup — a group of actions
#include <gtk/gtk.h> struct GtkActionGroup; GtkActionGroup* gtk_action_group_new (const gchar *name); const gchar* gtk_action_group_get_name (GtkActionGroup *action_group); GtkAction* gtk_action_group_get_action (GtkActionGroup *action_group, const gchar *action_name); GList* gtk_action_group_list_actions (GtkActionGroup *action_group); void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action); void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action); struct GtkActionEntry; void gtk_action_group_add_actions (GtkActionGroup *action_group, GtkActionEntry *entries, guint n_entries, gpointer user_data); void gtk_action_group_add_actions_full (GtkActionGroup *action_group, GtkActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy); struct GtkToggleActionEntry; void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, GtkToggleActionEntry *entries, guint n_entries, gpointer user_data); void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, GtkToggleActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy); struct GtkRadioActionEntry; void gtk_action_group_add_radio_actions (GtkActionGroup *action_group, GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data); void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data, GDestroyNotify destroy); void gtk_action_group_set_translate_func (GtkActionGroup *action_group, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify); void gtk_action_group_set_translation_domain (GtkActionGroup *action_group, const gchar *domain);
GObject +----GtkActionGroup
"name" gchararray : Read / Write / Construct Only
Actions are organised into groups. An action group is essentially a map from names to GtkAction objects.
All actions that would make sense to use in a particular context should be in a single group. Multiple action groups may be used for a particular user interface. In fact, it is expected that most nontrivial applications will make use of multiple groups. For example, in an application that can edit multiple documents, one group holding global actions (e.g. quit, about, new), and one group per document holding actions that act on that document (eg. save, cut/copy/paste, etc). Each window's menus would be constructed from a combination of two action groups.
Accelerators are handled by the GTK+ accelerator map. All actions are assigned an accelerator path (which normally has the form <Actions>/group-name/action-name) and a shortcut is associated with this accelerator path. All menuitems and toolitems take on this accelerator path. The GTK+ accelerator map code makes sure that the correct shortcut is displayed next to the menu item.
struct GtkActionGroup;
The GtkActionGroup struct contains only private members and should not be accessed directly.
GtkActionGroup* gtk_action_group_new (const gchar *name);
Creates a new GtkActionGroup object. The name of the action group is used when associating keybindings with the actions.
name : | the name of the action group. |
Returns : | the new GtkActionGroup |
Since 2.4
const gchar* gtk_action_group_get_name (GtkActionGroup *action_group);
Gets the name of the action group.
action_group : | the action group |
Returns : | the name of the action group. |
Since 2.4
GtkAction* gtk_action_group_get_action (GtkActionGroup *action_group, const gchar *action_name);
Looks up an action in the action group by name.
action_group : | the action group |
action_name : | the name of the action |
Returns : | the action, or NULL if no action by that name exists |
Since 2.4
GList* gtk_action_group_list_actions (GtkActionGroup *action_group);
Lists the actions in the action group.
action_group : | the action group |
Returns : | an allocated list of the action objects in the action group |
Since 2.4
void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action);
Adds an action object to the action group.
action_group : | the action group |
action : | an action |
Since 2.4
void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action);
Removes an action object from the action group.
action_group : | the action group |
action : | an action |
Since 2.4
struct GtkActionEntry { gchar *name; gchar *stock_id; gchar *label; gchar *accelerator; gchar *tooltip; GCallback callback; };
GtkActionEntry structs are used with gtk_action_group_add_actions() to construct actions.
gchar *name | The name of the action. |
gchar *stock_id | The stock id for the action. |
gchar *label | The label for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
gchar *accelerator | The accelerator for the action, in the format understood by gtk_accelerator_parse(). |
gchar *tooltip | The tooltip for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
GCallback callback | The function to call when the action is activated. |
void gtk_action_group_add_actions (GtkActionGroup *action_group, GtkActionEntry *entries, guint n_entries, gpointer user_data);
This is a convenience function to create a number of actions and add them to the action group.
The "activate" signals of the actions are connected to the callbacks and their accel paths are set to <Actions>/group-name/action-name.
action_group : | the action group |
entries : | an array of action descriptions |
n_entries : | the number of entries |
user_data : | data to pass to the action callbacks |
Since 2.4
void gtk_action_group_add_actions_full (GtkActionGroup *action_group, GtkActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
This variant of gtk_action_group_add_actions() adds a GDestroyNotify callback for user_data.
action_group : | the action group |
entries : | an array of action descriptions |
n_entries : | the number of entries |
user_data : | data to pass to the action callbacks |
destroy : | destroy notification callback for user_data |
Since 2.4
struct GtkToggleActionEntry { gchar *name; gchar *stock_id; gchar *label; gchar *accelerator; gchar *tooltip; GCallback callback; gboolean is_active; };
GtkToggleActionEntry structs are used with gtk_action_group_add_toggle_actions() to construct toggle actions.
gchar *name | The name of the action. |
gchar *stock_id | The stock id for the action. |
gchar *label | The label for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
gchar *accelerator | The accelerator for the action, in the format understood by gtk_accelerator_parse(). |
gchar *tooltip | The tooltip for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
GCallback callback | The function to call when the action is activated. |
gboolean is_active | The initial state of the toggle action. |
void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, GtkToggleActionEntry *entries, guint n_entries, gpointer user_data);
This is a convenience function to create a number of toggle actions and add them to the action group.
The "activate" signals of the actions are connected to the callbacks and their accel paths are set to <Actions>/group-name/action-name.
action_group : | the action group |
entries : | an array of toggle action descriptions |
n_entries : | the number of entries |
user_data : | data to pass to the action callbacks |
Since 2.4
void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, GtkToggleActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
This variant of gtk_action_group_add_toggle_actions() adds a GDestroyNotify callback for user_data.
action_group : | the action group |
entries : | an array of toggle action descriptions |
n_entries : | the number of entries |
user_data : | data to pass to the action callbacks |
destroy : | destroy notification callback for user_data |
Since 2.4
struct GtkRadioActionEntry { gchar *name; gchar *stock_id; gchar *label; gchar *accelerator; gchar *tooltip; gint value; };
GtkRadioActionEntry structs are used with gtk_action_group_add_radio_actions() to construct groups of radio actions.
gchar *name | The name of the action. |
gchar *stock_id | The stock id for the action. |
gchar *label | The label for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
gchar *accelerator | The accelerator for the action, in the format understood by gtk_accelerator_parse(). |
gchar *tooltip | The tooltip for the action. This field should typically be marked for translation, see gtk_action_group_set_translation_domain(). |
gint value | The value to set on the radio action. See gtk_radio_action_get_current_value(). |
void gtk_action_group_add_radio_actions (GtkActionGroup *action_group, GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data);
This is a convenience routine to create a group of radio actions and add them to the action group.
The "changed" signal of the first radio action is connected to the on_change callback and the accel paths of the actions are set to <Actions>/group-name/action-name.
action_group : | the action group |
entries : | an array of radio action descriptions |
n_entries : | the number of entries |
value : | the value of the action to activate initially, or -1 if no action should be activated |
on_change : | the callback to connect to the changed signal |
user_data : | data to pass to the action callbacks |
Since 2.4
void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data, GDestroyNotify destroy);
This variant of gtk_action_group_add_radio_actions() adds a GDestroyNotify callback for user_data.
action_group : | the action group |
entries : | an array of radio action descriptions |
n_entries : | the number of entries |
value : | the value of the action to activate initially, or -1 if no action should be activated |
on_change : | the callback to connect to the changed signal |
user_data : | data to pass to the action callbacks |
destroy : | destroy notification callback for user_data |
Since 2.4
void gtk_action_group_set_translate_func (GtkActionGroup *action_group, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify);
Sets a function to be used for translating the label and tooltip of GtkActionGroupEntrys added by gtk_action_group_add_actions().
If you're using gettext(), it is enough to set the translation domain with gtk_action_group_set_translation_domain().
action_group : | a GtkActionGroup |
func : | a GtkTranslateFunc |
data : | data to be passed to func and notify |
notify : | a GtkDestroyNotify function to be called when action_group is destroyed and when the translation function is changed again |
Since 2.4
void gtk_action_group_set_translation_domain (GtkActionGroup *action_group, const gchar *domain);
Sets the translation domain and uses dgettext() for translating the label and tooltip of GtkActionEntrys added by gtk_action_group_add_actions().
If you're not using gettext() for localization, see gtk_action_group_set_translate_func().
action_group : | a GtkActionGroup |
domain : | the translation domain to use for dgettext() calls |
Since 2.4
"name" (gchararray : Read / Write / Construct Only) | A name for the action group. |
<< GtkUIManager | GtkAction >> |