GtkIconTheme

GtkIconTheme — Looking up icons by name

Functions

GtkIconTheme * gtk_icon_theme_new ()
GtkIconTheme * gtk_icon_theme_get_default ()
GtkIconTheme * gtk_icon_theme_get_for_screen ()
void gtk_icon_theme_set_screen ()
void gtk_icon_theme_set_search_path ()
void gtk_icon_theme_get_search_path ()
void gtk_icon_theme_append_search_path ()
void gtk_icon_theme_prepend_search_path ()
void gtk_icon_theme_add_resource_path ()
void gtk_icon_theme_set_custom_theme ()
gboolean gtk_icon_theme_has_icon ()
GtkIconInfo * gtk_icon_theme_lookup_icon ()
GtkIconInfo * gtk_icon_theme_lookup_icon_for_scale ()
GtkIconInfo * gtk_icon_theme_choose_icon ()
GtkIconInfo * gtk_icon_theme_choose_icon_for_scale ()
GtkIconInfo * gtk_icon_theme_lookup_by_gicon ()
GtkIconInfo * gtk_icon_theme_lookup_by_gicon_for_scale ()
GdkPixbuf * gtk_icon_theme_load_icon ()
GdkPixbuf * gtk_icon_theme_load_icon_for_scale ()
cairo_surface_t * gtk_icon_theme_load_surface ()
GList * gtk_icon_theme_list_contexts ()
GList * gtk_icon_theme_list_icons ()
gint * gtk_icon_theme_get_icon_sizes ()
char * gtk_icon_theme_get_example_icon_name ()
gboolean gtk_icon_theme_rescan_if_needed ()
void gtk_icon_theme_add_builtin_icon ()
GtkIconInfo * gtk_icon_info_copy ()
void gtk_icon_info_free ()
GtkIconInfo * gtk_icon_info_new_for_pixbuf ()
gint gtk_icon_info_get_base_size ()
gint gtk_icon_info_get_base_scale ()
const gchar * gtk_icon_info_get_filename ()
GdkPixbuf * gtk_icon_info_get_builtin_pixbuf ()
GdkPixbuf * gtk_icon_info_load_icon ()
cairo_surface_t * gtk_icon_info_load_surface ()
void gtk_icon_info_load_icon_async ()
GdkPixbuf * gtk_icon_info_load_icon_finish ()
GdkPixbuf * gtk_icon_info_load_symbolic ()
void gtk_icon_info_load_symbolic_async ()
GdkPixbuf * gtk_icon_info_load_symbolic_finish ()
GdkPixbuf * gtk_icon_info_load_symbolic_for_style ()
GdkPixbuf * gtk_icon_info_load_symbolic_for_context ()
void gtk_icon_info_load_symbolic_for_context_async ()
GdkPixbuf * gtk_icon_info_load_symbolic_for_context_finish ()
void gtk_icon_info_set_raw_coordinates ()
gboolean gtk_icon_info_get_embedded_rect ()
gboolean gtk_icon_info_get_attach_points ()
const gchar * gtk_icon_info_get_display_name ()
gboolean gtk_icon_info_is_symbolic ()

Signals

Types and Values

Object Hierarchy

    GObject
    ╰── GtkIconTheme

Includes

#include <gtk/gtk.h>

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 selected by the user. The operation of icon themes on Linux and Unix follows the Icon Theme Specification There is a fallback icon theme, named hicolor, where applications should install their icons, but additional icon themes can be installed as operating system vendors and users choose.

Named icons are similar to the deprecated Stock Items, and the distinction between the two may be a bit confusing. A few things to keep in mind:

  • Stock images usually are used in conjunction with Stock Items, such as GTK_STOCK_OK or GTK_STOCK_OPEN. Named icons are easier to set up and therefore are more useful for new icons that an application wants to add, such as application icons or window icons.

  • Stock images can only be loaded at the symbolic sizes defined by the GtkIconSize enumeration, or by custom sizes defined by gtk_icon_size_register(), while named icons are more flexible and any pixel size can be specified.

  • Because stock images are closely tied to stock items, and thus to actions in the user interface, stock images may come in multiple variants for different widget states or writing directions.

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 it’s 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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, // icon 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);
  }

