IconSize

Browse the available stock icons in the list of stock IDs found here. You can also use the gtk-demo application for this purpose.

An icon factory manages a collection of GtkIconSet; a GtkIconSet manages a set of variants of a particular icon (i.e. a GtkIconSet contains variants for different sizes and widget states). Icons in an icon factory are named by a stock ID, which is a simple string identifying the icon. Each GtkStyle has a list of GtkIconFactory derived from the current theme; those icon factories are consulted first when searching for an icon. If the theme doesn't set a particular icon, GTK+ looks for the icon in a list of default icon factories, maintained by gtk_icon_factory_add_default() and gtk_icon_factory_remove_default(). Applications with icons should add a default icon factory with their icons, which will allow themes to override the icons for the application.

To display an icon, always use gtk_style_lookup_icon_set() on the widget that will display the icon, or the convenience function gtk_widget_render_icon(). These functions take the theme into account when looking up the icon to use for a given stock ID.

GtkIconFactory as GtkBuildable

GtkIconFactory supports a custom <sources> element, which can contain multiple <source> elements. The following attributes are allowed:

stock-id

The stock id of the source, a string. This attribute is mandatory

filename

The filename of the source, a string. This attribute is optional

icon-name

The icon name for the source, a string. This attribute is optional.

size

Size of the icon, a GtkIconSize enum value. This attribute is optional.

direction

Direction of the source, a GtkTextDirection enum value. This attribute is optional.

state

State of the source, a GtkStateType enum value. This attribute is optional.

Members

Static functions

fromName
GtkIconSize fromName(string name)

Warning gtk_icon_size_from_name has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead. Looks up the icon size associated with name.

getName
string getName(GtkIconSize size)

Warning gtk_icon_size_get_name has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead. Gets the canonical name of the given icon size. The returned string is statically allocated and should not be freed.

lookup
int lookup(GtkIconSize size, int width, int height)
lookupForSettings
int lookupForSettings(Settings settings, GtkIconSize size, int width, int height)

Warning gtk_icon_size_lookup_for_settings has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_icon_size_lookup() instead. Obtains the pixel size of a semantic icon size, possibly modified by user preferences for a particular GtkSettings. Normally size would be GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_BUTTON, etc. This function isn't normally needed, gtk_widget_render_icon_pixbuf() is the usual way to get an icon for rendering, then just look at the size of the rendered pixbuf. The rendered pixbuf may not even correspond to the width/height returned by gtk_icon_size_lookup(), because themes are free to render the pixbuf however they like, including changing the usual size. Since 2.2

register
GtkIconSize register(string name, int width, int height)

Warning gtk_icon_size_register has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead. Registers a new icon size, along the same lines as GTK_ICON_SIZE_MENU, etc. Returns the integer value for the size.

registerAlias
void registerAlias(string alia, GtkIconSize target)

Warning gtk_icon_size_register_alias has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead. Registers alias as another name for target. So calling gtk_icon_size_from_name() with alias as argument will return target.

Meta