Synopsis#include <gtk/gtk.h> GtkIconInfo; GtkIconTheme; enum GtkIconLookupFlags; #define GTK_ICON_THEME_ERROR enum GtkIconThemeError; GtkIconTheme* gtk_icon_theme_new (void); GtkIconTheme* gtk_icon_theme_get_default (void); GtkIconTheme* gtk_icon_theme_get_for_screen (GdkScreen *screen); void gtk_icon_theme_set_screen (GtkIconTheme *icon_theme, GdkScreen *screen); void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme, const gchar *path[], gint n_elements); void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme, gchar **path[], gint *n_elements); void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme, const gchar *path); void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme, const gchar *path); void gtk_icon_theme_set_custom_theme (GtkIconTheme *icon_theme, const gchar *theme_name); gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme, const gchar *icon_name); GtkIconInfo* gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags); GtkIconInfo* gtk_icon_theme_choose_icon (GtkIconTheme *icon_theme, const gchar *icon_names[], gint size, GtkIconLookupFlags flags); GtkIconInfo* gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme, GIcon *icon, gint size, GtkIconLookupFlags flags); GdkPixbuf* gtk_icon_theme_load_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags, GError **error); GList* gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme); GList* gtk_icon_theme_list_icons (GtkIconTheme *icon_theme, const gchar *context); gint* gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, const gchar *icon_name); char* gtk_icon_theme_get_example_icon_name (GtkIconTheme *icon_theme); gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme); void gtk_icon_theme_add_builtin_icon (const gchar *icon_name, gint size, GdkPixbuf *pixbuf); GtkIconInfo* gtk_icon_info_copy (GtkIconInfo *icon_info); void gtk_icon_info_free (GtkIconInfo *icon_info); GtkIconInfo* gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme, GdkPixbuf *pixbuf); gint gtk_icon_info_get_base_size (GtkIconInfo *icon_info); const gchar* gtk_icon_info_get_filename (GtkIconInfo *icon_info); GdkPixbuf* gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info); GdkPixbuf* gtk_icon_info_load_icon (GtkIconInfo *icon_info, GError **error); void gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info, gboolean raw_coordinates); gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info, GdkRectangle *rectangle); gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info, GdkPoint **points, gint *n_points); const gchar* gtk_icon_info_get_display_name (GtkIconInfo *icon_info); Description
GtkIconTheme provides a facility for looking up icons by name
and size. The main reason for using a name rather than simply
providing a filename is to allow different icons to be used
depending on what icon theme is selecetd
by the user. The operation of icon themes on Linux and Unix
follows the Icon
Theme Specification. There is a default icon theme,
named Named icons are similar to the Themeable Stock Images(3) facility, and the distinction between the two may be a bit confusing. A few things to keep in mind:
A good rule of thumb is that if there is a stock image for what you want to use, use it, otherwise use a named icon. It turns out that internally stock images are generally defined in terms of one or more named icons. (An example of the more than one case is icons that depend on writing direction; GTK_STOCK_GO_FORWARD uses the two themed icons "gtk-stock-go-forward-ltr" and "gtk-stock-go-forward-rtl".) In many cases, named themes are used indirectly, via GtkImage or stock items, rather than directly, but looking up icons directly is also simple. The GtkIconTheme object acts as a database of all the icons in the current theme. You can create new GtkIconTheme objects, but its much more efficient to use the standard icon theme for the GdkScreen so that the icon information is shared with other people looking up icons. In the case where the default screen is being used, looking up an icon can be as simple as: GError *error = NULL; GtkIconTheme *icon_theme; GdkPixbuf *pixbuf; icon_theme = gtk_icon_theme_get_default (); pixbuf = gtk_icon_theme_load_icon (icon_theme, "my-icon-name", /* icon name */ 48, /* size */ 0, /* flags */ &error); if (!pixbuf) { g_warning ("Couldn't load icon: %s", error->message); g_error_free (error); } else { /* Use the pixbuf */ g_object_unref (pixbuf); } DetailsGtkIconInfotypedef struct _GtkIconInfo GtkIconInfo; Contains information found when looking up an icon in an icon theme. GtkIconThemetypedef struct _GtkIconTheme GtkIconTheme;
Acts as a database of information about an icon theme.
Normally, you retrieve the icon theme for a particular
screen using enum GtkIconLookupFlagstypedef enum { GTK_ICON_LOOKUP_NO_SVG = 1 << 0, GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1, GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2, GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3, GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4 } GtkIconLookupFlags;
Used to specify options for
GTK_ICON_THEME_ERROR#define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark () The GQuark used for GtkIconThemeError errors. enum GtkIconThemeErrortypedef enum { GTK_ICON_THEME_NOT_FOUND, GTK_ICON_THEME_FAILED } GtkIconThemeError; Error codes for GtkIconTheme operations.
gtk_icon_theme_new ()GtkIconTheme* gtk_icon_theme_new (void);
Creates a new icon theme object. Icon theme objects are used
to lookup up an icon by name in a particular icon theme.
Usually, you'll want to use
Since 2.4 gtk_icon_theme_get_default ()GtkIconTheme* gtk_icon_theme_get_default (void);
Gets the icon theme for the default screen. See
Since 2.4 gtk_icon_theme_get_for_screen ()GtkIconTheme* gtk_icon_theme_get_for_screen (GdkScreen *screen);
Gets the icon theme object associated with
Since 2.4 gtk_icon_theme_set_screen ()void gtk_icon_theme_set_screen (GtkIconTheme *icon_theme, GdkScreen *screen); Sets the screen for an icon theme; the screen is used to track the user's currently configured icon theme, which might be different for different screens.
Since 2.4 gtk_icon_theme_set_search_path ()void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme, const gchar *path[], gint n_elements);
Sets the search path for the icon theme object. When looking
for an icon theme, GTK+ will search for a subdirectory of
one or more of the directories in
In addition if an icon found isn't found either in the current
icon theme or the default icon theme, and an image file with
the right name is found directly in one of the elements of
Since 2.4 gtk_icon_theme_get_search_path ()void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme, gchar **path[], gint *n_elements);
Gets the current search path. See
Since 2.4 gtk_icon_theme_append_search_path ()void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme, const gchar *path);
Appends a directory to the search path.
See
Since 2.4 gtk_icon_theme_prepend_search_path ()void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme, const gchar *path);
Prepends a directory to the search path.
See
Since 2.4 gtk_icon_theme_set_custom_theme ()void gtk_icon_theme_set_custom_theme (GtkIconTheme *icon_theme, const gchar *theme_name);
Sets the name of the icon theme that the GtkIconTheme object uses
overriding system configuration. This function cannot be called
on the icon theme objects returned from
Since 2.4 gtk_icon_theme_has_icon ()gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme, const gchar *icon_name); Checks whether an icon theme includes an icon for a particular name.
Since 2.4 gtk_icon_theme_lookup_icon ()GtkIconInfo* gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags);
Looks up a named icon and returns a structure containing
information such as the filename of the icon. The icon
can then be rendered into a pixbuf using
Since 2.4 gtk_icon_theme_choose_icon ()GtkIconInfo* gtk_icon_theme_choose_icon (GtkIconTheme *icon_theme, const gchar *icon_names[], gint size, GtkIconLookupFlags flags);
Looks up a named icon and returns a structure containing
information such as the filename of the icon. The icon
can then be rendered into a pixbuf using
If
Since 2.12 gtk_icon_theme_lookup_by_gicon ()GtkIconInfo* gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme, GIcon *icon, gint size, GtkIconLookupFlags flags);
Looks up an icon and returns a structure containing
information such as the filename of the icon.
The icon can then be rendered into a pixbuf using
Since 2.14 gtk_icon_theme_load_icon ()GdkPixbuf* gtk_icon_theme_load_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags, GError **error);
Looks up an icon in an icon theme, scales it to the given size
and renders it into a pixbuf. This is a convenience function;
if more details about the icon are needed, use
Note that you probably want to listen for icon theme changes and
update the icon. This is usually done by connecting to the
GtkWidget::style-set signal. If for some reason you do not want to
update the icon when the icon theme changes, you should consider
using
Since 2.4 gtk_icon_theme_list_contexts ()GList* gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme); Gets the list of contexts available within the current hierarchy of icon themes
Since 2.12 gtk_icon_theme_list_icons ()GList* gtk_icon_theme_list_icons (GtkIconTheme *icon_theme, const gchar *context); Lists the icons in the current icon theme. Only a subset of the icons can be listed by providing a context string. The set of values for the context string is system dependent, but will typically include such values as "Applications" and "MimeTypes".
Since 2.4 gtk_icon_theme_get_icon_sizes ()gint* gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, const gchar *icon_name); Returns an array of integers describing the sizes at which the icon is available without scaling. A size of -1 means that the icon is available in a scalable format. The array is zero-terminated.
Since 2.6 gtk_icon_theme_get_example_icon_name ()char* gtk_icon_theme_get_example_icon_name (GtkIconTheme *icon_theme); Gets the name of an icon that is representative of the current theme (for instance, to use when presenting a list of themes to the user.)
Since 2.4 gtk_icon_theme_rescan_if_needed ()gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
Checks to see if the icon theme has changed; if it has, any
currently cached information is discarded and will be reloaded
next time
Since 2.4 gtk_icon_theme_add_builtin_icon ()void gtk_icon_theme_add_builtin_icon (const gchar *icon_name, gint size, GdkPixbuf *pixbuf); Registers a built-in icon for icon theme lookups. The idea of built-in icons is to allow an application or library that uses themed icons to function requiring files to be present in the file system. For instance, the default images for all of GTK+'s stock icons are registered as built-icons.
In general, if you use
This function will generally be used with pixbufs loaded
via
Since 2.4 gtk_icon_info_copy ()GtkIconInfo* gtk_icon_info_copy (GtkIconInfo *icon_info); Make a copy of a GtkIconInfo.
Since 2.4 gtk_icon_info_free ()void gtk_icon_info_free (GtkIconInfo *icon_info); Free a GtkIconInfo and associated information
Since 2.4 gtk_icon_info_new_for_pixbuf ()GtkIconInfo* gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme, GdkPixbuf *pixbuf); Creates a GtkIconInfo for a GtkPixbuf.
Since 2.14 gtk_icon_info_get_base_size ()gint gtk_icon_info_get_base_size (GtkIconInfo *icon_info); Gets the base size for the icon. The base size is a size for the icon that was specified by the icon theme creator. This may be different than the actual size of image; an example of this is small emblem icons that can be attached to a larger icon. These icons will be given the same base size as the larger icons to which they are attached.
Since 2.4 gtk_icon_info_get_filename ()const gchar* gtk_icon_info_get_filename (GtkIconInfo *icon_info);
Gets the filename for the icon. If the
Since 2.4 gtk_icon_info_get_builtin_pixbuf ()GdkPixbuf* gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info);
Gets the built-in image for this icon, if any. To allow
GTK+ to use built in icon images, you must pass the
Since 2.4 gtk_icon_info_load_icon ()GdkPixbuf* gtk_icon_info_load_icon (GtkIconInfo *icon_info, GError **error);
Renders an icon previously looked up in an icon theme using
Since 2.4 gtk_icon_info_set_raw_coordinates ()void gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info, gboolean raw_coordinates);
Sets whether the coordinates returned by
Raw coordinates are somewhat strange; they are specified to be with
respect to the unscaled pixmap for PNG and XPM icons, but for SVG
icons, they are in a 1000x1000 coordinate space that is scaled
to the final size of the icon. You can determine if the icon is an SVG
icon by using This function is provided primarily to allow compatibility wrappers for older API's, and is not expected to be useful for applications.
Since 2.4 gtk_icon_info_get_embedded_rect ()gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info, GdkRectangle *rectangle);
Gets the coordinates of a rectangle within the icon
that can be used for display of information such
as a preview of the contents of a text file.
See
Since 2.4 gtk_icon_info_get_attach_points ()gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info, GdkPoint **points, gint *n_points); Fetches the set of attach points for an icon. An attach point is a location in the icon that can be used as anchor points for attaching emblems or overlays to the icon.
Since 2.4 gtk_icon_info_get_display_name ()const gchar* gtk_icon_info_get_display_name (GtkIconInfo *icon_info); Gets the display name for an icon. A display name is a string to be used in place of the icon name in a user visible context like a list of icons.
Since 2.4 Signal DetailsThe
|
|
the icon theme |
|
user data set when the signal handler was connected. |