Functions

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 gtk_icon_theme_get_default() or gtk_icon_theme_get_for_screen() rather than creating a new icon theme object for scratch.

Returns

the newly created GtkIconTheme object.

Since: 2.4


gtk_icon_theme_get_default ()

GtkIconTheme *
gtk_icon_theme_get_default (void);

Gets the icon theme for the default screen. See gtk_icon_theme_get_for_screen().

Returns

A unique GtkIconTheme associated with the default screen. This icon theme is associated with the screen and can be used as long as the screen is open. Do not ref or unref it.

[transfer none]

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 screen ; if this function has not previously been called for the given screen, a new icon theme object will be created and associated with the screen. Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than gtk_icon_theme_new() and setting the screen yourself; by using this function a single icon theme object will be shared between users.

Parameters

screen

a GdkScreen

 

Returns

A unique GtkIconTheme associated with the given screen. This icon theme is associated with the screen and can be used as long as the screen is open. Do not ref or unref it.

[transfer none]

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.

Parameters

icon_theme

a GtkIconTheme

 

screen

a GdkScreen

 

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 path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)

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 path , then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)

Parameters

icon_theme

a GtkIconTheme

 

path

array of directories that are searched for icon themes.

[array length=n_elements][element-type filename]

n_elements

number of elements in path .

 

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 gtk_icon_theme_set_search_path().

Parameters

icon_theme

a GtkIconTheme

 

path

location to store a list of icon theme path directories or NULL. The stored value should be freed with g_strfreev().

[allow-none][array length=n_elements][element-type filename][out]

n_elements

location to store number of elements in path , or NULL

 

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 gtk_icon_theme_set_search_path().

Parameters

icon_theme

a GtkIconTheme

 

path

directory name to append to the icon path.

[type filename]

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 gtk_icon_theme_set_search_path().

Parameters

icon_theme

a GtkIconTheme

 

path

directory name to prepend to the icon path.

[type filename]

Since: 2.4


gtk_icon_theme_add_resource_path ()

void
gtk_icon_theme_add_resource_path (GtkIconTheme *icon_theme,
                                  const gchar *path);

Adds a resource path that will be looked at when looking for icons, similar to search paths.

This function should be used to make application-specific icons available as part of the icon theme.

The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as @path/16x16/actions/run.png. Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback.

Parameters

icon_theme

a GtkIconTheme

 

path

a resource path

 

Since: 3.14


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 gtk_icon_theme_get_default() and gtk_icon_theme_get_for_screen().

Parameters

icon_theme

a GtkIconTheme

 

theme_name

name of icon theme to use instead of configured theme, or NULL to unset a previously set custom theme.

[allow-none]

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.

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of an icon

 

Returns

TRUE if icon_theme includes an icon for icon_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 GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines these two steps if all you need is the pixbuf.)

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of the icon to lookup

 

size

desired icon size

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo object containing information about the icon, or NULL if the icon wasn’t found.

[nullable][transfer full]

Since: 2.4


gtk_icon_theme_lookup_icon_for_scale ()

GtkIconInfo *
gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme,
                                      const gchar *icon_name,
                                      gint size,
                                      gint scale,
                                      GtkIconLookupFlags flags);

Looks up a named icon for a particular window scale and returns a GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines these two steps if all you need is the pixbuf.)

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of the icon to lookup

 

size

desired icon size

 

scale

the desired scale

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo object containing information about the icon, or NULL if the icon wasn’t found.

[nullable][transfer full]

Since: 3.10


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 GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Parameters

icon_theme

a GtkIconTheme

 

icon_names

NULL-terminated array of icon names to lookup.

[array zero-terminated=1]

size

desired icon size

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo object containing information about the icon, or NULL if the icon wasn’t found.

[nullable][transfer full]

Since: 2.12


gtk_icon_theme_choose_icon_for_scale ()

GtkIconInfo *
gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *icon_theme,
                                      const gchar *icon_names[],
                                      gint size,
                                      gint scale,
                                      GtkIconLookupFlags flags);

Looks up a named icon for a particular window scale and returns a GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Parameters

icon_theme

a GtkIconTheme

 

icon_names

NULL-terminated array of icon names to lookup.

[array zero-terminated=1]

size

desired icon size

 

scale

desired scale

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo object containing information about the icon, or NULL if the icon wasn’t found.

[nullable][transfer full]

