Gtk.IconFactory¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.IconFactory(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
An icon factory manages a collection of
Gtk.IconSet
; aGtk.IconSet
manages a set of variants of a particular icon (i.e. aGtk.IconSet
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. EachGtk.Style
has a list ofGtk.IconFactory
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 byGtk.IconFactory.add_default
() andGtk.IconFactory.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 functionGtk.Widget.render_icon
(). These functions take the theme into account when looking up the icon to use for a given stock ID.Gtk.IconFactory
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
Gtk.IconSize
enum value. This attribute is optional.direction
Direction of the source, a
Gtk.TextDirection
enum value. This attribute is optional.state
State of the source, a
Gtk.StateType
enum value. This attribute is optional.
- A
Gtk.IconFactory
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>
- classmethod lookup_default(stock_id)[source]¶
- Parameters:
stock_id (
str
) – an icon name- Returns:
a
Gtk.IconSet
, orNone
- Return type:
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 theGtk.Style
for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.Deprecated since version 3.10: Use
Gtk.IconTheme
instead.
- classmethod new()[source]¶
- Returns:
a new
Gtk.IconFactory
- Return type:
Creates a new
Gtk.IconFactory
. An icon factory manages a collection ofGtk.IconSets
; aGtk.IconSet
manages a set of variants of a particular icon (i.e. aGtk.IconSet
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. EachGtk.Style
has a list ofGtk.IconFactorys
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 byGtk.IconFactory.add_default
() andGtk.IconFactory.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 since version 3.10: Use
Gtk.IconTheme
instead.
- add(stock_id, icon_set)[source]¶
- Parameters:
stock_id (
str
) – icon nameicon_set (
Gtk.IconSet
) – 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.IconFactory
, then add it to the list of default factories withGtk.IconFactory.add_default
(). Then they pass the stock_id to widgets such asGtk.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 self for stock_id, it is unreferenced and replaced with the new icon_set.Deprecated since version 3.10: Use
Gtk.IconTheme
instead.
- add_default()[source]¶
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 self. 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 version 3.10: Use
Gtk.IconTheme
instead.
- lookup(stock_id)[source]¶
- Parameters:
stock_id (
str
) – an icon name- Returns:
icon set of stock_id.
- Return type:
Looks up stock_id in the icon factory, returning an icon set if found, otherwise
None
. For display to the user, you should useGtk.Style.lookup_icon_set
() on theGtk.Style
for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.Deprecated since version 3.10: Use
Gtk.IconTheme
instead.
- remove_default()[source]¶
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 version 3.10: Use
Gtk.IconTheme
instead.