Class

GtkIconFactory

Description [src]

class Gtk.IconFactory : GObject.Object
  implements Gtk.Buildable {
  /* No available fields */
}

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

Hierarchy

hierarchy this GtkIconFactory implements_0 GtkBuildable this--implements_0 ancestor_0 GObject ancestor_0--this

Ancestors

Implements

Constructors

gtk_icon_factory_new

Creates a new GtkIconFactory. An icon factory manages a collection of GtkIconSets; 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 GtkIconFactorys 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.

deprecated: 3.10 

Functions

gtk_icon_factory_lookup_default

Looks for an icon in the list of default icon factories. For display to the user, you should use gtk_style_lookup_icon_set() on the GtkStyle for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.

deprecated: 3.10 

Instance methods

gtk_icon_factory_add

Adds the given icon_set to the icon factory, under the name stock_id. stock_id should be namespaced for your application, e.g. “myapp-whatever-icon”. Normally applications create a GtkIconFactory, then add it to the list of default factories with gtk_icon_factory_add_default(). Then they pass the stock_id to widgets such as GtkImage to display the icon. Themes can provide an icon with the same name (such as “myapp-whatever-icon”) to override your application’s default icons. If an icon already existed in factory for stock_id, it is unreferenced and replaced with the new icon_set.

deprecated: 3.10 

gtk_icon_factory_add_default

Adds an icon factory to the list of icon factories searched by gtk_style_lookup_icon_set(). This means that, for example, gtk_image_new_from_stock() will be able to find icons in factory. There will normally be an icon factory added for each library or application that comes with icons. The default icon factories can be overridden by themes.

deprecated: 3.10 

gtk_icon_factory_lookup

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_lookup_icon_set() on the GtkStyle for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.

deprecated: 3.10 

gtk_icon_factory_remove_default

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.

deprecated: 3.10 

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Methods inherited from GtkBuildable (10)
gtk_buildable_add_child

Adds a child to buildable. type is an optional string describing how the child should be added.

since: 2.12

gtk_buildable_construct_child

Constructs a child of buildable with the name name.

since: 2.12

gtk_buildable_custom_finished

This is similar to gtk_buildable_parser_finished() but is called once for each custom tag handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_end

This is called at the end of each custom element handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_start

This is called for each unknown element under <child>.

since: 2.12

gtk_buildable_get_internal_child

Get the internal child called childname of the buildable object.

since: 2.12

gtk_buildable_get_name

Gets the name of the buildable object.

since: 2.12

gtk_buildable_parser_finished

Called when the builder finishes the parsing of a [GtkBuilder UI definition][BUILDER-UI]. Note that this will be called once for each time gtk_builder_add_from_file() or gtk_builder_add_from_string() is called on a builder.

since: 2.12

gtk_buildable_set_buildable_property

Sets the property name name to value on the buildable object.

since: 2.12

gtk_buildable_set_name

Sets the name of the buildable object.

since: 2.12

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct GtkIconFactoryClass {
  GObjectClass parent_class;
  void (* _gtk_reserved1) (
void
  );
  void (* _gtk_reserved2) (
void
  );
  void (* _gtk_reserved3) (
void
  );
  void (* _gtk_reserved4) (
void
  );
  
}

No description available.

Class members
parent_class: GObjectClass

The parent class.

_gtk_reserved1: void (* _gtk_reserved1) ( void )

No description available.

_gtk_reserved2: void (* _gtk_reserved2) ( void )

No description available.

_gtk_reserved3: void (* _gtk_reserved3) ( void )

No description available.

_gtk_reserved4: void (* _gtk_reserved4) ( void )

No description available.