Since: 3.10


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 GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon().

Parameters

icon_theme

a GtkIconTheme

 

icon

the GIcon to look up

 

size

desired icon size

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo containing information about the icon, or NULL if the icon wasn’t found. Unref with g_object_unref().

[nullable][transfer full]

Since: 2.14


gtk_icon_theme_lookup_by_gicon_for_scale ()

GtkIconInfo *
gtk_icon_theme_lookup_by_gicon_for_scale
                               (GtkIconTheme *icon_theme,
                                GIcon *icon,
                                gint size,
                                gint scale,
                                GtkIconLookupFlags flags);

Looks up an icon and returns a GtkIconInfo containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon().

Parameters

icon_theme

a GtkIconTheme

 

icon

the GIcon to look up

 

size

desired icon size

 

scale

the desired scale

 

flags

flags modifying the behavior of the icon lookup

 

Returns

a GtkIconInfo containing information about the icon, or NULL if the icon wasn’t found. Unref with g_object_unref().

[nullable][transfer full]

Since: 3.10


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 gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_icon().

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 gdk_pixbuf_copy() to make a private copy of the pixbuf returned by this function. Otherwise GTK+ may need to keep the old icon theme loaded, which would be a waste of memory.

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of the icon to lookup

 

size

the desired icon size. The resulting icon may not be exactly this size; see gtk_icon_info_load_icon().

 

flags

flags modifying the behavior of the icon lookup

 

error

Location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. NULL if the icon isn’t found.

[nullable][transfer full]

Since: 2.4


gtk_icon_theme_load_icon_for_scale ()

GdkPixbuf *
gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
                                    const gchar *icon_name,
                                    gint size,
                                    gint scale,
                                    GtkIconLookupFlags flags,
                                    GError **error);

Looks up an icon in an icon theme for a particular window scale, 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 gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_icon().

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 gdk_pixbuf_copy() to make a private copy of the pixbuf returned by this function. Otherwise GTK+ may need to keep the old icon theme loaded, which would be a waste of memory.

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of the icon to lookup

 

size

the desired icon size. The resulting icon may not be exactly this size; see gtk_icon_info_load_icon().

 

scale

desired scale

 

flags

flags modifying the behavior of the icon lookup

 

error

Location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. NULL if the icon isn’t found.

[nullable][transfer full]

Since: 3.10


gtk_icon_theme_load_surface ()

cairo_surface_t *
gtk_icon_theme_load_surface (GtkIconTheme *icon_theme,
                             const gchar *icon_name,
                             gint size,
                             gint scale,
                             GdkWindow *for_window,
                             GtkIconLookupFlags flags,
                             GError **error);

Looks up an icon in an icon theme for a particular window scale, scales it to the given size and renders it into a cairo surface. This is a convenience function; if more details about the icon are needed, use gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_surface().

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.

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of the icon to lookup

 

size

the desired icon size. The resulting icon may not be exactly this size; see gtk_icon_info_load_icon().

 

scale

desired scale

 

for_window

GdkWindow to optimize drawing for, or NULL.

[allow-none]

flags

flags modifying the behavior of the icon lookup

 

error

Location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use cairo_surface_destroy() to release your reference to the icon. NULL if the icon isn’t found.

[nullable][transfer full]

Since: 3.10


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. See gtk_icon_theme_list_icons() for details about contexts.

Parameters

icon_theme

a GtkIconTheme

 

Returns

a GList list holding the names of all the contexts in the theme. You must first free each element in the list with g_free(), then free the list itself with g_list_free().

[element-type utf8][transfer full]

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”. Contexts are explained in the Icon Theme Specification. The standard contexts are listed in the Icon Naming Specification. Also see gtk_icon_theme_list_contexts().

Parameters

icon_theme

a GtkIconTheme

 

context

a string identifying a particular type of icon, or NULL to list all icons.

[allow-none]

Returns

a GList list holding the names of all the icons in the theme. You must first free each element in the list with g_free(), then free the list itself with g_list_free().

[element-type utf8][transfer full]

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.

Parameters

icon_theme

a GtkIconTheme

 

icon_name

the name of an icon

 

Returns

An newly allocated array describing the sizes at which the icon is available. The array should be freed with g_free() when it is no longer needed.

