Gtk.IconSet

Fields

None

Methods

class

new ()

class

new_from_pixbuf (pixbuf)

add_source (source)

copy ()

get_sizes ()

ref ()

render_icon (style, direction, state, size, widget, detail)

render_icon_pixbuf (context, size)

render_icon_surface (context, size, scale, for_window)

unref ()

Details

class Gtk.IconSet(*args, **kwargs)
classmethod new()[source]
Returns:

a new Gtk.IconSet

Return type:

Gtk.IconSet

Creates a new Gtk.IconSet. A Gtk.IconSet represents a single icon in various sizes and widget states. It can provide a GdkPixbuf.Pixbuf for a given size and state on request, and automatically caches some of the rendered GdkPixbuf.Pixbuf objects.

Normally you would use Gtk.Widget.render_icon_pixbuf() instead of using Gtk.IconSet directly. The one case where you’d use Gtk.IconSet is to create application-specific icon sets to place in a Gtk.IconFactory.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

classmethod new_from_pixbuf(pixbuf)[source]
Parameters:

pixbuf (GdkPixbuf.Pixbuf) – a GdkPixbuf.Pixbuf

Returns:

a new Gtk.IconSet

Return type:

Gtk.IconSet

Creates a new Gtk.IconSet with pixbuf as the default/fallback source image. If you don’t add any additional Gtk.IconSource to the icon set, all variants of the icon will be created from pixbuf, using scaling, pixelation, etc. as required to adjust the icon size or make the icon look insensitive/prelighted.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

add_source(source)[source]
Parameters:

source (Gtk.IconSource) – a Gtk.IconSource

Icon sets have a list of Gtk.IconSource, which they use as base icons for rendering icons in different states and sizes. Icons are scaled, made to look insensitive, etc. in Gtk.IconSet.render_icon(), but Gtk.IconSet needs base images to work with. The base images and when to use them are described by a Gtk.IconSource.

This function copies source, so you can reuse the same source immediately without affecting the icon set.

An example of when you’d use this function: a web browser’s “Back to Previous Page” icon might point in a different direction in Hebrew and in English; it might look different when insensitive; and it might change size depending on toolbar mode (small/large icons). So a single icon set would contain all those variants of the icon, and you might add a separate source for each one.

You should nearly always add a “default” icon source with all fields wildcarded, which will be used as a fallback if no more specific source matches. Gtk.IconSet always prefers more specific icon sources to more generic icon sources. The order in which you add the sources to the icon set does not matter.

Gtk.IconSet.new_from_pixbuf() creates a new icon set with a default icon source based on the given pixbuf.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

copy()[source]
Returns:

a new Gtk.IconSet identical to the first.

Return type:

Gtk.IconSet

Copies self by value.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_sizes()[source]
Returns:

return location for array of sizes (Gtk.IconSize)

Return type:

sizes: [int]

Obtains a list of icon sizes this icon set can render. The returned array must be freed with GLib.free().

Deprecated since version 3.10: Use Gtk.IconTheme instead.

ref()[source]
Returns:

self.

Return type:

Gtk.IconSet

Increments the reference count on self.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

render_icon(style, direction, state, size, widget, detail)[source]
Parameters:
  • style (Gtk.Style or None) – a Gtk.Style associated with widget, or None

  • direction (Gtk.TextDirection) – text direction

  • state (Gtk.StateType) – widget state

  • size (int) – icon size (Gtk.IconSize). A size of (GtkIconSize)-1 means render at the size of the source and don’t scale.

  • widget (Gtk.Widget or None) – widget that will display the icon, or None. The only use that is typically made of this is to determine the appropriate Gdk.Screen.

  • detail (str or None) – detail to pass to the theme engine, or None. Note that passing a detail of anything but None will disable caching.

Returns:

a GdkPixbuf.Pixbuf to be displayed

Return type:

GdkPixbuf.Pixbuf

Renders an icon using Gtk.Style.render_icon(). In most cases, Gtk.Widget.render_icon() is better, since it automatically provides most of the arguments from the current widget settings. This function never returns None; if the icon can’t be rendered (perhaps because an image file fails to load), a default “missing image” icon will be returned instead.

Deprecated since version 3.0: Use Gtk.IconSet.render_icon_pixbuf() instead

render_icon_pixbuf(context, size)[source]
Parameters:
Returns:

a GdkPixbuf.Pixbuf to be displayed

Return type:

GdkPixbuf.Pixbuf

Renders an icon using Gtk.render_icon_pixbuf(). In most cases, Gtk.Widget.render_icon_pixbuf() is better, since it automatically provides most of the arguments from the current widget settings. This function never returns None; if the icon can’t be rendered (perhaps because an image file fails to load), a default “missing image” icon will be returned instead.

New in version 3.0.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

render_icon_surface(context, size, scale, for_window)[source]
Parameters:
Returns:

a cairo.Surface to be displayed

Return type:

cairo.Surface

Renders an icon using Gtk.render_icon_pixbuf() and converts it to a cairo surface.

This function never returns None; if the icon can’t be rendered (perhaps because an image file fails to load), a default “missing image” icon will be returned instead.

New in version 3.10.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

unref()[source]

Decrements the reference count on self, and frees memory if the reference count reaches 0.

Deprecated since version 3.10: Use Gtk.IconTheme instead.