W Wrapl, The Programming Language

Libraries:Gtk:Gtk:IconTheme

Types

T

Inherits from:

T 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 default icon theme, named hicolor where applications should install their icons, but more additional application themes can be installed as operating system vendors and users choose.

Named icons are similar to the Themeable Stock Images(3) facility, and the distinction between the two may be a bit confusing. A few things to keep in mind:

  • Stock images usually are used in conjunction with Stock Items(3)., such as GTK_STOCK_OK or GTK_STOCK_OPEN. Named icons are easier to set up and therefore are more useful for new icons that an application wants to add, such as application icons or window icons.

  • Stock images can only be loaded at the symbolic sizes defined by the Gtk.Gtk.IconSize.T enumeration, or by custom sizes defined by Gtk.Gtk.Icon.SizeRegister, while named icons are more flexible and any pixel size can be specified.

  • Because stock images are closely tied to stock items, and thus to actions in the user interface, stock images may come in multiple variants for different widget states or writing directions.

A good rule of thumb is that if there is a stock image for what you want to use, use it, otherwise use a named icon. It turns out that internally stock images are generally defined in terms of one or more named icons. (An example of the more than one case is icons that depend on writing direction; GTK_STOCK_GO_FORWARD uses the two themed icons "gtk-stock-go-forward-ltr" and "gtk-stock-go-forward-rtl".)

In many cases, named themes are used indirectly, via Gtk.Gtk.Image.T or stock items, rather than directly, but looking up icons directly is also simple. The T object acts as a database of all the icons in the current theme. You can create new T objects, but its much more efficient to use the standard icon theme for the Gtk.Gdk.Screen.T so that the icon information is shared with other people looking up icons. In the case where the default screen is being used, looking up an icon can be as simple as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
GError *error = NULL;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
icon_theme = gtk_icon_theme_get_default ();
pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                   "my-icon-name", /* icon name */
                                   48, /* size */
                                   0,  /* flags */
                                   &error);
if (!pixbuf)
  {
    g_warning ("Couldn't load icon: %s", error->message);
    g_error_free (error);
  }
else
  {
    /* Use the pixbuf */
    g_object_unref (pixbuf);
  }


Constants

Nil : T

Functions

AddBuiltinIcon(icon_name @ Std.String.T, size @ Std.Integer.SmallT, pixbuf @ Gtk.Gdk.Pixbuf.T) : Std.Object.T

Registers a built-in icon for icon theme lookups. The idea of built-in icons is to allow an application or library that uses themed icons to function requiring files to be present in the file system. For instance, the default images for all of GTK+'s stock icons are registered as built-icons.

In general, if you use AddBuiltinIcon you should also install the icon in the icon theme, so that the icon is generally available.

This function will generally be used with pixbufs loaded via gdk_pixbuf_new_from_inline().

icon_name the name of the icon to register
size the size at which to register the icon (different images can be registered for the same icon name at different sizes.)
pixbuf Gtk.Gdk.Pixbuf.T that contains the image to use for icon_name.


ErrorQuark() : Std.Integer.SmallT



GetDefault() : Gtk.Gtk.IconTheme.T

Gets the icon theme for the default screen. See GetForScreen.

Returns A unique T associated with the default screen. This icon theme is associated with the screen and can be used as long as the screen is open. Do not ref or unref it. [transfer none]


GetForScreen(screen @ Gtk.Gdk.Screen.T) : Gtk.Gtk.IconTheme.T

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. Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than gtk_icon_theme_new() and setting the screen yourself; by using this function a single icon theme object will be shared between users.

screen a Gtk.Gdk.Screen.T
Returns A unique T associated with the given screen. This icon theme is associated with the screen and can be used as long as the screen is open. Do not ref or unref it. [transfer none]


GetType() : Gtk.GObject.Type.T



New() : Gtk.Gtk.IconTheme.T

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 GetDefault or GetForScreen rather than creating a new icon theme object for scratch.

Returns the newly created T object.


Methods

:AppendSearchPath(self @ T, path @ Std.String.T) : Std.Object.T



:ChooseIcon(self @ T, icon_names @ Agg.List.T, size @ Std.Integer.SmallT, flags @ Std.Integer.SmallT) : Gtk.Gtk.IconInfo.T

Looks up a named icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using Gtk.Gtk.IconInfo.LoadIcon. (LoadIcon combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

icon_theme a T
icon_names NULL-terminated array of icon names to lookup. [array zero-terminated=1]
size desired icon size
flags flags modifying the behavior of the icon lookup
Returns a Gtk.Gtk.IconInfo.T structure containing information about the icon, or NULL if the icon wasn't found. Free with Gtk.Gtk.IconInfo.Free


:GetExampleIconName(self @ T) : Std.String.T

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.)

icon_theme a T
Returns the name of an example icon or NULL. Free with g_free().