[array zero-terminated=1][transfer full]

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.)

Parameters

icon_theme

a GtkIconTheme

 

Returns

the name of an example icon or NULL. Free with g_free().

[nullable]

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 icon_theme is accessed.

Parameters

icon_theme

a GtkIconTheme

 

Returns

TRUE if the icon theme has changed and needed to be reloaded.

Since: 2.4


gtk_icon_theme_add_builtin_icon ()

void
gtk_icon_theme_add_builtin_icon (const gchar *icon_name,
                                 gint size,
                                 GdkPixbuf *pixbuf);

gtk_icon_theme_add_builtin_icon has been deprecated since version 3.14 and should not be used in newly-written code.

Use gtk_icon_theme_add_resource_path() to add application-specific icons to the icon theme.

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 gtk_icon_theme_add_builtin_icon() you should also install the icon in the icon theme, so that the icon is generally available.

This function will generally be used with pixbufs loaded via gdk_pixbuf_new_from_inline().

Parameters

icon_name

the name of the icon to register

 

size

the size in pixels at which to register the icon (different images can be registered for the same icon name at different sizes.)

 

pixbuf

GdkPixbuf that contains the image to use for icon_name

 

Since: 2.4


gtk_icon_info_copy ()

GtkIconInfo *
gtk_icon_info_copy (GtkIconInfo *icon_info);

gtk_icon_info_copy has been deprecated since version 3.8 and should not be used in newly-written code.

Use g_object_ref()

Make a copy of a GtkIconInfo.

[skip]

Parameters

icon_info

a GtkIconInfo

 

Returns

the new GtkIconInfo.

[transfer full]

Since: 2.4


gtk_icon_info_free ()

void
gtk_icon_info_free (GtkIconInfo *icon_info);

gtk_icon_info_free has been deprecated since version 3.8 and should not be used in newly-written code.

Use g_object_unref()

Free a GtkIconInfo and associated information

[skip]

Parameters

icon_info

a GtkIconInfo

 

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 GdkPixbuf.

Parameters

icon_theme

a GtkIconTheme

 

pixbuf

the pixbuf to wrap in a GtkIconInfo

 

Returns

a GtkIconInfo.

[transfer full]

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.

Note that for scaled icons the base size does not include the base scale.

Parameters

icon_info

a GtkIconInfo

 

Returns

the base size, or 0, if no base size is known for the icon.

Since: 2.4


gtk_icon_info_get_base_scale ()

gint
gtk_icon_info_get_base_scale (GtkIconInfo *icon_info);

Gets the base scale for the icon. The base scale is a scale for the icon that was specified by the icon theme creator. For instance an icon drawn for a high-dpi screen with window scale 2 for a base size of 32 will be 64 pixels tall and have a base scale of 2.

Parameters

icon_info

a GtkIconInfo

 

Returns

the base scale

Since: 3.10


gtk_icon_info_get_filename ()

const gchar *
gtk_icon_info_get_filename (GtkIconInfo *icon_info);

Gets the filename for the icon. If the GTK_ICON_LOOKUP_USE_BUILTIN flag was passed to gtk_icon_theme_lookup_icon(), there may be no filename if a builtin icon is returned; in this case, you should use gtk_icon_info_get_builtin_pixbuf().

Parameters

icon_info

a GtkIconInfo

 

Returns

the filename for the icon, or NULL if gtk_icon_info_get_builtin_pixbuf() should be used instead. The return value is owned by GTK+ and should not be modified or freed.

[type filename]

Since: 2.4


gtk_icon_info_get_builtin_pixbuf ()

GdkPixbuf *
gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info);

gtk_icon_info_get_builtin_pixbuf has been deprecated since version 3.14 and should not be used in newly-written code.

This function is deprecated, use gtk_icon_theme_add_resource_path() instead of builtin icons.

Gets the built-in image for this icon, if any. To allow GTK+ to use built in icon images, you must pass the GTK_ICON_LOOKUP_USE_BUILTIN to gtk_icon_theme_lookup_icon().

Parameters

icon_info

a GtkIconInfo

 

Returns

the built-in image pixbuf, or NULL. No extra reference is added to the returned pixbuf, so if you want to keep it around, you must use g_object_ref(). The returned image must not be modified.

[transfer none]

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 gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting pixbuf may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the GtkIconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

