Top |
Functions
void | gtk_stock_add () |
void | gtk_stock_add_static () |
GtkStockItem * | gtk_stock_item_copy () |
void | gtk_stock_item_free () |
GSList * | gtk_stock_list_ids () |
gboolean | gtk_stock_lookup () |
void | gtk_stock_set_translate_func () |
Types and Values
Description
Stock items represent commonly-used menu or toolbar items such as "Open" or "Exit". Each stock item is identified by a stock ID; stock IDs are just strings, but macros such as GTK_STOCK_OPEN are provided to avoid typing mistakes in the strings. Applications can register their own stock items in addition to those built-in to GTK+.
Each stock ID can be associated with a GtkStockItem, which contains the user-visible label, keyboard accelerator, and translation domain of the menu or toolbar item; and/or with an icon stored in a GtkIconFactory. See GtkIconFactory for more information on stock icons. The connection between a GtkStockItem and stock icons is purely conventional (by virtue of using the same stock ID); it's possible to register a stock item but no icon, and vice versa. Stock icons may have a RTL variant which gets used for right-to-left locales.
Functions
gtk_stock_add ()
void gtk_stock_add (const GtkStockItem *items
,guint n_items
);
Registers each of the stock items in items
. If an item already
exists with the same stock ID as one of the items
, the old item
gets replaced. The stock items are copied, so GTK+ does not hold
any pointer into items
and items
can be freed. Use
gtk_stock_add_static()
if items
is persistent and GTK+ need not
copy the array.
Parameters
items |
a GtkStockItem or array of items. |
[array length=n_items] |
n_items |
number of GtkStockItem in |
gtk_stock_add_static ()
void gtk_stock_add_static (const GtkStockItem *items
,guint n_items
);
Same as gtk_stock_add()
, but doesn't copy items
, so
items
must persist until application exit.
Parameters
items |
a GtkStockItem or array of GtkStockItem. |
[array length=n_items] |
n_items |
number of items |
gtk_stock_item_copy ()
GtkStockItem *
gtk_stock_item_copy (const GtkStockItem *item
);
Copies a stock item, mostly useful for language bindings and not in applications.
gtk_stock_item_free ()
void
gtk_stock_item_free (GtkStockItem *item
);
Frees a stock item allocated on the heap, such as one returned by
gtk_stock_item_copy()
. Also frees the fields inside the stock item,
if they are not NULL
.
gtk_stock_list_ids ()
GSList *
gtk_stock_list_ids (void
);
Retrieves a list of all known stock IDs added to a GtkIconFactory
or registered with gtk_stock_add()
. The list must be freed with g_slist_free()
,
and each string in the list must be freed with g_free()
.
gtk_stock_lookup ()
gboolean gtk_stock_lookup (const gchar *stock_id
,GtkStockItem *item
);
Fills item
with the registered values for stock_id
, returning TRUE
if stock_id
was known.
gtk_stock_set_translate_func ()
void gtk_stock_set_translate_func (const gchar *domain
,GtkTranslateFunc func
,gpointer data
,GDestroyNotify notify
);
Sets a function to be used for translating the label
of
a stock item.
If no function is registered for a translation domain,
g_dgettext()
is used.
The function is used for all stock items whose
translation_domain
matches domain
. Note that it is possible
to use strings different from the actual gettext translation domain
of your application for this, as long as your GtkTranslateFunc uses
the correct domain when calling dgettext()
. This can be useful, e.g.
when dealing with message contexts:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
GtkStockItem items[] = { { MY_ITEM1, NC_("odd items", "Item 1"), 0, 0, "odd-item-domain" }, { MY_ITEM2, NC_("even items", "Item 2"), 0, 0, "even-item-domain" }, }; gchar * my_translate_func (const gchar *msgid, gpointer data) { gchar *msgctxt = data; return (gchar*)g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msgid); } /* ... */ gtk_stock_add (items, G_N_ELEMENTS (items)); gtk_stock_set_translate_func ("odd-item-domain", my_translate_func, "odd items"); gtk_stock_set_translate_func ("even-item-domain", my_translate_func, "even items"); |
Parameters
domain |
the translation domain for which |
|
func |
||
data |
data to pass to |
|
notify |
a GDestroyNotify that is called when |
Since 2.8
Types and Values
struct GtkStockItem
struct GtkStockItem { gchar *stock_id; gchar *label; GdkModifierType modifier; guint keyval; gchar *translation_domain; };
GTK_STOCK_CAPS_LOCK_WARNING
#define GTK_STOCK_CAPS_LOCK_WARNING "gtk-caps-lock-warning"
The "Caps Lock Warning" icon.
Since 2.16
GTK_STOCK_COLOR_PICKER
#define GTK_STOCK_COLOR_PICKER "gtk-color-picker"
The "Color Picker" item.
Since 2.2
GTK_STOCK_DIALOG_AUTHENTICATION
#define GTK_STOCK_DIALOG_AUTHENTICATION "gtk-dialog-authentication"
The "Authentication" item.
Since 2.4
GTK_STOCK_DIALOG_QUESTION
#define GTK_STOCK_DIALOG_QUESTION "gtk-dialog-question"
The "Question" item.
GTK_STOCK_DND_MULTIPLE
#define GTK_STOCK_DND_MULTIPLE "gtk-dnd-multiple"
The "Drag-And-Drop multiple" icon.
GTK_STOCK_FIND_AND_REPLACE
#define GTK_STOCK_FIND_AND_REPLACE "gtk-find-and-replace"
The "Find and Replace" item.
GTK_STOCK_LEAVE_FULLSCREEN
#define GTK_STOCK_LEAVE_FULLSCREEN "gtk-leave-fullscreen"
The "Leave Fullscreen" item.
Since 2.8
GTK_STOCK_MEDIA_FORWARD
#define GTK_STOCK_MEDIA_FORWARD "gtk-media-forward"
The "Media Forward" item.
RTL variant
Since 2.6
GTK_STOCK_MEDIA_NEXT
#define GTK_STOCK_MEDIA_NEXT "gtk-media-next"
The "Media Next" item.
RTL variant
Since 2.6
GTK_STOCK_MEDIA_PAUSE
#define GTK_STOCK_MEDIA_PAUSE "gtk-media-pause"
The "Media Pause" item.
Since 2.6
GTK_STOCK_MEDIA_PLAY
#define GTK_STOCK_MEDIA_PLAY "gtk-media-play"
The "Media Play" item.
RTL variant
Since 2.6
GTK_STOCK_MEDIA_PREVIOUS
#define GTK_STOCK_MEDIA_PREVIOUS "gtk-media-previous"
The "Media Previous" item.
RTL variant
Since 2.6
GTK_STOCK_MEDIA_RECORD
#define GTK_STOCK_MEDIA_RECORD "gtk-media-record"
The "Media Record" item.
Since 2.6
GTK_STOCK_MEDIA_REWIND
#define GTK_STOCK_MEDIA_REWIND "gtk-media-rewind"
The "Media Rewind" item.
RTL variant
Since 2.6
GTK_STOCK_MISSING_IMAGE
#define GTK_STOCK_MISSING_IMAGE "gtk-missing-image"
The "Missing image" icon.
GTK_STOCK_ORIENTATION_LANDSCAPE
#define GTK_STOCK_ORIENTATION_LANDSCAPE "gtk-orientation-landscape"
The "Landscape Orientation" item.
Since 2.10
GTK_STOCK_ORIENTATION_PORTRAIT
#define GTK_STOCK_ORIENTATION_PORTRAIT "gtk-orientation-portrait"
The "Portrait Orientation" item.
Since 2.10
GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE
#define GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE "gtk-orientation-reverse-landscape"
The "Reverse Landscape Orientation" item.
Since 2.10
GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT
#define GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT "gtk-orientation-reverse-portrait"
The "Reverse Portrait Orientation" item.
Since 2.10
GTK_STOCK_PAGE_SETUP
#define GTK_STOCK_PAGE_SETUP "gtk-page-setup"
The "Page Setup" item.
Since 2.14
GTK_STOCK_PRINT_ERROR
#define GTK_STOCK_PRINT_ERROR "gtk-print-error"
The "Print Error" icon.
Since 2.14
GTK_STOCK_PRINT_PAUSED
#define GTK_STOCK_PRINT_PAUSED "gtk-print-paused"
The "Print Paused" icon.
Since 2.14
GTK_STOCK_PRINT_PREVIEW
#define GTK_STOCK_PRINT_PREVIEW "gtk-print-preview"
The "Print Preview" item.
GTK_STOCK_PRINT_REPORT
#define GTK_STOCK_PRINT_REPORT "gtk-print-report"
The "Print Report" icon.
Since 2.14
GTK_STOCK_PRINT_WARNING
#define GTK_STOCK_PRINT_WARNING "gtk-print-warning"
The "Print Warning" icon.
Since 2.14
GTK_STOCK_REVERT_TO_SAVED
#define GTK_STOCK_REVERT_TO_SAVED "gtk-revert-to-saved"
The "Revert" item.
RTL variant
GTK_STOCK_SELECT_ALL
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
The "Select All" item.
Since 2.10
GTK_STOCK_SORT_ASCENDING
#define GTK_STOCK_SORT_ASCENDING "gtk-sort-ascending"
The "Ascending" item.
GTK_STOCK_SORT_DESCENDING
#define GTK_STOCK_SORT_DESCENDING "gtk-sort-descending"
The "Descending" item.
GTK_STOCK_STRIKETHROUGH
#define GTK_STOCK_STRIKETHROUGH "gtk-strikethrough"
The "Strikethrough" item.
GTK_STOCK_UNINDENT
#define GTK_STOCK_UNINDENT "gtk-unindent"
The "Unindent" item.
RTL variant
Since 2.4