IconInfo

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 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 GtkIconSize enumeration, or by custom sizes defined by gtk_icon_size_register(), 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 GtkImage or stock items, 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 for the GdkScreen 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:

class IconInfo {}

Constructors

this
this(GtkIconInfo* gtkIconInfo)

Sets our main struct and passes it to the parent class

this
this(IconTheme iconTheme, Pixbuf pixbuf)

Creates a GtkIconInfo for a GdkPixbuf. Since 2.14

Destructor

~this
~this()
Undocumented in source.

Members

Functions

addOnChanged
void addOnChanged(void delegate(IconInfo) dlg, ConnectFlags connectFlags)

Emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.

copy
IconInfo copy()

Warning gtk_icon_info_copy has been deprecated since version 3.8 and should not be used in newly-written code. Use g_object_ref() Make a copy of a GtkIconInfo. Since 2.4

free
void free()

Warning gtk_icon_info_free has been deprecated since version 3.8 and should not be used in newly-written code. Use g_object_unref() Free a GtkIconInfo and associated information Since 2.4

getAttachPoints
int getAttachPoints(GdkPoint[] points)

Fetches the set of attach points for an icon. An attach point is a location in the icon that can be used as anchor points for attaching emblems or overlays to the icon. Since 2.4

getBaseScale
int getBaseScale()

Gets the base scale for the icon. The base scale is a scale for the icon that was specified by the icon theme creator. For instance an icon drawn for a high-dpi screen with window-scale 2 for a base size of 32 will be 64 pixels tall and have a base_scale of 2.

getBaseSize
int getBaseSize()

Gets the base size for the icon. The base size is a size for the icon that was specified by the icon theme creator. This may be different than the actual size of image; an example of this is small emblem icons that can be attached to a larger icon. These icons will be given the same base size as the larger icons to which they are attached. Note that for scaled icons the base size does not include the base scale. Since 2.4

getBuiltinPixbuf
Pixbuf getBuiltinPixbuf()

Gets the built-in image for this icon, if any. To allow GTK+ to use built in icon images, you must pass the GTK_ICON_LOOKUP_USE_BUILTIN to gtk_icon_theme_lookup_icon(). Since 2.4

getDisplayName
string getDisplayName()

Gets the display name for an icon. A display name is a string to be used in place of the icon name in a user visible context like a list of icons. Since 2.4 Signal Details The "changed" signal void user_function (GtkIconTheme *icon_theme, gpointer user_data) : Run Last Emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.

getEmbeddedRect
int getEmbeddedRect(Rectangle rectangle)

Gets the coordinates of a rectangle within the icon that can be used for display of information such as a preview of the contents of a text file. See gtk_icon_info_set_raw_coordinates() for further information about the coordinate system. Since 2.4

getFilename
string getFilename()

Gets the filename for the icon. If the GTK_ICON_LOOKUP_USE_BUILTIN flag was passed to gtk_icon_theme_lookup_icon(), there may be no filename if a builtin icon is returned; in this case, you should use gtk_icon_info_get_builtin_pixbuf(). Since 2.4

getIconInfoStruct
GtkIconInfo* getIconInfoStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

loadIcon
Pixbuf loadIcon()

Renders an icon previously looked up in an icon theme using gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting pixbuf may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the GtkIconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size. Since 2.4

loadIconAsync
void loadIconAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously load, render and scale an icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon(). For more details, see gtk_icon_info_load_icon() which is the synchronous version of this call.

loadIconFinish
Pixbuf loadIconFinish(AsyncResultIF res)

Finishes an async icon load, see gtk_icon_info_load_icon_async().

loadSurface
Surface loadSurface(Window forWindow)

Renders an icon previously looked up in an icon theme using gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting surface may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the GtkIconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

loadSymbolic
Pixbuf loadSymbolic(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, int wasSymbolic)

Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon(). This allows loading symbolic icons that will match the system theme. Unless you are implementing a widget, you will want to use g_themed_icon_new_with_default_fallbacks() to load the icon. As implementation details, the icon loaded needs to be of SVG type, contain the "symbolic" term as the last component of the icon name, and use the 'fg', 'success', 'warning' and 'error' CSS styles in the SVG file itself. See the Symbolic Icons spec for more information about symbolic icons.

loadSymbolicAsync
void loadSymbolicAsync(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon(). For more details, see gtk_icon_info_load_symbolic() which is the synchronous version of this call.

loadSymbolicFinish
Pixbuf loadSymbolicFinish(AsyncResultIF res, int wasSymbolic)

Finishes an async icon load, see gtk_icon_info_load_symbolic_async().

loadSymbolicForContext
Pixbuf loadSymbolicForContext(StyleContext context, int* wasSymbolic)

Loads an icon, modifying it to match the system colors for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon(). This function uses the regular foreground color and the symbolic colors with the names "success_color", "warning_color" and "error_color" from the context. This allows loading symbolic icons that will match the system theme. See gtk_icon_info_load_symbolic() for more details.

loadSymbolicForContextAsync
void loadSymbolicForContextAsync(StyleContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon(). For more details, see gtk_icon_info_load_symbolic_for_context() which is the synchronous version of this call.

loadSymbolicForContextFinish
Pixbuf loadSymbolicForContextFinish(AsyncResultIF res, int wasSymbolic)

Finishes an async icon load, see gtk_icon_info_load_symbolic_for_context_async().

loadSymbolicForStyle
Pixbuf loadSymbolicForStyle(Style style, GtkStateType state, int wasSymbolic)

Warning gtk_icon_info_load_symbolic_for_style has been deprecated since version 3.0 and should not be used in newly-written code. Use gtk_icon_info_load_symbolic_for_context() instead Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon(). This allows loading symbolic icons that will match the system theme. See gtk_icon_info_load_symbolic() for more details.

setRawCoordinates
void setRawCoordinates(int rawCoordinates)

Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect() and gtk_icon_info_get_attach_points() should be returned in their original form as specified in the icon theme, instead of scaled appropriately for the pixbuf returned by gtk_icon_info_load_icon(). Raw coordinates are somewhat strange; they are specified to be with respect to the unscaled pixmap for PNG and XPM icons, but for SVG icons, they are in a 1000x1000 coordinate space that is scaled to the final size of the icon. You can determine if the icon is an SVG icon by using gtk_icon_info_get_filename(), and seeing if it is non-NULL and ends in '.svg'. This function is provided primarily to allow compatibility wrappers for older API's, and is not expected to be useful for applications. Since 2.4

Static functions

callBackChanged
void callBackChanged(GtkIconTheme* iconThemeStruct, IconInfo _iconInfo)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gtkIconInfo
GtkIconInfo* gtkIconInfo;

the main Gtk struct

onChangedListeners
void delegate(IconInfo)[] onChangedListeners;
Undocumented in source.

Meta