Gtk.IconTheme¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
[ |
r |
||
[ |
r/w/en |
||
[ |
r/w/en |
||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the icon theme changes. |
Fields¶
- Inherited:
Class Details¶
- class Gtk.IconTheme(**kwargs)¶
- Bases:
- Abstract:
No
GtkIconTheme
provides a facility for loading themed icons.The main reason for using a name rather than simply providing a filename is to allow different icons to be used depending on what “icon theme” is selected by the user. The operation of icon themes on Linux and Unix follows the Icon Theme Specification There is a fallback icon theme, named
hicolor
, where applications should install their icons, but additional icon themes can be installed as operating system vendors and users choose.In many cases, named themes are used indirectly, via [class`Gtk`.Image] rather than directly, but looking up icons directly is also simple. The
GtkIconTheme
object acts as a database of all the icons in the current theme. You can create newGtkIconTheme
objects, but it’s much more efficient to use the standard icon theme of theGtkWidget
so that the icon information is shared with other people looking up icons.```c
Gtk.IconTheme
*icon_theme;Gtk.IconPaintable
*icon;Gdk.Paintable
*paintable;icon_theme =
Gtk.IconTheme.get_for_display
(Gtk.Widget.get_display
(my_widget)); icon =Gtk.IconTheme.lookup_icon
(icon_theme, “my-icon-name”, // icon name 48, // icon size 1, // scale 0, // flags); paintable = GDK_PAINTABLE (icon); // Use the paintableGObject.Object.unref
(icon); ```- classmethod get_for_display(display)[source]¶
- Parameters:
display (
Gdk.Display
) – aGdkDisplay
- Returns:
A unique
GtkIconTheme
associated with the given display. This icon theme is associated with the display and can be used as long as the display is open. Do not ref or unref it.- Return type:
Gets the icon theme object associated with display.
If this function has not previously been called for the given display, a new icon theme object will be created and associated with the display. Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling [ctor`Gtk`.IconTheme.new] and setting the display yourself; by using this function a single icon theme object will be shared between users.
- classmethod new()[source]¶
- Returns:
the newly created
GtkIconTheme
object.- Return type:
Creates a new icon theme object.
Icon theme objects are used to lookup up an icon by name in a particular icon theme. Usually, you’ll want to use [func`Gtk`.IconTheme.get_for_display] rather than creating a new icon theme object for scratch.
- add_resource_path(path)[source]¶
- Parameters:
path (
str
) – a resource path
Adds a resource path that will be looked at when looking for icons, similar to search paths.
See [method`Gtk`.IconTheme.set_resource_path].
This function should be used to make application-specific icons available as part of the icon theme.
- add_search_path(path)[source]¶
- Parameters:
path (
str
) – directory name to append to the icon path
Appends a directory to the search path.
See [method`Gtk`.IconTheme.set_search_path].
- get_display()[source]¶
- Returns:
the display of icon_theme
- Return type:
Gdk.Display
orNone
Returns the display that the
GtkIconTheme
object was created for.
- get_icon_names()[source]¶
- Returns:
a string array holding the names of all the icons in the theme. You must free the array using
GLib.strfreev
().- Return type:
[
str
]
Lists the names of icons in the current icon theme.
- get_icon_sizes(icon_name)[source]¶
- Parameters:
icon_name (
str
) – the name of an icon- Returns:
A newly allocated array describing the sizes at which the icon is available. The array should be freed with
GLib.free
() when it is no longer needed.- Return type:
[
int
]
Returns an array of integers describing the sizes at which the icon is available without scaling.
A size of -1 means that the icon is available in a scalable format. The array is zero-terminated.
- get_resource_path()[source]¶
-
Gets the current resource path.
See [method`Gtk`.IconTheme.set_resource_path].
- get_search_path()[source]¶
-
Gets the current search path.
See [method`Gtk`.IconTheme.set_search_path].
- get_theme_name()[source]¶
- Return type:
Gets the current icon theme name.
Returns (transfer full): the current icon theme name,
- has_gicon(gicon)[source]¶
- Parameters:
gicon (
Gio.Icon
) – aGIcon
- Returns:
True
if self includes an icon for gicon- Return type:
Checks whether an icon theme includes an icon for a particular
GIcon
.New in version 4.2.
- has_icon(icon_name)[source]¶
- Parameters:
icon_name (
str
) – the name of an icon- Returns:
True
if self includes an icon for icon_name.- Return type:
Checks whether an icon theme includes an icon for a particular name.
- lookup_by_gicon(icon, size, scale, direction, flags)[source]¶
- Parameters:
icon (
Gio.Icon
) – theGIcon
to look upsize (
int
) – desired icon sizescale (
int
) – the desired scaledirection (
Gtk.TextDirection
) – text direction the icon will be displayed inflags (
Gtk.IconLookupFlags
) – flags modifying the behavior of the icon lookup
- Returns:
a
GtkIconPaintable
containing information about the icon. Unref withGObject.Object.unref
()- Return type:
Looks up a icon for a desired size and window scale.
The icon can then be rendered by using it as a
GdkPaintable
, or you can get information such as the filename and size.
- lookup_icon(icon_name, fallbacks, size, scale, direction, flags)[source]¶
- Parameters:
icon_name (
str
) – the name of the icon to lookupsize (
int
) – desired icon size.scale (
int
) – the window scale this will be displayed ondirection (
Gtk.TextDirection
) – text direction the icon will be displayed inflags (
Gtk.IconLookupFlags
) – flags modifying the behavior of the icon lookup
- Returns:
a
GtkIconPaintable
object containing the icon.- Return type:
Looks up a named icon for a desired size and window scale, returning a
GtkIconPaintable
.The icon can then be rendered by using it as a
GdkPaintable
, or you can get information such as the filename and size.If the available icon_name is not available and fallbacks are provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the “missing icon” icon is returned. If you need to do something else for missing icons you need to use [method`Gtk`.IconTheme.has_icon].
Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the
Gtk.Widget.do_css-changed
() function.
- set_resource_path(path)[source]¶
- Parameters:
path ([
str
] orNone
) –None
-terminated array of resource paths that are searched for icons
Sets the resource paths that will be looked at when looking for icons, similar to search paths.
The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as
@path/16x16/actions/run.png
or@path/scalable/actions/run.svg
.Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback, but they are treated like unthemed icons.
- set_search_path(path)[source]¶
- Parameters:
path ([
str
] orNone
) –None
-terminated array of directories that are searched for icon themes
Sets the search path for the icon theme object.
When looking for an icon theme, GTK will search for a subdirectory of one or more of the directories in path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)
In addition if an icon found isn’t found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of path, then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)
- set_theme_name(theme_name)[source]¶
- Parameters:
theme_name (
str
orNone
) – name of icon theme to use instead of configured theme, orNone
to unset a previously set custom theme
Sets the name of the icon theme that the
GtkIconTheme
object uses overriding system configuration.This function cannot be called on the icon theme objects returned from [func`Gtk`.IconTheme.get_for_display].
Signal Details¶
- Gtk.IconTheme.signals.changed(icon_theme)¶
- Signal Name:
changed
- Flags:
- Parameters:
icon_theme (
Gtk.IconTheme
) – The object which received the signal
Emitted when the icon theme changes.
This can happen because current icon theme is switched or because GTK detects that a change has occurred in the contents of the current icon theme.
Property Details¶
- Gtk.IconTheme.props.display¶
- Name:
display
- Type:
- Default Value:
- Flags:
The display that this icon theme object is attached to.
- Gtk.IconTheme.props.icon_names¶
-
The icon names that are supported by the icon theme.
- Gtk.IconTheme.props.resource_path¶
- Name:
resource-path
- Type:
[
str
]- Default Value:
[]
- Flags:
Resource paths that will be looked at when looking for icons, similar to search paths.
The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as
@path/16x16/actions/run.png
. Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback.
- Gtk.IconTheme.props.search_path¶
- Name:
search-path
- Type:
[
str
]- Default Value:
[]
- Flags:
The search path for this icon theme.
When looking for icons, GTK will search for a subdirectory of one or more of the directories in the search path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)
- Gtk.IconTheme.props.theme_name¶
- Name:
theme-name
- Type:
- Default Value:
- Flags:
The name of the icon theme that is being used.
Unless set to a different value, this will be the value of the
GtkSettings:gtk-icon-theme-name
property of theGtkSettings
object associated to the display of the icontheme object.