IconTheme
Object Hierarchy:
Description:
public class IconTheme :
Object
Loads 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 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.
```c 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); ```
Content:
Static methods:
- public static void add_builtin_icon (string icon_name, int size, Pixbuf pixbuf)
Registers a built-in icon for icon theme lookups.
- public static Quark error_quark ()
Registers an error quark for [class@Gtk.
- public static unowned IconTheme get_default ()
Gets the icon theme for the default screen.
- public static unowned IconTheme get_for_screen (Screen screen)
Gets the icon theme object associated with screen; if
this function has not previously been called for the given screen, a new icon theme object will be created and associated with the
screen.
Creation methods:
Methods:
- public void append_search_path (string path)
Appends a directory to the search path.
- public IconInfo choose_icon (string[] icon_names, int size, IconLookupFlags flags)
Looks up a named icon and returns a
IconInfo containing information such as the filename of the icon.
- public string? get_example_icon_name ()
Gets the name of an icon that is representative of the current theme (
for instance, to use when presenting a list of themes to the user.
- public int[] get_icon_sizes (string icon_name)
Returns an array of integers describing the sizes at which the icon is
available without scaling.
- public void get_search_path (out string[] path)
Gets the current search path.
- public bool has_icon (string icon_name)
Checks whether an icon theme includes an icon for a particular name.
- public List<string> list_contexts ()
Gets the list of contexts available within the current hierarchy of
icon themes.
- public List<string> list_icons (string? context)
Lists the icons in the current icon theme.
- public Pixbuf? load_icon (string icon_name, int size, IconLookupFlags flags) throws Error
Looks up an icon in an icon theme, scales it to the given size and
renders it into a pixbuf.
- public IconInfo lookup_by_gicon (Icon icon, int size, IconLookupFlags flags)
Looks up a icon for a desired size and window scale.
- public IconInfo lookup_icon (string icon_name, int size, IconLookupFlags flags)
Looks up a named icon for a desired size and window scale, returning a
`GtkIconPaintable`.
- public void prepend_search_path (string path)
Prepends a directory to the search path.
- public bool rescan_if_needed ()
Checks to see if the icon theme has changed; if it has, any currently
cached information is discarded and will be reloaded next time this is accessed.
- public void set_custom_theme (string theme_name)
Sets the name of the icon theme that the IconTheme
object uses overriding system configuration.
- public void set_screen (Screen screen)
Sets the screen for an icon theme; the screen is used to track the
user’s currently configured icon theme, which might be different for different screens.
- public void set_search_path (string[] path)
Sets the search path for the icon theme object.
Signals:
Inherited Members:
All known members inherited from class GLib.Object