gtkmm  3.93.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::IconTheme Class Reference

Looking up icons by name. More...

#include <gtkmm/icontheme.h>

Inheritance diagram for Gtk::IconTheme:
Inheritance graph
[legend]

Public Member Functions

 IconTheme (IconTheme&& src) noexcept
 
IconThemeoperator= (IconTheme&& src) noexcept
 
 ~IconTheme () noexcept override
 
GtkIconTheme* gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkIconTheme* gobj () const
 Provides access to the underlying C GObject. More...
 
GtkIconTheme* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
void set_display (const Glib::RefPtr< Gdk::Display >& display)
 Sets the display for an icon theme; the display is used to track the user’s currently configured icon theme, which might be different for different displays. More...
 
void set_search_path (const std::vector< Glib::ustring >& path)
 
std::vector< Glib::ustringget_search_path () const
 
void append_search_path (const Glib::ustring& path)
 Appends a directory to the search path. More...
 
void prepend_search_path (const Glib::ustring& path)
 Prepends a directory to the search path. More...
 
void add_resource_path (const std::string& path)
 Adds a resource path that will be looked at when looking for icons, similar to search paths. More...
 
void set_custom_theme (const Glib::ustring& theme_name)
 Sets the name of the icon theme that the Gtk::IconTheme object uses overriding system configuration. More...
 
bool has_icon (const Glib::ustring& icon_name) const
 Checks whether an icon theme includes an icon for a particular name. More...
 
std::vector< int > get_icon_sizes (const Glib::ustring& icon_name) const
 