error

location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

[transfer full]

Since: 2.4


gtk_icon_info_load_surface ()

cairo_surface_t *
gtk_icon_info_load_surface (GtkIconInfo *icon_info,
                            GdkWindow *for_window,
                            GError **error);

Renders an icon previously looked up in an icon theme using gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting surface may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the GtkIconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

for_window

GdkWindow to optimize drawing for, or NULL.

[allow-none]

error

location for error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use cairo_surface_destroy() to release your reference to the icon.

[transfer full]

Since: 3.10


gtk_icon_info_load_icon_async ()

void
gtk_icon_info_load_icon_async (GtkIconInfo *icon_info,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer user_data);

Asynchronously load, render and scale an icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_icon() which is the synchronous version of this call.

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

cancellable

optional GCancellable object, NULL to ignore.

[allow-none]

callback

a GAsyncReadyCallback to call when the request is satisfied.

[scope async]

user_data

the data to pass to callback function.

[closure]

Since: 3.8


gtk_icon_info_load_icon_finish ()

GdkPixbuf *
gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info,
                                GAsyncResult *res,
                                GError **error);

Finishes an async icon load, see gtk_icon_info_load_icon_async().

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

res

a GAsyncResult

 

error

location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

[transfer full]

Since: 3.8


gtk_icon_info_load_symbolic ()

GdkPixbuf *
gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
                             const GdkRGBA *fg,
                             const GdkRGBA *success_color,
                             const GdkRGBA *warning_color,
                             const GdkRGBA *error_color,
                             gboolean *was_symbolic,
                             GError **error);

Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon().

This allows loading symbolic icons that will match the system theme.

Unless you are implementing a widget, you will want to use g_themed_icon_new_with_default_fallbacks() to load the icon.

As implementation details, the icon loaded needs to be of SVG type, contain the “symbolic” term as the last component of the icon name, and use the “fg”, “success”, “warning” and “error” CSS styles in the SVG file itself.

See the Symbolic Icons Specification for more information about symbolic icons.

Parameters

icon_info

a GtkIconInfo

 

fg

a GdkRGBA representing the foreground color of the icon

 

success_color

a GdkRGBA representing the warning color of the icon or NULL to use the default color.

[allow-none]

warning_color

a GdkRGBA representing the warning color of the icon or NULL to use the default color.

[allow-none]

error_color

a GdkRGBA representing the error color of the icon or NULL to use the default color (allow-none).

[allow-none]

was_symbolic

a gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

[out][allow-none]

error

location to store error information on failure, or NULL.

[allow-none]

Returns

a GdkPixbuf representing the loaded icon.

[transfer full]

Since: 3.0


gtk_icon_info_load_symbolic_async ()

void
gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_info,
                                   const GdkRGBA *fg,
                                   const GdkRGBA *success_color,
                                   const GdkRGBA *warning_color,
                                   const GdkRGBA *error_color,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_symbolic() which is the synchronous version of this call.

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

fg

a GdkRGBA representing the foreground color of the icon

 

success_color

a GdkRGBA representing the warning color of the icon or NULL to use the default color.

[allow-none]

warning_color

a GdkRGBA representing the warning color of the icon or NULL to use the default color.

[allow-none]

error_color

a GdkRGBA representing the error color of the icon or NULL to use the default color (allow-none).

[allow-none]

cancellable

optional GCancellable object, NULL to ignore.

[allow-none]

callback

a GAsyncReadyCallback to call when the request is satisfied.

[scope async]

user_data

the data to pass to callback function.

[closure]

Since: 3.8


gtk_icon_info_load_symbolic_finish ()

GdkPixbuf *
gtk_icon_info_load_symbolic_finish (GtkIconInfo *icon_info,
                                    GAsyncResult *res,
                                    gboolean *was_symbolic,
                                    GError **error);

Finishes an async icon load, see gtk_icon_info_load_symbolic_async().

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

res

a GAsyncResult

 

was_symbolic

a gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

[out][allow-none]

error

location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

[transfer full]

Since: 3.8


gtk_icon_info_load_symbolic_for_style ()

GdkPixbuf *
gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
                                       GtkStyle *style,
                                       GtkStateType state,
                                       gboolean *was_symbolic,
                                       GError **error);

