gtkmm
3.97.1
|
Looking up icons by name. More...
#include <gtkmm/icontheme.h>
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_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::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 |
Returns an array of integers describing the sizes at which the icon is available without scaling. More... | |
Glib::RefPtr< IconPaintable > | lookup_icon (const Glib::ustring& icon_name, const std::vector< Glib::ustring >& fallbacks, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) |
Looks up a named icon for a desired size and window scale, returning a Gtk::Icon. More... | |
Glib::RefPtr< IconPaintable > | lookup_icon (const Glib::ustring& icon_name, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) |
A lookup_icon() convenience overload. More... | |
Glib::RefPtr< const IconPaintable > | lookup_icon (const Glib::ustring& icon_name, const std::vector< Glib::ustring >& fallbacks, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) const |
Looks up a named icon for a desired size and window scale, returning a Gtk::Icon. More... | |
Glib::RefPtr< const IconPaintable > | lookup_icon (const Glib::ustring& icon_name, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) const |
A lookup_icon() convenience overload. More... | |
Glib::RefPtr< IconPaintable > | lookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) |
Looks up a icon for a desired size and window scale, returning a Gtk::Icon. More... | |
Glib::RefPtr< const IconPaintable > | lookup_icon (const Glib::RefPtr< const Gio::Icon >& icon, int size, int scale=1, TextDirection direction=TextDirection::NONE, IconLookupFlags flags=(IconLookupFlags) 0) const |
Looks up a icon for a desired size and window scale, returning a Gtk::Icon. More... | |
std::vector< Glib::ustring > | list_icons () const |
Lists the icons in the current icon theme. More... | |
Glib::SignalProxy< void()> | signal_changed () |
![]() | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (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::Object > | wrap (GObject *object, bool take_copy=false) |
![]() | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (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 |
![]() | |
trackable () noexcept | |
trackable (const trackable &src) noexcept | |
trackable (trackable &&src) noexcept | |
~trackable () | |
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const |
void | notify_callbacks () |
trackable & | operator= (const trackable &src) |
trackable & | operator= (trackable &&src) noexcept |
void | remove_destroy_notify_callback (notifiable *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< IconTheme > | create () |
static Glib::RefPtr< IconTheme > | get_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 () | |
![]() | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
![]() | |
ObjectBase () | |
ObjectBase (const char *custom_type_name) | |
ObjectBase (const std::type_info &custom_type_info) | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (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::IconTheme > | wrap (GtkIconTheme* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Additional Inherited Members | |
![]() | |
typedef void(*)(gpointer data | DestroyNotify) |
![]() | |
typedef internal::func_destroy_notify | func_destroy_notify |
![]() | |
typedef internal::func_destroy_notify | func_destroy_notify |
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 IconPaintable 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_for_display().
|
noexcept |
|
overridenoexcept |
|
protected |
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. |
|
static |
|
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.
display | A Gdk::Display. |
std::vector<int> Gtk::IconTheme::get_icon_sizes | ( | const Glib::ustring & | icon_name | ) | const |
Returns an array of integers describing the sizes at which the icon is available without scaling.
A size of -1 means that the icon is available in a scalable format. The array is zero-terminated.
icon_name | The name of an icon. |
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 self includes an icon for icon_name. std::vector<Glib::ustring> Gtk::IconTheme::list_icons | ( | ) | const |
Lists the icons in the current icon theme.
Glib::RefPtr<IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::ustring & | icon_name, |
const std::vector< Glib::ustring > & | fallbacks, | ||
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) |
Looks up a named icon for a desired size and window scale, returning a Gtk::Icon.
The icon can then be rendered by using it as a Gdk::Paintable, or you can get information such as the filename and size.
If the available icon_name is not available and fallbacks are provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the "missing icon" icon is returned. If you need to do something else for missing icons you need to use has_icon().
Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the Gtk::Widget::property_css_changed() function.
icon_name | The name of the icon to lookup. |
size | Desired icon size. |
scale | The window scale this will be displayed on. |
direction | Text direction the icon will be displayed in. |
flags | Flags modifying the behavior of the icon lookup. |
Glib::RefPtr<IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::ustring & | icon_name, |
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) |
A lookup_icon() convenience overload.
Glib::RefPtr<const IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::ustring & | icon_name, |
const std::vector< Glib::ustring > & | fallbacks, | ||
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) | const |
Looks up a named icon for a desired size and window scale, returning a Gtk::Icon.
The icon can then be rendered by using it as a Gdk::Paintable, or you can get information such as the filename and size.
If the available icon_name is not available and fallbacks are provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the "missing icon" icon is returned. If you need to do something else for missing icons you need to use has_icon().
Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the Gtk::Widget::property_css_changed() function.
icon_name | The name of the icon to lookup. |
size | Desired icon size. |
scale | The window scale this will be displayed on. |
direction | Text direction the icon will be displayed in. |
flags | Flags modifying the behavior of the icon lookup. |
Glib::RefPtr<const IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::ustring & | icon_name, |
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) | const |
A lookup_icon() convenience overload.
Glib::RefPtr<IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::RefPtr< const Gio::Icon > & | icon, |
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) |
Looks up a icon for a desired size and window scale, returning a Gtk::Icon.
The icon can then be rendered by using it as a Gdk::Paintable, or you can get information such as the filename and size.
icon | The Gio::Icon to look up. |
size | Desired icon size. |
scale | The desired scale. |
direction | Text direction the icon will be displayed in. |
flags | Flags modifying the behavior of the icon lookup. |
Glib::RefPtr<const IconPaintable> Gtk::IconTheme::lookup_icon | ( | const Glib::RefPtr< const Gio::Icon > & | icon, |
int | size, | ||
int | scale = 1 , |
||
TextDirection | direction = TextDirection::NONE , |
||
IconLookupFlags | flags = (IconLookupFlags) 0 |
||
) | const |
Looks up a icon for a desired size and window scale, returning a Gtk::Icon.
The icon can then be rendered by using it as a Gdk::Paintable, or you can get information such as the filename and size.
icon | The Gio::Icon to look up. |
size | Desired icon size. |
scale | The desired scale. |
direction | Text direction the icon will be displayed in. |
flags | Flags modifying the behavior of the icon lookup. |
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. |
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_for_display().
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_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.
display | A Gdk::Display. |
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. |