Glib::RefPtr< IconInfolookup_icon (const Glib::ustring& icon_name, int size, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up a named icon and returns a structure containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfolookup_icon (const Glib::ustring& icon_name, int size, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up a named icon and returns a structure containing information such as the filename of the icon. More...
 
Glib::RefPtr< IconInfolookup_icon (const Glib::ustring& icon_name, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfolookup_icon (const Glib::ustring& icon_name, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< IconInfolookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfolookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< IconInfolookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfolookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< IconInfochoose_icon (const std::vector< Glib::ustring >& icon_names, int size, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up a named icon and returns a structure containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfochoose_icon (const std::vector< Glib::ustring >& icon_names, int size, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up a named icon and returns a structure containing information such as the filename of the icon. More...
 
Glib::RefPtr< IconInfochoose_icon (const std::vector< Glib::ustring >& icon_names, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0)
 Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< const IconInfochoose_icon (const std::vector< Glib::ustring >& icon_names, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon. More...
 
Glib::RefPtr< const Gdk::Pixbufload_icon (const Glib::ustring& icon_name, int size, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up an icon in an icon theme, scales it to the given size and renders it into a pixbuf. More...
 
Glib::RefPtr< const Gdk::Pixbufload_icon (const Glib::ustring& icon_name, int size, int scale, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up an icon in an icon theme for a particular window scale, scales it to the given size and renders it into a pixbuf. More...
 
Cairo::RefPtr< const Cairo::Surfaceload_surface (const Glib::ustring& icon_name, int size, int scale, const Glib::RefPtr< Gdk::Window >& for_window, IconLookupFlags flags=(IconLookupFlags) 0) const
 Looks up an icon in an icon theme for a particular window scale, scales it to the given size and renders it into a cairo surface. More...
 
std::vector< Glib::ustringlist_icons (const Glib::ustring& context) const
 Lists a subset of icons in the current icon theme, by providing a context string. More...
 
std::vector< Glib::ustringlist_icons () const
 Lists the icons in the current icon theme. More...
 
std::vector< Glib::ustringlist_contexts () const
 Gets the list of contexts available within the current hierarchy of icon themes. More...
 
Glib::ustring get_example_icon_name () const
 Gets the name of an icon that is representative of the current theme (for instance, to use when presenting a list of themes to the user.) More...
 
bool rescan_if_needed ()
 Checks to see if the icon theme has changed; if it has, any currently cached information is discarded and will be reloaded next time icon_theme is accessed. More...
 
Glib::SignalProxy< void()> signal_changed ()
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src)
 
 ~trackable ()
 
void add_destroy_notify_callback (void *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src)
 
void remove_destroy_notify_callback (void *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< IconThemecreate ()
 
static Glib::RefPtr< IconThemeget_default ()
 Gets the icon theme for the default display. More...
 
static Glib::RefPtr< IconThemeget_for_display (const Glib::RefPtr< Gdk::Display >& display)
 Gets the icon theme object associated with display; if this function has not previously been called for the given display, a new icon theme object will be created and associated with the display. More...
 

Protected Member Functions

 IconTheme ()
 
virtual void on_changed ()
 This is a default handler for the signal signal_changed(). More...
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::IconThemewrap (GtkIconTheme* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 

Detailed Description

Looking up icons by name.

Gtk::IconTheme 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 fallback icon theme, named hicolor, where applications should install their icons, but additional icon themes can be installed as operating system vendors and users choose.

In many cases, named themes are used indirectly, via Gtk::Image rather than directly, but looking up icons directly is also simple. The Gtk::IconTheme object acts as a database of all the icons in the current theme. You can create new Gtk::IconTheme objects, but it’s much more efficient to use the standard icon theme for the Gdk::Display so that the icon information is shared with other people looking up icons. Use get_default() or get_for_display().

Constructor & Destructor Documentation

◆ IconTheme() [1/2]

Gtk::IconTheme::IconTheme ( IconTheme&&  src)
noexcept

◆ ~IconTheme()

Gtk::IconTheme::~IconTheme ( )
overridenoexcept

◆ IconTheme() [2/2]

Gtk::IconTheme::IconTheme ( )
protected

Member Function Documentation

◆ add_resource_path()

void Gtk::IconTheme::add_resource_path ( const std::string path)

Adds a resource path that will be looked at when looking for icons, similar to search paths.

This function should be used to make application-specific icons available as part of the icon theme.

The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as @a path/16x16/actions/run.png. Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback.

Parameters
pathA resource path.

◆ append_search_path()

void Gtk::IconTheme::append_search_path ( const Glib::ustring path)

Appends a directory to the search path.

See set_search_path().

Parameters
pathDirectory name to append to the icon path.

◆ choose_icon() [1/4]

Glib::RefPtr<IconInfo> Gtk::IconTheme::choose_icon ( const std::vector< Glib::ustring > &  icon_names,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up a named icon and returns a structure containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Since gtkmm 2.12:
Parameters
icon_namesArray of icon names to lookup.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo structure containing information about the icon. IconInfo::operator bool() will be false if the icon wasn't found - for instance, if (icon_info) { ... }.

◆ choose_icon() [2/4]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::choose_icon ( const std::vector< Glib::ustring > &  icon_names,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up a named icon and returns a structure containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Since gtkmm 2.12:
Parameters
icon_namesArray of icon names to lookup.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo structure containing information about the icon. IconInfo::operator bool() will be false if the icon wasn't found - for instance, if (icon_info) { ... }.

◆ choose_icon() [3/4]

Glib::RefPtr<IconInfo> Gtk::IconTheme::choose_icon ( const std::vector< Glib::ustring > &  icon_names,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Parameters
icon_namesnullptr-terminated array of icon names to lookup.
sizeDesired icon size.
scaleDesired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo object containing information about the icon, or nullptr if the icon wasn’t found.

◆ choose_icon() [4/4]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::choose_icon ( const std::vector< Glib::ustring > &  icon_names,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

If icon_names contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

Parameters
icon_namesnullptr-terminated array of icon names to lookup.
sizeDesired icon size.
scaleDesired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo object containing information about the icon, or nullptr if the icon wasn’t found.

◆ create()

static Glib::RefPtr<IconTheme> Gtk::IconTheme::create ( )
static

◆ get_default()

static Glib::RefPtr<IconTheme> Gtk::IconTheme::get_default ( )
static

Gets the icon theme for the default display.

See get_for_display().

Returns
A unique Gtk::IconTheme associated with the default display. This icon theme is associated with the display and can be used as long as the display is open. Do not ref or unref it.

◆ get_example_icon_name()

Glib::ustring Gtk::IconTheme::get_example_icon_name ( ) const

Gets the name of an icon that is representative of the current theme (for instance, to use when presenting a list of themes to the user.)

◆ get_for_display()

static Glib::RefPtr<IconTheme> Gtk::IconTheme::get_for_display ( const Glib::RefPtr< Gdk::Display >&  display)
static

Gets the icon theme object associated with display; if this function has not previously been called for the given display, a new icon theme object will be created and associated with the display.

Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than new() and setting the display yourself; by using this function a single icon theme object will be shared between users.

Parameters
displayA Gdk::Display.
Returns
A unique Gtk::IconTheme associated with the given display. This icon theme is associated with the display and can be used as long as the display is open. Do not ref or unref it.

◆ get_icon_sizes()

std::vector<int> Gtk::IconTheme::get_icon_sizes ( const Glib::ustring icon_name) const

◆ get_search_path()

std::vector<Glib::ustring> Gtk::IconTheme::get_search_path ( ) const

◆ get_type()

static GType Gtk::IconTheme::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GtkIconTheme* Gtk::IconTheme::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkIconTheme* Gtk::IconTheme::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkIconTheme* Gtk::IconTheme::gobj_copy ( )

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

◆ has_icon()

bool Gtk::IconTheme::has_icon ( const Glib::ustring icon_name) const

Checks whether an icon theme includes an icon for a particular name.

Parameters
icon_nameThe name of an icon.
Returns
true if icon_theme includes an icon for icon_name.

◆ list_contexts()

std::vector<Glib::ustring> Gtk::IconTheme::list_contexts ( ) const

Gets the list of contexts available within the current hierarchy of icon themes.

Since gtkmm 2.12:
Returns
A list holding the names of all the contexts in the theme.

◆ list_icons() [1/2]

std::vector<Glib::ustring> Gtk::IconTheme::list_icons ( const Glib::ustring context) const

Lists a subset of icons in the current icon theme, by providing a context string.

The set of values for the context string is system dependent, but will typically include such values as 'Applications' and 'MimeTypes'.

Since gtkmm 2.4:
Parameters
contextA string identifying a particular type of icon.
Returns
The names of all the icons in the theme.

◆ list_icons() [2/2]

std::vector<Glib::ustring> Gtk::IconTheme::list_icons ( ) const

Lists the icons in the current icon theme.

Returns
A list holding the names of all the icons in the theme.
Since gtkmm 2.10:

◆ load_icon() [1/2]

Glib::RefPtr<const Gdk::Pixbuf> Gtk::IconTheme::load_icon ( const Glib::ustring icon_name,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up an icon in an icon theme, scales it to the given size and renders it into a pixbuf.

This is a convenience function; if more details about the icon are needed, use lookup_icon() followed by Gtk::IconInfo::load_icon().

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the GtkWidget::style-set signal. If for some reason you do not want to update the icon when the icon theme changes, you should consider using gdk_pixbuf_copy() to make a private copy of the pixbuf returned by this function. Otherwise GTK+ may need to keep the old icon theme loaded, which would be a waste of memory.

Parameters
icon_nameThe name of the icon to lookup.
sizeThe desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon().
flagsFlags modifying the behavior of the icon lookup.
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 Glib::object_unref() to release your reference to the icon. nullptr if the icon isn’t found.
Exceptions
Glib::Error

◆ load_icon() [2/2]

Glib::RefPtr<const Gdk::Pixbuf> Gtk::IconTheme::load_icon ( const Glib::ustring icon_name,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up an icon in an icon theme for a particular window scale, scales it to the given size and renders it into a pixbuf.

This is a convenience function; if more details about the icon are needed, use lookup_icon() followed by Gtk::IconInfo::load_icon().

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the GtkWidget::style-set signal. If for some reason you do not want to update the icon when the icon theme changes, you should consider using gdk_pixbuf_copy() to make a private copy of the pixbuf returned by this function. Otherwise GTK+ may need to keep the old icon theme loaded, which would be a waste of memory.

Parameters
icon_nameThe name of the icon to lookup.
sizeThe desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon().
scaleDesired scale.
flagsFlags modifying the behavior of the icon lookup.
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 Glib::object_unref() to release your reference to the icon. nullptr if the icon isn’t found.
Exceptions
Glib::Error

◆ load_surface()

Cairo::RefPtr<const Cairo::Surface> Gtk::IconTheme::load_surface ( const Glib::ustring icon_name,
int  size,
int  scale,
const Glib::RefPtr< Gdk::Window >&  for_window,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up an icon in an icon theme for a particular window scale, scales it to the given size and renders it into a cairo surface.

This is a convenience function; if more details about the icon are needed, use lookup_icon() followed by Gtk::IconInfo::load_surface().

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the GtkWidget::style-set signal.

Parameters
icon_nameThe name of the icon to lookup.
sizeThe desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon().
scaleDesired scale.
for_windowGdk::Window to optimize drawing for, or nullptr.
flagsFlags modifying the behavior of the icon lookup.
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. nullptr if the icon isn’t found.
Exceptions
Glib::Error

◆ lookup_icon() [1/8]

Glib::RefPtr<IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::ustring icon_name,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up a named icon and returns a structure containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

Since gtkmm 2.4:
Parameters
icon_nameThe name of the icon to lookup.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
An IconInfo structure containing information about the icon. IconInfo::operator bool() will return false if the icon wasn't found. For instance, if (icon_info) { ... }.

◆ lookup_icon() [2/8]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::ustring icon_name,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up a named icon and returns a structure containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

Since gtkmm 2.4:
Parameters
icon_nameThe name of the icon to lookup.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
An IconInfo structure containing information about the icon. IconInfo::operator bool() will return false if the icon wasn't found. For instance, if (icon_info) { ... }.

◆ lookup_icon() [3/8]

Glib::RefPtr<IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::ustring icon_name,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

Parameters
icon_nameThe name of the icon to lookup.
sizeDesired icon size.
scaleThe desired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo object containing information about the icon, or nullptr if the icon wasn’t found.

◆ lookup_icon() [4/8]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::ustring icon_name,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up a named icon for a particular window scale and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon(). (load_icon() combines these two steps if all you need is the pixbuf.)

Parameters
icon_nameThe name of the icon to lookup.
sizeDesired icon size.
scaleThe desired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo object containing information about the icon, or nullptr if the icon wasn’t found.

◆ lookup_icon() [5/8]

Glib::RefPtr<IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::RefPtr< const Gio::Icon > &  icon,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon().

When rendering on displays with high pixel densities you should not use a size multiplied by the scaling factor returned by functions like gdk_window_get_scale_factor(). Instead, you should use lookup_by_gicon_for_scale(), as the assets loaded for a given scaling factor may be different.

Parameters
iconThe Gio::Icon to look up.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo containing information about the icon, or nullptr if the icon wasn’t found. Unref with Glib::object_unref().

◆ lookup_icon() [6/8]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::RefPtr< const Gio::Icon > &  icon,
int  size,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon().

When rendering on displays with high pixel densities you should not use a size multiplied by the scaling factor returned by functions like gdk_window_get_scale_factor(). Instead, you should use lookup_by_gicon_for_scale(), as the assets loaded for a given scaling factor may be different.

Parameters
iconThe Gio::Icon to look up.
sizeDesired icon size.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo containing information about the icon, or nullptr if the icon wasn’t found. Unref with Glib::object_unref().

◆ lookup_icon() [7/8]

Glib::RefPtr<IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::RefPtr< const Gio::Icon > &  icon,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
)

Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon().

Parameters
iconThe Gio::Icon to look up.
sizeDesired icon size.
scaleThe desired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo containing information about the icon, or nullptr if the icon wasn’t found. Unref with Glib::object_unref().

◆ lookup_icon() [8/8]

Glib::RefPtr<const IconInfo> Gtk::IconTheme::lookup_icon ( const Glib::RefPtr< const Gio::Icon > &  icon,
int  size,
int  scale,
IconLookupFlags  flags = (IconLookupFlags) 0 
) const

Looks up an icon and returns a Gtk::IconInfo containing information such as the filename of the icon.

The icon can then be rendered into a pixbuf using Gtk::IconInfo::load_icon().

Parameters
iconThe Gio::Icon to look up.
sizeDesired icon size.
scaleThe desired scale.
flagsFlags modifying the behavior of the icon lookup.
Returns
A Gtk::IconInfo containing information about the icon, or nullptr if the icon wasn’t found. Unref with Glib::object_unref().

◆ on_changed()

virtual void Gtk::IconTheme::on_changed ( )
protectedvirtual

This is a default handler for the signal signal_changed().

◆ operator=()

IconTheme& Gtk::IconTheme::operator= ( IconTheme&&  src)
noexcept

◆ prepend_search_path()

void Gtk::IconTheme::prepend_search_path ( const Glib::ustring path)

Prepends a directory to the search path.

See set_search_path().

Parameters
pathDirectory name to prepend to the icon path.

◆ rescan_if_needed()

bool Gtk::IconTheme::rescan_if_needed ( )

Checks to see if the icon theme has changed; if it has, any currently cached information is discarded and will be reloaded next time icon_theme is accessed.

Returns
true if the icon theme has changed and needed to be reloaded.

◆ set_custom_theme()

void Gtk::IconTheme::set_custom_theme ( const Glib::ustring theme_name)

Sets the name of the icon theme that the Gtk::IconTheme object uses overriding system configuration.

This function cannot be called on the icon theme objects returned from get_default() and get_for_display().

Parameters
theme_nameName of icon theme to use instead of configured theme, or nullptr to unset a previously set custom theme.

◆ set_display()

void Gtk::IconTheme::set_display ( const Glib::RefPtr< Gdk::Display >&  display)

Sets the display for an icon theme; the display is used to track the user’s currently configured icon theme, which might be different for different displays.

Parameters
displayA Gdk::Display.

◆ set_search_path()

void Gtk::IconTheme::set_search_path ( const std::vector< Glib::ustring > &  path)

◆ signal_changed()

Glib::SignalProxy<void()> Gtk::IconTheme::signal_changed ( )
Slot Prototype:
void on_my_changed()

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

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::IconTheme > wrap ( GtkIconTheme *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.