Gtk.IconSource

Fields

None

Methods

class

new ()

copy ()

free ()

get_direction ()

get_direction_wildcarded ()

get_filename ()

get_icon_name ()

get_pixbuf ()

get_size ()

get_size_wildcarded ()

get_state ()

get_state_wildcarded ()

set_direction (direction)

set_direction_wildcarded (setting)

set_filename (filename)

set_icon_name (icon_name)

set_pixbuf (pixbuf)

set_size (size)

set_size_wildcarded (setting)

set_state (state)

set_state_wildcarded (setting)

Details

class Gtk.IconSource
classmethod new()[source]
Returns:

a new Gtk.IconSource

Return type:

Gtk.IconSource

Creates a new Gtk.IconSource. A Gtk.IconSource contains a GdkPixbuf.Pixbuf (or image filename) that serves as the base image for one or more of the icons in a Gtk.IconSet, along with a specification for which icons in the icon set will be based on that pixbuf or image file. An icon set contains a set of icons that represent “the same” logical concept in different states, different global text directions, and different sizes.

So for example 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. Gtk.IconSet contains a list of Gtk.IconSource from which it can derive specific icon variants in the set.

In the simplest case, Gtk.IconSet contains one source pixbuf from which it derives all variants. The convenience function Gtk.IconSet.new_from_pixbuf() handles this case; if you only have one source pixbuf, just use that function.

If you want to use a different base pixbuf for different icon variants, you create multiple icon sources, mark which variants they’ll be used to create, and add them to the icon set with Gtk.IconSet.add_source().

By default, the icon source has all parameters wildcarded. That is, the icon source will be used as the base icon for any desired text direction, widget state, or icon size.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

copy()[source]
Returns:

a new Gtk.IconSource

Return type:

Gtk.IconSource

Creates a copy of self; mostly useful for language bindings.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

free()[source]

Frees a dynamically-allocated icon source, along with its filename, size, and pixbuf fields if those are not None.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_direction()[source]
Returns:

text direction this source matches

Return type:

Gtk.TextDirection

Obtains the text direction this icon source applies to. The return value is only useful/meaningful if the text direction is not wildcarded.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_direction_wildcarded()[source]
Returns:

True if this icon source is a base for any text direction variant

Return type:

bool

Gets the value set by Gtk.IconSource.set_direction_wildcarded().

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_filename()[source]
Returns:

image filename. This string must not be modified or freed.

Return type:

str

Retrieves the source filename, or None if none is set. The filename is not a copy, and should not be modified or expected to persist beyond the lifetime of the icon source.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_icon_name()[source]
Returns:

icon name. This string must not be modified or freed.

Return type:

str

Retrieves the source icon name, or None if none is set. The icon_name is not a copy, and should not be modified or expected to persist beyond the lifetime of the icon source.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_pixbuf()[source]
Returns:

source pixbuf

Return type:

GdkPixbuf.Pixbuf

Retrieves the source pixbuf, or None if none is set. In addition, if a filename source is in use, this function in some cases will return the pixbuf from loaded from the filename. This is, for example, true for the Gtk.IconSource passed to the Gtk.Style render_icon() virtual function. The reference count on the pixbuf is not incremented.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_size()[source]
Returns:

icon size (Gtk.IconSize) this source matches.

Return type:

int

Obtains the icon size this source applies to. The return value is only useful/meaningful if the icon size is not wildcarded.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_size_wildcarded()[source]
Returns:

True if this icon source is a base for any icon size variant

Return type:

bool

Gets the value set by Gtk.IconSource.set_size_wildcarded().

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_state()[source]
Returns:

widget state this source matches

Return type:

Gtk.StateType

Obtains the widget state this icon source applies to. The return value is only useful/meaningful if the widget state is not wildcarded.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

get_state_wildcarded()[source]
Returns:

True if this icon source is a base for any widget state variant

Return type:

bool

Gets the value set by Gtk.IconSource.set_state_wildcarded().

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_direction(direction)[source]
Parameters:

direction (Gtk.TextDirection) – text direction this source applies to

Sets the text direction this icon source is intended to be used with.

Setting the text direction on an icon source makes no difference if the text direction is wildcarded. Therefore, you should usually call Gtk.IconSource.set_direction_wildcarded() to un-wildcard it in addition to calling this function.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_direction_wildcarded(setting)[source]
Parameters:

setting (bool) – True to wildcard the text direction

If the text direction is wildcarded, this source can be used as the base image for an icon in any Gtk.TextDirection. If the text direction is not wildcarded, then the text direction the icon source applies to should be set with Gtk.IconSource.set_direction(), and the icon source will only be used with that text direction.

Gtk.IconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_filename(filename)[source]
Parameters:

filename (str) – image file to use

Sets the name of an image file to use as a base image when creating icon variants for Gtk.IconSet. The filename must be absolute.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_icon_name(icon_name)[source]
Parameters:

icon_name (str or None) – name of icon to use

Sets the name of an icon to look up in the current icon theme to use as a base image when creating icon variants for Gtk.IconSet.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_pixbuf(pixbuf)[source]
Parameters:

pixbuf (GdkPixbuf.Pixbuf) – pixbuf to use as a source

Sets a pixbuf to use as a base image when creating icon variants for Gtk.IconSet.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_size(size)[source]
Parameters:

size (int) – icon size (Gtk.IconSize) this source applies to

Sets the icon size this icon source is intended to be used with.

Setting the icon size on an icon source makes no difference if the size is wildcarded. Therefore, you should usually call Gtk.IconSource.set_size_wildcarded() to un-wildcard it in addition to calling this function.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_size_wildcarded(setting)[source]
Parameters:

setting (bool) – True to wildcard the widget state

If the icon size is wildcarded, this source can be used as the base image for an icon of any size. If the size is not wildcarded, then the size the source applies to should be set with Gtk.IconSource.set_size() and the icon source will only be used with that specific size.

Gtk.IconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible.

Gtk.IconSet will normally scale wildcarded source images to produce an appropriate icon at a given size, but will not change the size of source images that match exactly.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_state(state)[source]
Parameters:

state (Gtk.StateType) – widget state this source applies to

Sets the widget state this icon source is intended to be used with.

Setting the widget state on an icon source makes no difference if the state is wildcarded. Therefore, you should usually call Gtk.IconSource.set_state_wildcarded() to un-wildcard it in addition to calling this function.

Deprecated since version 3.10: Use Gtk.IconTheme instead.

set_state_wildcarded(setting)[source]
Parameters:

setting (bool) – True to wildcard the widget state

If the widget state is wildcarded, this source can be used as the base image for an icon in any Gtk.StateType. If the widget state is not wildcarded, then the state the source applies to should be set with Gtk.IconSource.set_state() and the icon source will only be used with that specific state.

Gtk.IconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible.

Gtk.IconSet will normally transform wildcarded source images to produce an appropriate icon for a given state, for example lightening an image on prelight, but will not modify source images that match exactly.

Deprecated since version 3.10: Use Gtk.IconTheme instead.