gtk.icon_factory
Module for [IconFactory] class
Types 3
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.IconFactory.addDefault] and [gtk.icon_factory.IconFactory.removeDefault]. 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.Style.lookupIconSet] on the widget that will display the icon, or the convenience function [gtk.widget.Widget.renderIcon]. These functions take the theme into account when looking up the icon to use for a given stock ID.
GtkIconFactory as GtkBuildable # {#GtkIconFactory-BUILDER-UI}
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.
A #GtkIconFactory UI definition fragment.
<object class="GtkIconFactory" id="iconfactory1">
<sources>
<source stock-id="apple-red" filename="apple-red.png"/>
</sources>
</object>
<object class="GtkWindow" id="window1">
<child>
<object class="GtkButton" id="apple_button">
<property name="label">apple-red</property>
<property name="use-stock">True</property>
</object>
</child>
</object>IconFactory self()Returns `this`, for use in `with` statements.IconFactoryGidBuilder builder()Get builder for [gtk.icon_factory.IconFactory] Returns: New builder objectgtk.icon_set.IconSet lookupDefault(string stockId)Looks for an icon in the list of default icon factories. For display to the user, you should use [gtk.style.Style.lookupIconSet] on the #GtkStyle for the widget that will display the icon, instead...void add(string stockId, gtk.icon_set.IconSet iconSet)Adds the given iconset to the icon factory, under the name stockid. stockid should be namespaced for your application, e.g. “myapp-whatever-icon”. Normally applications create a #GtkIconFacto...void addDefault()Adds an icon factory to the list of icon factories searched by [gtk.style.Style.lookupIconSet]. This means that, for example, [gtk.image.Image.newFromStock] will be able to find icons in factory. T...gtk.icon_set.IconSet lookup(string stockId)Looks up stock_id in the icon factory, returning an icon set if found, otherwise null. For display to the user, you should use [gtk.style.Style.lookupIconSet] on the #GtkStyle for the widget that w...void removeDefault()Removes an icon factory from the list of default icon factories. Not normally used; you might use it for a library that can be unloaded or shut down.Fluent builder for [gtk.icon_factory.IconFactory]