gtk_icon_info_load_symbolic_for_style has been deprecated since version 3.0 and should not be used in newly-written code.

Use gtk_icon_info_load_symbolic_for_context() instead

Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon().

This allows loading symbolic icons that will match the system theme.

See gtk_icon_info_load_symbolic() for more details.

Parameters

icon_info

a GtkIconInfo

 

style

a GtkStyle to take the colors from

 

state

the widget state to use for colors

 

was_symbolic

a gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

[out][allow-none]

error

location to store error information on failure, or NULL.

[allow-none]

Returns

a GdkPixbuf representing the loaded icon.

[transfer full]

Since: 3.0


gtk_icon_info_load_symbolic_for_context ()

GdkPixbuf *
gtk_icon_info_load_symbolic_for_context
                               (GtkIconInfo *icon_info,
                                GtkStyleContext *context,
                                gboolean *was_symbolic,
                                GError **error);

Loads an icon, modifying it to match the system colors for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon(). This function uses the regular foreground color and the symbolic colors with the names “success_color”, “warning_color” and “error_color” from the context.

This allows loading symbolic icons that will match the system theme.

See gtk_icon_info_load_symbolic() for more details.

Parameters

icon_info

a GtkIconInfo

 

context

a GtkStyleContext

 

was_symbolic

a gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

[out][allow-none]

error

location to store error information on failure, or NULL.

[allow-none]

Returns

a GdkPixbuf representing the loaded icon.

[transfer full]

Since: 3.0


gtk_icon_info_load_symbolic_for_context_async ()

void
gtk_icon_info_load_symbolic_for_context_async
                               (GtkIconInfo *icon_info,
                                GtkStyleContext *context,
                                GCancellable *cancellable,
                                GAsyncReadyCallback callback,
                                gpointer user_data);

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_symbolic_for_context() which is the synchronous version of this call.

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

context

a GtkStyleContext

 

cancellable

optional GCancellable object, NULL to ignore.

[allow-none]

callback

a GAsyncReadyCallback to call when the request is satisfied.

[scope async]

user_data

the data to pass to callback function.

[closure]

Since: 3.8


gtk_icon_info_load_symbolic_for_context_finish ()

GdkPixbuf *
gtk_icon_info_load_symbolic_for_context_finish
                               (GtkIconInfo *icon_info,
                                GAsyncResult *res,
                                gboolean *was_symbolic,
                                GError **error);

Finishes an async icon load, see gtk_icon_info_load_symbolic_for_context_async().

Parameters

icon_info

a GtkIconInfo from gtk_icon_theme_lookup_icon()

 

res

a GAsyncResult

 

was_symbolic

a gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

[out][allow-none]

error

location to store error information on failure, or NULL.

[allow-none]

Returns

the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

[transfer full]

Since: 3.8


gtk_icon_info_set_raw_coordinates ()

void
gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info,
                                   gboolean raw_coordinates);

gtk_icon_info_set_raw_coordinates has been deprecated since version 3.14 and should not be used in newly-written code.

Embedded rectangles and attachment points are deprecated

Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect() and gtk_icon_info_get_attach_points() should be returned in their original form as specified in the icon theme, instead of scaled appropriately for the pixbuf returned by gtk_icon_info_load_icon().

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 gtk_icon_info_get_filename(), and seeing if it is non-NULL and ends in “.svg”.

This function is provided primarily to allow compatibility wrappers for older API's, and is not expected to be useful for applications.

Parameters

icon_info

a GtkIconInfo

 

raw_coordinates

whether the coordinates of embedded rectangles and attached points should be returned in their original (unscaled) form.

 

Since: 2.4


gtk_icon_info_get_embedded_rect ()

gboolean
gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info,
                                 GdkRectangle *rectangle);

gtk_icon_info_get_embedded_rect has been deprecated since version 3.14 and should not be used in newly-written code.

Embedded rectangles are deprecated

This function is deprecated and always returns FALSE.

Parameters

icon_info

a GtkIconInfo

 

rectangle

GdkRectangle in which to store embedded rectangle coordinates; coordinates are only stored when this function returns TRUE.

[out]

Returns

FALSE

Since: 2.4


gtk_icon_info_get_attach_points ()

gboolean
gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
                                 GdkPoint **points,
                                 gint *n_points);