:GetIconSizes(self @ T, icon_name @ Std.String.T) : Std.Object.T

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.

icon_theme a T
icon_name the name of an icon
Returns An newly allocated array describing the sizes at which the icon is available. The array should be freed with g_free() when it is no longer needed. [array zero-terminated=1]


:GetSearchPath(self @ T, path @ Agg.List.T, n_elements @ Std.Object.T) : Std.Object.T



:HasIcon(self @ T, icon_name @ Std.String.T) : Std.Symbol.T

Checks whether an icon theme includes an icon for a particular name.

icon_theme a T
icon_name the name of an icon
Returns TRUE if icon_theme includes an icon for icon_name.


:ListContexts(self @ T) : Std.Object.T

Gets the list of contexts available within the current hierarchy of icon themes

icon_theme a T
Returns a GList list holding the names of all the contexts in the theme. You must first free each element in the list with g_free(), then free the list itself with g_list_free(). [element-type utf8][transfer full]


:ListIcons(self @ T, context @ Std.String.T) : Std.Object.T

Lists the icons in the current icon theme. Only a subset of the icons can be listed by providing a context string. The set of values for the context string is system dependent, but will typically include such values as "Applications" and "MimeTypes".

icon_theme a T
context a string identifying a particular type of icon, or NULL to list all icons.
Returns a GList list holding the names of all the icons in the theme. You must first free each element in the list with g_free(), then free the list itself with g_list_free(). [element-type utf8][transfer full]


:LoadIcon(self @ T, icon_name @ Std.String.T, size @ Std.Integer.SmallT, flags @ Std.Integer.SmallT, error @ Std.Object.T) : Gtk.Gdk.Pixbuf.T

Looks up an icon in an icon theme, scales it to the given size and renders it into a pixbuf. This is a convenience function; if more details about the icon are needed, use LookupIcon followed by Gtk.Gtk.IconInfo.LoadIcon.

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the GtkWidget::style-set signal. If for some reason you do not want to update the icon when the icon theme changes, you should consider using Gtk.Gdk.Pixbuf.Copy to make a private copy of the pixbuf returned by this function. Otherwise GTK+ may need to keep the old icon theme loaded, which would be a waste of memory.

icon_theme a T
icon_name the name of the icon to lookup
size the desired icon size. The resulting icon may not be exactly this size; see Gtk.Gtk.IconInfo.LoadIcon.
flags flags modifying the behavior of the icon lookup
error Location to store error information on failure, or NULL. [allow-none]
Returns the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. NULL if the icon isn't found. [transfer full]


:LookupByGicon(self @ T, icon @ Gtk.Gio.GIcon.T, size @ Std.Integer.SmallT, flags @ Std.Integer.SmallT) : Gtk.Gtk.IconInfo.T

Looks up an icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using Gtk.Gtk.IconInfo.LoadIcon.

icon_theme a T
icon the GIcon to look up
size desired icon size
flags flags modifying the behavior of the icon lookup
Returns a Gtk.Gtk.IconInfo.T structure containing information about the icon, or NULL if the icon wasn't found. Free with Gtk.Gtk.IconInfo.Free


:LookupIcon(self @ T, icon_name @ Std.String.T, size @ Std.Integer.SmallT, flags @ Std.Integer.SmallT) : Gtk.Gtk.IconInfo.T

Looks up a named icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using Gtk.Gtk.IconInfo.LoadIcon. (LoadIcon combines these two steps if all you need is the pixbuf.)

icon_theme a T
icon_name the name of the icon to lookup
size desired icon size
flags flags modifying the behavior of the icon lookup
Returns a Gtk.Gtk.IconInfo.T structure containing information about the icon, or NULL if the icon wasn't found. Free with Gtk.Gtk.IconInfo.Free


:PrependSearchPath(self @ T, path @ Std.String.T) : Std.Object.T



:RescanIfNeeded(self @ T) : Std.Symbol.T

Checks to see if the icon theme has changed; if it has, any currently cached information is discarded and will be reloaded next time icon_theme is accessed.

icon_theme a T
Returns TRUE if the icon theme has changed and needed to be reloaded.


:SetCustomTheme(self @ T, theme_name @ Std.String.T) : Std.Object.T

Sets the name of the icon theme that the T object uses overriding system configuration. This function cannot be called on the icon theme objects returned from GetDefault and GetForScreen.

icon_theme a T
theme_name name of icon theme to use instead of configured theme, or NULL to unset a previously set custom theme


:SetScreen(self @ T, screen @ Gtk.Gdk.Screen.T) : Std.Object.T

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.

icon_theme a T
screen a Gtk.Gdk.Screen.T


:SetSearchPath(self @ T, path @ Agg.List.T, n_elements @ Std.Integer.SmallT) : Std.Object.T