IconFactoryProtocol
public protocol IconFactoryProtocol : ObjectProtocol, BuildableProtocol
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.
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>
The IconFactoryProtocol
protocol exposes the methods and properties of an underlying GtkIconFactory
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see IconFactory
.
Alternatively, use IconFactoryRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkIconFactory
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
icon_factory_ptr
Default implementationTyped pointer to the underlying
GtkIconFactory
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkIconFactory
instance.Declaration
Swift
var icon_factory_ptr: UnsafeMutablePointer<GtkIconFactory>! { get }
-
Required Initialiser for types conforming to
IconFactoryProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
add(stockID:
Extension methodiconSet: ) Adds the given
icon_set
to the icon factory, under the namestock_id
.stock_id
should be namespaced for your application, e.g. “myapp-whatever-icon”. Normally applications create aGtkIconFactory
, then add it to the list of default factories withgtk_icon_factory_add_default()
. Then they pass thestock_id
to widgets such asGtkImage
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 infactory
forstock_id
, it is unreferenced and replaced with the newicon_set
.add is deprecated: Use #GtkIconTheme instead.
Declaration
Swift
@available(*, deprecated) @inlinable func add<IconSetT>(stockID: UnsafePointer<gchar>!, iconSet: IconSetT) where IconSetT : IconSetProtocol
-
addDefault()
Extension methodAdds 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 infactory
. 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.add_default is deprecated: Use #GtkIconTheme instead.
Declaration
Swift
@available(*, deprecated) @inlinable func addDefault()
-
lookup(stockID:
Extension method) Looks up
stock_id
in the icon factory, returning an icon set if found, otherwisenil
. For display to the user, you should usegtk_style_lookup_icon_set()
on theGtkStyle
for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.lookup is deprecated: Use #GtkIconTheme instead.
Declaration
Swift
@available(*, deprecated) @inlinable func lookup(stockID: UnsafePointer<gchar>!) -> IconSetRef!
-
removeDefault()
Extension methodRemoves 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.
remove_default is deprecated: Use #GtkIconTheme instead.
Declaration
Swift
@available(*, deprecated) @inlinable func removeDefault()
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }