TeplActionInfoStore

TeplActionInfoStore — A store of TeplActionInfo's

Functions

Properties

GtkApplication * application Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── TeplActionInfoStore

Includes

#include <tepl/tepl.h>

Description

TeplActionInfoStore contains a set of TeplActionInfo's.

TeplActionInfoStore is add-only, a TeplActionInfo cannot be removed. If needed, the remove operation will be added in the future.

A GtkApplication can be associated so that when a widget is created, gtk_application_set_accels_for_action() is called. See tepl_action_info_store_create_menu_item() for more details. Note that this happens on widget creation, not when adding a TeplActionInfo to the store, so that the accelerator is bound to the application only if the TeplActionInfo is actually used.

TeplActionInfoStore is designed so that libraries can provide their own store, to share action information (with translations) and possibly the GAction implementations as well. Application-specific TeplActionInfo's can be added to the store returned by tepl_application_get_app_action_info_store().

A library TeplActionInfoStore must namespace the action names to not have conflicts when a TeplActionInfo is added to the TeplActionInfoCentralStore. Examples of namespaced action names: "win.tepl-save" or "app.tepl-quit".

Functions

tepl_action_info_store_new ()

TeplActionInfoStore *
tepl_action_info_store_new (GtkApplication *application);

Creates a new TeplActionInfoStore object. Associating a GtkApplication is optional.

Parameters

application

a GtkApplication, or NULL.

[nullable]

Returns

a new TeplActionInfoStore.

Since: 2.0


tepl_action_info_store_get_application ()

GtkApplication *
tepl_action_info_store_get_application
                               (TeplActionInfoStore *store);

Parameters

store

a TeplActionInfoStore.

 

Returns

the associated GtkApplication, or NULL.

[transfer none][nullable]


tepl_action_info_store_add ()

void
tepl_action_info_store_add (TeplActionInfoStore *store,
                            TeplActionInfo *info);

Inserts info into store and into the TeplActionInfoCentralStore. Both the store and central store must not already contain a TeplActionInfo with the same action name. The stores take their own reference on info .

Parameters

store

a TeplActionInfoStore.

 

info

a TeplActionInfo.

 

Since: 2.0


tepl_action_info_store_add_entries ()

void
tepl_action_info_store_add_entries (TeplActionInfoStore *store,
                                    const TeplActionInfoEntry *entries,
                                    gint n_entries,
                                    const gchar *translation_domain);

Calls tepl_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 TeplActionInfo.

An API similar to g_action_map_add_action_entries().

Parameters

store

a TeplActionInfoStore.

 

entries

a pointer to the first item in an array of TeplActionInfoEntry structs.

[array length=n_entries][element-type TeplActionInfoEntry]

n_entries

the length of entries , or -1 if entries is NULL-terminated.

 

translation_domain

a gettext domain, or NULL.

[nullable]

Since: 2.0


tepl_action_info_store_lookup ()

const TeplActionInfo *
tepl_action_info_store_lookup (TeplActionInfoStore *store,
                               const gchar *action_name);

Parameters

store

a TeplActionInfoStore.

 

action_name

an action name.

 

Returns

the found TeplActionInfo, or NULL.

[transfer none]

Since: 2.0


tepl_action_info_store_create_menu_item ()

GtkWidget *
tepl_action_info_store_create_menu_item
                               (TeplActionInfoStore *store,
                                const gchar *action_name);

Creates a new GtkMenuItem for action_name . The store must contain a TeplActionInfo for action_name .

gtk_actionable_set_action_name() is called on the menu item with action_name . The label is set with the “use-underline” property enabled. The first accelerator is set to the GtkAccelLabel of the menu item. The icon is set. And the tooltip is set with tepl_menu_item_set_long_description().

If “application” is non-NULL, this function also calls gtk_application_set_accels_for_action() with the accelerators returned by tepl_action_info_get_accels() (this will erase previously set accelerators for that action, if any).

Parameters

store

a TeplActionInfoStore.

 

action_name

an action name.

 

Returns

a new GtkMenuItem for action_name .

[transfer floating]

Since: 2.0


tepl_action_info_store_check_all_used ()

void
tepl_action_info_store_check_all_used (TeplActionInfoStore *store);

Checks that all TeplActionInfo's of store have been used by tepl_action_info_store_create_menu_item(). If not, a warning is printed and might indicate dead code.

You probably want to call this function on the store returned by tepl_application_get_app_action_info_store(). But it can also be useful for a store provided by a library, to easily see which actions you don't use.

Parameters

store

a TeplActionInfoStore.

 

Since: 2.0

Types and Values

TeplActionInfoStore

typedef struct _TeplActionInfoStore TeplActionInfoStore;

Property Details

The “application” property

  “application”              GtkApplication *

The associated GtkApplication. TeplActionInfoStore has a weak reference to the GtkApplication.

Flags: Read / Write / Construct Only

Since: 2.0

See Also

TeplActionInfo, TeplActionInfoCentralStore