gtkmm 3.24.7
|
#include <gtkmm/icontheme.h>
Inherits Glib::Object.
Public Member Functions | |
IconTheme (IconTheme && src) noexcept | |
IconTheme & | operator= (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_screen (const Glib::RefPtr< Gdk::Screen > & screen) |
Sets the screen for an icon theme; the screen is used to track the user’s currently configured icon theme, which might be different for different screens. More... | |
void | set_search_path (const std::vector< Glib::ustring > & path) |
std::vector< Glib::ustring > | get_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 |
IconInfo | 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. More... | |
IconInfo | 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. More... | |
IconInfo | 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. More... | |
IconInfo | 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. More... | |
IconInfo | 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. More... | |
IconInfo | 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. More... | |
Glib::RefPtr< Gdk::Pixbuf > | 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. More... | |
Glib::RefPtr< Gdk::Pixbuf > | 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. More... | |
::Cairo::RefPtr< ::Cairo::Surface > | load_surface (const Glib::ustring & icon_name, int size, int scale, const Glib::RefPtr< Gdk::Window > & for_window, IconLookupFlags flags=(IconLookupFlags) 0) |
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::ustring > | list_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::ustring > | list_icons () const |
Lists the icons in the current icon theme. More... | |
std::vector< Glib::ustring > | list_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 () |
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< IconTheme > | create () |
static Glib::RefPtr< IconTheme > | get_default () |
Gets the icon theme for the default screen. More... | |
static Glib::RefPtr< IconTheme > | get_for_screen (const Glib::RefPtr< Gdk::Screen > & screen) |
Gets the icon theme object associated with screen; if this function has not previously been called for the given screen, a new icon theme object will be created and associated with the screen. More... | |
static void | add_builtin_icon (const Glib::ustring & icon_name, int size, const Glib::RefPtr< Gdk::Pixbuf > & pixbuf) |
Registers a built-in icon for icon theme lookups. More... | |
Protected Member Functions | |
IconTheme () | |
virtual void | on_changed () |
This is a default handler for the signal signal_changed(). More... | |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gtk::IconTheme > | wrap (GtkIconTheme * object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
|
noexcept |
|
overridenoexcept |
|
protected |
|
static |
Registers a built-in icon for icon theme lookups.
The idea of built-in icons is to allow an application or library that uses themed icons to function requiring files to be present in the file system. For instance, the default images for all of GTK+’s stock icons are registered as built-icons.
In general, if you use add_builtin_icon() you should also install the icon in the icon theme, so that the icon is generally available.
This function will generally be used with pixbufs loaded via gdk_pixbuf_new_from_inline().
Deprecated: 3.14: Use add_resource_path() to add application-specific icons to the icon theme.
icon_name | The name of the icon to register. |
size | The size in pixels at which to register the icon (different images can be registered for the same icon name at different sizes.). |
pixbuf | Gdk::Pixbuf that contains the image to use for icon_name. |
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.
path | A resource path. |
void Gtk::IconTheme::append_search_path | ( | const Glib::ustring & | path | ) |
Appends a directory to the search path.
See set_search_path().
path | Directory name to append to the icon path. |
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.
icon_names | Array of icon names to lookup. |
size | Desired icon size. |
flags | Flags modifying the behavior of the icon lookup. |
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.
icon_names | nullptr -terminated array of icon names to lookup. |
size | Desired icon size. |
scale | Desired scale. |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon wasn’t found.
|
static |
|
static |
Gets the icon theme for the default screen.
See get_for_screen().
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.)
|
static |
Gets the icon theme object associated with screen; if this function has not previously been called for the given screen, a new icon theme object will be created and associated with the screen.
Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than new() and setting the screen yourself; by using this function a single icon theme object will be shared between users.
screen | A Gdk::Screen. |
std::vector< int > Gtk::IconTheme::get_icon_sizes | ( | const Glib::ustring & | icon_name | ) | const |
std::vector< Glib::ustring > Gtk::IconTheme::get_search_path | ( | ) | const |
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
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.
bool Gtk::IconTheme::has_icon | ( | const Glib::ustring & | icon_name | ) | const |
Checks whether an icon theme includes an icon for a particular name.
icon_name | The name of an icon. |
true
if icon_theme includes an icon for icon_name. std::vector< Glib::ustring > Gtk::IconTheme::list_contexts | ( | ) | const |
Gets the list of contexts available within the current hierarchy of icon themes.
std::vector< Glib::ustring > Gtk::IconTheme::list_icons | ( | ) | const |
Lists the icons in the current icon theme.
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'.
context | A string identifying a particular type of icon. |
Glib::RefPtr< 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.
icon_name | The name of the icon to lookup. |
size | The desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon(). |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon isn’t found.Glib::Error |
Glib::RefPtr< 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.
icon_name | The name of the icon to lookup. |
size | The desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon(). |
scale | Desired scale. |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon isn’t found.Glib::Error |
::Cairo::RefPtr< ::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 |
||
) |
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.
icon_name | The name of the icon to lookup. |
size | The desired icon size. The resulting icon may not be exactly this size; see Gtk::IconInfo::load_icon(). |
scale | Desired scale. |
for_window | Gdk::Window to optimize drawing for, or nullptr . |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon isn’t found.Glib::Error |
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.
icon | The Gio::Icon to look up. |
size | Desired icon size. |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon wasn’t found. Unref with Glib::object_unref(). 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().
icon | The Gio::Icon to look up. |
size | Desired icon size. |
scale | The desired scale. |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon wasn’t found. Unref with Glib::object_unref(). 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.)
icon_name | The name of the icon to lookup. |
size | Desired icon size. |
flags | Flags modifying the behavior of the icon lookup. |
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.)
icon_name | The name of the icon to lookup. |
size | Desired icon size. |
scale | The desired scale. |
flags | Flags modifying the behavior of the icon lookup. |
nullptr
if the icon wasn’t found.
|
protectedvirtual |
This is a default handler for the signal signal_changed().
void Gtk::IconTheme::prepend_search_path | ( | const Glib::ustring & | path | ) |
Prepends a directory to the search path.
See set_search_path().
path | Directory name to prepend to the icon path. |
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.
true
if the icon theme has changed and needed to be reloaded. 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_screen().
theme_name | Name of icon theme to use instead of configured theme, or nullptr to unset a previously set custom theme. |
void Gtk::IconTheme::set_screen | ( | const Glib::RefPtr< Gdk::Screen > & | screen | ) |
Sets the screen for an icon theme; the screen is used to track the user’s currently configured icon theme, which might be different for different screens.
screen | A Gdk::Screen. |
void Gtk::IconTheme::set_search_path | ( | const std::vector< Glib::ustring > & | path | ) |
Glib::SignalProxy< void > Gtk::IconTheme::signal_changed | ( | ) |
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.
|
related |
A Glib::wrap() method for this object.
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. |