Gtk.IconInfo

g GObject.Object GObject.Object Gtk.IconInfo Gtk.IconInfo GObject.Object->Gtk.IconInfo

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new_for_pixbuf (icon_theme, pixbuf)
  get_attach_points ()
  get_base_scale ()
  get_base_size ()
  get_builtin_pixbuf ()
  get_display_name ()
  get_embedded_rect ()
  get_filename ()
  is_symbolic ()
  load_icon ()
  load_icon_async (cancellable, callback, *user_data)
  load_icon_finish (res)
  load_surface (for_window)
  load_symbolic (fg, success_color, warning_color, error_color)
  load_symbolic_async (fg, success_color, warning_color, error_color, cancellable, callback, *user_data)
  load_symbolic_finish (res)
  load_symbolic_for_context (context)
  load_symbolic_for_context_async (context, cancellable, callback, *user_data)
  load_symbolic_for_context_finish (res)
  load_symbolic_for_style (style, state)
  set_raw_coordinates (raw_coordinates)

Virtual Methods

Inherited:GObject.Object (7)

Properties

None

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)

Class Details

class Gtk.IconInfo(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:Gtk.IconInfoClass

Contains information found when looking up an icon in an icon theme.

classmethod new_for_pixbuf(icon_theme, pixbuf)[source]
Parameters:
Returns:

a Gtk.IconInfo

Return type:

Gtk.IconInfo

Creates a Gtk.IconInfo for a GdkPixbuf.Pixbuf.

New in version 2.14.

get_attach_points()[source]
Returns:False
points:location to store pointer to an array of points, or None free the array of points with GLib.free().
Return type:(bool, points: [Gdk.Point])

This function is deprecated and always returns False.

New in version 2.4.

Deprecated since version 3.14: Attachment points are deprecated

get_base_scale()[source]
Returns:the base scale
Return type:int

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.

New in version 3.10.

get_base_size()[source]
Returns:the base size, or 0, if no base size is known for the icon.
Return type:int

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.

New in version 2.4.

get_builtin_pixbuf()[source]
Returns:the built-in image pixbuf, or None. No extra reference is added to the returned pixbuf, so if you want to keep it around, you must use GObject.Object.ref(). The returned image must not be modified.
Return type:GdkPixbuf.Pixbuf or None

Gets the built-in image for this icon, if any. To allow GTK+ to use built in icon images, you must pass the Gtk.IconLookupFlags.USE_BUILTIN to Gtk.IconTheme.lookup_icon().

New in version 2.4.

Deprecated since version 3.14: This function is deprecated, use Gtk.IconTheme.add_resource_path() instead of builtin icons.

get_display_name()[source]
Returns:None
Return type:str

This function is deprecated and always returns None.

New in version 2.4.

Deprecated since version 3.14: xlib.Display names are deprecated

get_embedded_rect()[source]
Returns:False
rectangle:Gdk.Rectangle in which to store embedded rectangle coordinates; coordinates are only stored when this function returns True.
Return type:(bool, rectangle: Gdk.Rectangle)

This function is deprecated and always returns False.

New in version 2.4.

Deprecated since version 3.14: Embedded rectangles are deprecated

get_filename()[source]
Returns:the filename for the icon, or None if Gtk.IconInfo.get_builtin_pixbuf() should be used instead. The return value is owned by GTK+ and should not be modified or freed.
Return type:str or None

Gets the filename for the icon. If the Gtk.IconLookupFlags.USE_BUILTIN flag was passed to Gtk.IconTheme.lookup_icon(), there may be no filename if a builtin icon is returned; in this case, you should use Gtk.IconInfo.get_builtin_pixbuf().

New in version 2.4.

is_symbolic()[source]
Returns:True if the icon is symbolic, False otherwise
Return type:bool

Checks if the icon is symbolic or not. This currently uses only the file name and not the file contents for determining this. This behaviour may change in the future.

New in version 3.12.

load_icon()[source]
Raises:GLib.Error
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 GObject.Object.unref() to release your reference to the icon.
Return type:GdkPixbuf.Pixbuf

Renders an icon previously looked up in an icon theme using Gtk.IconTheme.lookup_icon(); the size will be based on the size passed to Gtk.IconTheme.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.IconLookupFlags.FORCE_SIZE flag when obtaining the Gtk.IconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

New in version 2.4.

load_icon_async(cancellable, callback, *user_data)[source]
Parameters:

Asynchronously load, render and scale an icon previously looked up from the icon theme using Gtk.IconTheme.lookup_icon().

For more details, see Gtk.IconInfo.load_icon() which is the synchronous version of this call.

New in version 3.8.

load_icon_finish(res)[source]
Parameters:res (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
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 GObject.Object.unref() to release your reference to the icon.
Return type:GdkPixbuf.Pixbuf

Finishes an async icon load, see Gtk.IconInfo.load_icon_async().

New in version 3.8.

load_surface(for_window)[source]
Parameters:for_window (Gdk.Window or None) – Gdk.Window to optimize drawing for, or None
Raises:GLib.Error
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 cairo_surface_destroy() to release your reference to the icon.
Return type:cairo.Surface

Renders an icon previously looked up in an icon theme using Gtk.IconTheme.lookup_icon(); the size will be based on the size passed to Gtk.IconTheme.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.IconLookupFlags.FORCE_SIZE flag when obtaining the Gtk.IconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

New in version 3.10.

load_symbolic(fg, success_color, warning_color, error_color)[source]
Parameters:
  • fg (Gdk.RGBA) – a Gdk.RGBA representing the foreground color of the icon
  • success_color (Gdk.RGBA or None) – a Gdk.RGBA representing the warning color of the icon or None to use the default color
  • warning_color (Gdk.RGBA or None) – a Gdk.RGBA representing the warning color of the icon or None to use the default color
  • error_color (Gdk.RGBA or None) – a Gdk.RGBA representing the error color of the icon or None to use the default color (allow-none)
Raises:

GLib.Error

Returns:

a GdkPixbuf.Pixbuf representing the loaded icon

was_symbolic:a bool, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Return type:

(GdkPixbuf.Pixbuf, was_symbolic: bool)

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.IconInfo.load_icon().

This allows loading symbolic icons that will match the system theme.

Unless you are implementing a widget, you will want to use Gio.ThemedIcon.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 Specification for more information about symbolic icons.

New in version 3.0.

load_symbolic_async(fg, success_color, warning_color, error_color, cancellable, callback, *user_data)[source]
Parameters:

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using Gtk.IconTheme.lookup_icon().

For more details, see Gtk.IconInfo.load_symbolic() which is the synchronous version of this call.

New in version 3.8.

load_symbolic_finish(res)[source]
Parameters:res (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
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 GObject.Object.unref() to release your reference to the icon.
was_symbolic:a bool, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.
Return type:(GdkPixbuf.Pixbuf, was_symbolic: bool)

Finishes an async icon load, see Gtk.IconInfo.load_symbolic_async().

New in version 3.8.

load_symbolic_for_context(context)[source]
Parameters:context (Gtk.StyleContext) – a Gtk.StyleContext
Raises:GLib.Error
Returns:a GdkPixbuf.Pixbuf representing the loaded icon
was_symbolic:a bool, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.
Return type:(GdkPixbuf.Pixbuf, was_symbolic: bool)

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.IconInfo.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.IconInfo.load_symbolic() for more details.

New in version 3.0.

load_symbolic_for_context_async(context, cancellable, callback, *user_data)[source]
Parameters:

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using Gtk.IconTheme.lookup_icon().

For more details, see Gtk.IconInfo.load_symbolic_for_context() which is the synchronous version of this call.

New in version 3.8.

load_symbolic_for_context_finish(res)[source]
Parameters:res (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
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 GObject.Object.unref() to release your reference to the icon.
was_symbolic:a bool, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.
Return type:(GdkPixbuf.Pixbuf, was_symbolic: bool)

Finishes an async icon load, see Gtk.IconInfo.load_symbolic_for_context_async().

New in version 3.8.

load_symbolic_for_style(style, state)[source]
Parameters:
Raises:

GLib.Error

Returns:

a GdkPixbuf.Pixbuf representing the loaded icon

was_symbolic:a bool, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Return type:

(GdkPixbuf.Pixbuf, was_symbolic: bool)

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.IconInfo.load_icon().

This allows loading symbolic icons that will match the system theme.

See Gtk.IconInfo.load_symbolic() for more details.

New in version 3.0.

Deprecated since version 3.0: Use Gtk.IconInfo.load_symbolic_for_context() instead

set_raw_coordinates(raw_coordinates)[source]
Parameters:raw_coordinates (bool) – whether the coordinates of embedded rectangles and attached points should be returned in their original (unscaled) form.

Sets whether the coordinates returned by Gtk.IconInfo.get_embedded_rect() and Gtk.IconInfo.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.IconInfo.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.IconInfo.get_filename(), and seeing if it is non-None 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.

New in version 2.4.

Deprecated since version 3.14: Embedded rectangles and attachment points are deprecated