gtkmm 3.24.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::IconSet Class Referencefinal

This manages a set of variants of a particular icon An IconSet contains variants for different sizes and widget states. More...

`#include <gtkmm/iconset.h>`

## Public Member Functions
void | reference () const
| Increment the reference count for this object. More...
void | unreference () const
| Decrement the reference count for this object. More...
GtkIconSet* | gobj ()
| Provides access to the underlying C instance. More...
const GtkIconSet* | gobj () const
| Provides access to the underlying C instance. More...
GtkIconSet* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
| IconSet ()=delete
| IconSet (const IconSet&)=delete
IconSet& | operator= (const IconSet&)=delete
Glib::RefPtr< IconSet > | copy () const
| Copies icon_set by value. More...
Glib::RefPtr< Gdk::Pixbuf > | render_icon_pixbuf (const Glib::RefPtr< StyleContext >& context, IconSize size)
| Renders an icon using gtk_render_icon_pixbuf(). More...
void | add_source (const IconSource& source)
| Icon sets have a list of Gtk::IconSource, which they use as base icons for rendering icons in different states and sizes. More...
std::vector< IconSize > | get_sizes () const

## Static Public Member Functions
static Glib::RefPtr< IconSet > | create ()
static Glib::RefPtr< IconSet > | create (const Glib::RefPtr< Gdk::Pixbuf >& pixbuf)
static Glib::RefPtr< IconSet > | lookup_default (const Gtk::StockID& stock_id)
| Looks for an icon in the list of default icon factories. More...

## Protected Member Functions
void | operator delete (void*, std::size_t)

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gtk::IconSet > | wrap (GtkIconSet* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

This manages a set of variants of a particular icon An IconSet contains variants for different sizes and widget states.

Icons in an icon factory are named by a stock ID, which is a simple string identifying the icon. Each GtkStyle has a list of GtkIconFactory derived from the current theme; those icon factories are consulted first when searching for an icon. If the theme doesn't set a particular icon, GTK+ looks for the icon in a list of default icon factories, maintained by gtk_icon_factory_add_default() and gtk_icon_factory_remove_default(). Applications with icons should add a default icon factory with their icons, which will allow themes to override the icons for the application.

Deprecated:
  Use Gtk::IconTheme instead.

## Constructor & Destructor Documentation

Gtk::IconSet::IconSet | ( |  | ) |
| delete

Gtk::IconSet::IconSet | ( | const IconSet& |  | ) |
| delete

## Member Function Documentation

void Gtk::IconSet::add_source | ( | const IconSource& | source | ) |

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

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

Deprecated: 3.10: Use Gtk::IconTheme instead.

Parameters

  source | A Gtk::IconSource.

Glib::RefPtr<IconSet> Gtk::IconSet::copy | ( |  | ) | const

Copies icon_set by value.

Deprecated: 3.10: Use Gtk::IconTheme instead.

Returns
  A new Gtk::IconSet identical to the first.

static Glib::RefPtr<IconSet> Gtk::IconSet::create | ( |  | ) |
| static

static Glib::RefPtr<IconSet> Gtk::IconSet::create | ( | const Glib::RefPtr< Gdk::Pixbuf >& | pixbuf | ) |
| static

std::vector<IconSize> Gtk::IconSet::get_sizes | ( |  | ) | const

GtkIconSet* Gtk::IconSet::gobj | ( |  | ) |

Provides access to the underlying C instance.

const GtkIconSet* Gtk::IconSet::gobj | ( |  | ) | const

Provides access to the underlying C instance.

GtkIconSet* Gtk::IconSet::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

static Glib::RefPtr<IconSet> Gtk::IconSet::lookup_default | ( | const Gtk::StockID& | stock_id | ) |
| static

Looks for an icon in the list of default icon factories.

For display to the user, you should use Gtk::Style::lookup_icon_set() on the Gtk::Style for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.

Deprecated: 3.10: Use Gtk::IconTheme instead.

Parameters

  stock_id | An icon name.

Returns
  A Gtk::IconSet, or `nullptr`.

void Gtk::IconSet::operator delete | ( | void * | ,
|  | std::size_t |
| ) |  |
| protected

IconSet& Gtk::IconSet::operator= | ( | const IconSet& |  | ) |
| delete

void Gtk::IconSet::reference | ( |  | ) | const

Increment the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

Glib::RefPtr<Gdk::Pixbuf> Gtk::IconSet::render_icon_pixbuf | ( | const Glib::RefPtr< StyleContext >& | context,
|  | IconSize | size
| ) |  |

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 `nullptr`; if the icon can’t be rendered (perhaps because an image file fails to load), a default "missing image" icon will be returned instead.

Since gtkmm 3.0:

Deprecated: 3.10: Use Gtk::IconTheme instead.

Parameters

  context | A Gtk::StyleContext.
  size | Icon size (Gtk::IconSize). A size of `(GtkIconSize)-1` means render at the size of the source and don’t scale.

Returns
  A Gdk::Pixbuf to be displayed.

void Gtk::IconSet::unreference | ( |  | ) | const

Decrement the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

## Friends And Related Function Documentation

Glib::RefPtr< Gtk::IconSet > wrap | ( | GtkIconSet * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.