Gtk.Icon_Factory

Entities

Tagged Types

Access Types

Subprograms

Generic Instantiations

Description

An icon factory manages a collection of Gtk.Icon_Set.Gtk_Icon_Set; a Gtk.Icon_Set.Gtk_Icon_Set manages a set of variants of a particular icon (i.e. a Gtk.Icon_Set.Gtk_Icon_Set 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 Gtk.Style.Gtk_Style has a list of Gtk.Icon_Factory.Gtk_Icon_Factory 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 # {Gtk.Icon_Factory.Gtk_Icon_Factory-BUILDER-UI}

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

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

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

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

Size of the icon, a Gtk.Enums.Gtk_Icon_Size enum value. This attribute is optional.

Direction of the source, a Gtk.Enums.Gtk_Text_Direction enum value. This attribute is optional.

State of the source, a Gtk.Enums.Gtk_State_Type enum value. This attribute is optional.

## A Gtk.Icon_Factory.Gtk_Icon_Factory 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>

"+"

function "+"
  (Widget : access Gtk_Icon_Factory_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Icon_Factory
Parameters
Interf
Return Value

Add

procedure Add
   (Self     : not null access Gtk_Icon_Factory_Record;
    Stock_Id : UTF8_String;
    Icon_Set : Gtk.Icon_Set.Gtk_Icon_Set)

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 Gtk.Icon_Factory.Gtk_Icon_Factory, 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 Gtk.Image.Gtk_Image 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 since 3.10, 1

Parameters
Self
Stock_Id

icon name

Icon_Set

icon set

Add_Default

procedure Add_Default (Self : not null access Gtk_Icon_Factory_Record)

Adds an icon factory to the list of icon factories searched by gtk_style_lookup_icon_set. This means that, for example, Gtk.Image.Gtk_New 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 since 3.10, 1

Parameters
Self

Get_Icon_Factory

function Get_Icon_Factory
  (Self : Gtk.Style_Provider.Gtk_Style_Provider;
   Path : Gtk.Widget.Gtk_Widget_Path)
return Gtk_Icon_Factory

Returns the Gtk.Icon_Factory.Gtk_Icon_Factory defined to be in use for Path, or null if none is defined. Since: gtk+ 3.0

Parameters
Self
Path
Return Value

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Icon_Factory

type Gtk_Icon_Factory is access all Gtk_Icon_Factory_Record'Class;

Gtk_Icon_Factory_New

function Gtk_Icon_Factory_New return Gtk_Icon_Factory

Creates a new Gtk.Icon_Factory.Gtk_Icon_Factory. An icon factory manages a collection of Gtk_Icon_Sets; a Gtk.Icon_Set.Gtk_Icon_Set manages a set of variants of a particular icon (i.e. a Gtk.Icon_Set.Gtk_Icon_Set 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 Gtk.Style.Gtk_Style has a list of Gtk_Icon_Factorys 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.

Return Value

Gtk_Icon_Factory_Record

type Gtk_Icon_Factory_Record is new GObject_Record with null record;

Gtk_New

procedure Gtk_New (Self : out Gtk_Icon_Factory)

Creates a new Gtk.Icon_Factory.Gtk_Icon_Factory. An icon factory manages a collection of Gtk_Icon_Sets; a Gtk.Icon_Set.Gtk_Icon_Set manages a set of variants of a particular icon (i.e. a Gtk.Icon_Set.Gtk_Icon_Set 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 Gtk.Style.Gtk_Style has a list of Gtk_Icon_Factorys 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. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Icon_Size_Lookup

procedure Icon_Size_Lookup
   (Size   : Gtk.Enums.Gtk_Icon_Size;
    Width  : out Glib.Gint;
    Height : out Glib.Gint;
    Result : out Boolean)

Obtains the pixel size of a semantic icon size Size: GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_BUTTON, etc. This function isn't normally needed, Gtk.Icon_Theme.Load_Icon 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_Factory.Icon_Size_Lookup, because themes are free to render the pixbuf however they like, including changing the usual size.

Parameters
Size

an icon size (Gtk.Enums.Gtk_Icon_Size)

Width

location to store icon width

Height

location to store icon height @return True if Size was a valid size

Result

Icon_Size_Lookup_For_Settings

procedure Icon_Size_Lookup_For_Settings
   (Settings : not null access Gtk.Settings.Gtk_Settings_Record'Class;
    Size     : Gtk.Enums.Gtk_Icon_Size;
    Width    : out Glib.Gint;
    Height   : out Glib.Gint;
    Result   : out Boolean)

Obtains the pixel size of a semantic icon size, possibly modified by user preferences for a particular Gtk.Settings.Gtk_Settings. 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_Factory.Icon_Size_Lookup, because themes are free to render the pixbuf however they like, including changing the usual size. Since: gtk+ 2.2 Deprecated since 3.10, 1

Parameters
Settings

a Gtk.Settings.Gtk_Settings object, used to determine which set of user preferences to used.

Size

an icon size (Gtk.Enums.Gtk_Icon_Size)

Width

location to store icon width

Height

location to store icon height @return True if Size was a valid size

Result

Icon_Size_Register

function Icon_Size_Register
   (Name   : UTF8_String;
    Width  : Glib.Gint;
    Height : Glib.Gint) return Gtk.Enums.Gtk_Icon_Size

Registers a new icon size, along the same lines as GTK_ICON_SIZE_MENU, etc. Returns the integer value for the size. Deprecated since 3.10, 1

Parameters
Name

name of the icon size

Width

the icon width

Height

the icon height

Return Value

integer value representing the size (Gtk.Enums.Gtk_Icon_Size)

Icon_Size_Register_Alias

procedure Icon_Size_Register_Alias
   (Alias  : UTF8_String;
    Target : Gtk.Enums.Gtk_Icon_Size)

Registers Alias as another name for Target. So calling gtk_icon_size_from_name with Alias as argument will return Target. Deprecated since 3.10, 1

Parameters
Alias

an alias for Target

Target

an existing icon size (Gtk.Enums.Gtk_Icon_Size)

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Icon_Factory_Record, Gtk_Icon_Factory);

Initialize

procedure Initialize
   (Self : not null access Gtk_Icon_Factory_Record'Class)

Creates a new Gtk.Icon_Factory.Gtk_Icon_Factory. An icon factory manages a collection of Gtk_Icon_Sets; a Gtk.Icon_Set.Gtk_Icon_Set manages a set of variants of a particular icon (i.e. a Gtk.Icon_Set.Gtk_Icon_Set 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 Gtk.Style.Gtk_Style has a list of Gtk_Icon_Factorys 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. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Lookup

function Lookup
   (Self     : not null access Gtk_Icon_Factory_Record;
    Stock_Id : UTF8_String) return Gtk.Icon_Set.Gtk_Icon_Set

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 Gtk.Style.Gtk_Style for the widget that will display the icon, instead of using this function directly, so that themes are taken into account. Deprecated since 3.10, 1

Parameters
Self
Stock_Id

an icon name

Return Value

icon set of Stock_Id.

Lookup_Default

function Lookup_Default
   (Stock_Id : UTF8_String) return Gtk.Icon_Set.Gtk_Icon_Set

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 Gtk.Style.Gtk_Style for the widget that will display the icon, instead of using this function directly, so that themes are taken into account. Deprecated since 3.10, 1

Parameters
Stock_Id

an icon name

Return Value

a Gtk.Icon_Set.Gtk_Icon_Set, or null

Remove_Default

procedure Remove_Default (Self : not null access Gtk_Icon_Factory_Record)

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 since 3.10, 1

Parameters
Self