gtk_icon_info_get_attach_points has been deprecated since version 3.14 and should not be used in newly-written code.

Attachment points are deprecated

This function is deprecated and always returns FALSE.

Parameters

icon_info

a GtkIconInfo

 

points

location to store pointer to an array of points, or NULL free the array of points with g_free().

[allow-none][array length=n_points][out]

n_points

location to store the number of points in points , or NULL.

[allow-none]

Returns

FALSE

Since: 2.4


gtk_icon_info_get_display_name ()

const gchar *
gtk_icon_info_get_display_name (GtkIconInfo *icon_info);

gtk_icon_info_get_display_name has been deprecated since version 3.14 and should not be used in newly-written code.

Display names are deprecated

This function is deprecated and always returns NULL.

Parameters

icon_info

a GtkIconInfo

 

Returns

NULL

Since: 2.4


gtk_icon_info_is_symbolic ()

gboolean
gtk_icon_info_is_symbolic (GtkIconInfo *icon_info);

Checks if the icon is symbolic or not. This currently uses only the file name and not the file contents for determining this. This behaviour may change in the future.

Parameters

icon_info

a GtkIconInfo

 

Returns

TRUE if the icon is symbolic, FALSE otherwise

Since: 3.12

Types and Values

GtkIconInfo

typedef struct _GtkIconInfo GtkIconInfo;

Contains information found when looking up an icon in an icon theme.


struct GtkIconTheme

struct GtkIconTheme;

Acts as a database of information about an icon theme. Normally, you retrieve the icon theme for a particular screen using gtk_icon_theme_get_for_screen() and it will contain information about current icon theme for that screen, but you can also create a new GtkIconTheme object and set the icon theme name explicitly using gtk_icon_theme_set_custom_theme().


struct GtkIconThemeClass

struct GtkIconThemeClass {
  GObjectClass parent_class;


  void (* changed)  (GtkIconTheme *icon_theme);
};

Members

GObjectClass parent_class;

The parent class.

 

changed ()

Signal emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.

 

enum GtkIconLookupFlags

Used to specify options for gtk_icon_theme_lookup_icon()

Members

GTK_ICON_LOOKUP_NO_SVG

Never get SVG icons, even if gdk-pixbuf supports them. Cannot be used together with GTK_ICON_LOOKUP_FORCE_SVG.

 

GTK_ICON_LOOKUP_FORCE_SVG

Get SVG icons, even if gdk-pixbuf doesn’t support them. Cannot be used together with GTK_ICON_LOOKUP_NO_SVG.

 

GTK_ICON_LOOKUP_USE_BUILTIN

When passed to gtk_icon_theme_lookup_icon() includes builtin icons as well as files. For a builtin icon, gtk_icon_info_get_filename() is NULL and you need to call gtk_icon_info_get_builtin_pixbuf().

 

GTK_ICON_LOOKUP_GENERIC_FALLBACK

Try to shorten icon name at '-' characters before looking at inherited themes. For more general fallback, see gtk_icon_theme_choose_icon(). Since 2.12.

 

GTK_ICON_LOOKUP_FORCE_SIZE

Always get the icon scaled to the requested size. Since 2.14.

 

GTK_ICON_LOOKUP_FORCE_REGULAR

Try to always load regular icons, even when symbolic icon names are given. Since 3.14.

 

GTK_ICON_LOOKUP_FORCE_SYMBOLIC

Try to always load symbolic icons, even when regular icon names are given. Since 3.14.

 

GTK_ICON_LOOKUP_DIR_LTR

Try to load a variant of the icon for left-to-right text direction. Since 3.14.

 

GTK_ICON_LOOKUP_DIR_RTL

Try to load a variant of the icon for right-to-left text direction. Since 3.14.

 

GTK_ICON_THEME_ERROR

#define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()

The GQuark used for GtkIconThemeError errors.


enum GtkIconThemeError

Error codes for GtkIconTheme operations.

Members

GTK_ICON_THEME_NOT_FOUND

The icon specified does not exist in the theme

 

GTK_ICON_THEME_FAILED

An unspecified error occurred.

 

Signal Details

The “changed” signal

void
user_function (GtkIconTheme *icon_theme,
               gpointer      user_data)

Emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.

Parameters

icon_theme

the icon theme

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last