Top |
AmtkActionInfoStoreAmtkActionInfoStore — A store of AmtkActionInfo's |
AmtkActionInfoStore contains a set of AmtkActionInfo's. It is add-only, an AmtkActionInfo cannot be removed.
AmtkActionInfoStore is designed so that libraries can provide their own store, to share action information (with translations) and possibly the GAction implementations as well.
A library AmtkActionInfoStore must namespace the action names to not have
conflicts when an AmtkActionInfo is added to the
AmtkActionInfoCentralStore. Examples of namespaced action names:
"win.amtk-save"
or "app.amtk-quit"
.
An AmtkActionInfoStore is meant to be something static, created on
application startup. See the paragraph about static objects in
AmtkFactory. So once an AmtkActionInfo has
been added to an AmtkActionInfoStore, it is discouraged to modify it
afterwards; an exception is to call amtk_action_info_set_accels()
with
several accelerators after using amtk_action_info_store_add_entries()
(because an AmtkActionInfoEntry can contain only one accelerator).
void amtk_action_info_store_add (AmtkActionInfoStore *store
,AmtkActionInfo *info
);
Inserts info
into store
and into the AmtkActionInfoCentralStore. Both the
store
and central store must not already contain an
AmtkActionInfo with the same action name. The stores take their own
reference on info
.
Since: 2.0
void amtk_action_info_store_add_entries (AmtkActionInfoStore *store
,const AmtkActionInfoEntry *entries
,gint n_entries
,const gchar *translation_domain
);
Calls amtk_action_info_store_add()
for each entry.
If translation_domain
is not NULL
, g_dgettext()
is used to translate the
label
and tooltip
of each entry before setting them to the AmtkActionInfo.
An API similar to g_action_map_add_action_entries()
.
store |
||
entries |
a pointer to the first item in an array of AmtkActionInfoEntry structs. |
[array length=n_entries][element-type AmtkActionInfoEntry] |
n_entries |
the length of |
|
translation_domain |
a gettext domain, or |
[nullable] |
Since: 2.0
AmtkActionInfo * amtk_action_info_store_lookup (AmtkActionInfoStore *store
,const gchar *action_name
);
Since: 2.0
void amtk_action_info_store_set_all_accels_to_app (AmtkActionInfoStore *store
,GtkApplication *application
);
Calls gtk_application_set_accels_for_action()
for all AmtkActionInfo's part
of store
with the accelerators returned by amtk_action_info_get_accels()
.
This function does *not* call amtk_action_info_mark_as_used()
, because if it
did it would not be possible to detect dead code in store
with
amtk_action_info_store_check_all_used()
.
This function is not recommended if store
is provided by a library, because
a future version of the library may add accelerators that are not wanted in
the application. So for a library store, you should let AmtkFactory call
gtk_application_set_accels_for_action()
.
This function can be convenient for an application store, in combination with
AMTK_FACTORY_IGNORE_ACCELS_FOR_APP
(and/or having a NULL
GtkApplication in
AmtkFactory). It has the advantage that
gtk_application_set_accels_for_action()
is called only once per action, not
each time that a GtkApplicationWindow is created.
This function can also be useful if – for some actions – the objects are not created directly with AmtkFactory on application startup, but are created later, on demand. For example to create a GtkShortcutsWindow with AmtkFactory, containing information about actions that are not added to any menu or toolbar.
Since: 5.0
void
amtk_action_info_store_check_all_used (AmtkActionInfoStore *store
);
Checks for each AmtkActionInfo of store
that it has been used (see
amtk_action_info_has_been_used()
). If an AmtkActionInfo has not been used, a
warning is printed and might indicate dead code.
You probably want to call this function on the application store after creating the menu and toolbar. But it can also be useful for a store provided by a library, to easily see which actions are not used by the application.
Since: 2.0