Class
Gtk.IconTheme
Description [src]
final class Gtk.IconTheme : GObject.Object {
/* No available fields */
}
GtkIconTheme
provides a facility for looking up icons by name
and size.
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 GtkImage
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 new GtkIconTheme
objects, but it’s much more
efficient to use the standard icon theme of the GtkWidget
so that the icon information is shared with other people
looking up icons.
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"my-icon-name", // icon name
48, // icon size
1, // scale
0, // flags);
paintable = GDK_PAINTABLE (icon);
// Use the paintable
g_object_unref (icon);
Constructors
gtk_icon_theme_new
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 gtk_icon_theme_get_for_display()
rather than creating a new icon theme object for scratch.
Instance methods
gtk_icon_theme_add_resource_path
Adds a resource path that will be looked at when looking for icons, similar to search paths.
gtk_icon_theme_add_search_path
Appends a directory to the search path.
See gtk_icon_theme_set_search_path()
.
gtk_icon_theme_get_display
Returns the display that the GtkIconTheme object was created for.
gtk_icon_theme_get_icon_names
Lists the names of icons in the current icon theme.
gtk_icon_theme_get_icon_sizes
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.
gtk_icon_theme_get_resource_path
Gets the current resource path.
gtk_icon_theme_get_search_path
Gets the current search path. See gtk_icon_theme_set_search_path()
.
gtk_icon_theme_get_theme_name
Gets the current icon theme name.
gtk_icon_theme_has_icon
Checks whether an icon theme includes an icon for a particular name.
gtk_icon_theme_lookup_by_gicon
Looks up a 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.
gtk_icon_theme_lookup_icon
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.
gtk_icon_theme_set_resource_path
Sets the resource paths that will be looked at when looking for icons, similar to search paths.
gtk_icon_theme_set_search_path
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.)
gtk_icon_theme_set_theme_name
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 gtk_icon_theme_get_for_display()
.
Properties
Gtk.IconTheme:display
The display that this icon theme object is attached to.
Gtk.IconTheme:icon-names
The icon names that are supported by the icon theme.
Gtk.IconTheme:resource-path
Resource paths that will be looked at when looking for icons, similar to search paths.
Gtk.IconTheme:search-path
The search path for this icon theme.
Gtk.IconTheme:theme-name
The name of the icon theme that is being used.
Signals
Gtk.IconTheme::changed
Emitted when the current icon theme is switched or GTK detects that a change has occurred in the contents of the current icon theme.