[−][src]Trait gtk::IconThemeExt
Required methods
fn add_resource_path(&self, path: &str)
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 @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
fn append_search_path<P: AsRef<Path>>(&self, path: P)
Appends a directory to the search path.
See IconTheme::set_search_path
.
path
directory name to append to the icon path
fn get_example_icon_name(&self) -> Option<GString>
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.)
Returns
the name of an example icon or None
.
Free with g_free
.
fn has_icon(&self, icon_name: &str) -> bool
Checks whether an icon theme includes an icon for a particular name.
icon_name
the name of an icon
Returns
true
if self
includes an
icon for icon_name
.
fn list_contexts(&self) -> Vec<GString>
Gets the list of contexts available within the current
hierarchy of icon themes.
See IconThemeExt::list_icons
for details about contexts.
Returns
a glib::List
list
holding the names of all the contexts in the theme. You must first
free each element in the list with g_free
, then free the list
itself with glib::List::free
.
fn list_icons(&self, context: Option<&str>) -> Vec<GString>
Lists the icons in the current icon theme. Only a subset
of the icons can be listed 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”. Contexts are explained in the
Icon Theme Specification.
The standard contexts are listed in the
Icon Naming Specification.
Also see IconThemeExt::list_contexts
.
context
a string identifying a particular type of
icon, or None
to list all icons.
Returns
a glib::List
list
holding the names of all the icons in the theme. You must
first free each element in the list with g_free
, then
free the list itself with glib::List::free
.
fn load_icon(
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
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
IconThemeExt::lookup_icon
followed by 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
Widget
::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::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 IconInfo::load_icon
.
flags
flags 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 gobject::ObjectExt::unref
to release
your reference to the icon. None
if the icon isn’t found.
fn load_icon_for_scale(
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
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 IconThemeExt::lookup_icon
followed by
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
Widget
::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::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 IconInfo::load_icon
.
scale
desired scale
flags
flags 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 gobject::ObjectExt::unref
to release
your reference to the icon. None
if the icon isn’t found.
fn load_surface<P: IsA<Window>>(
&self,
icon_name: &str,
size: i32,
scale: i32,
for_window: Option<&P>,
flags: IconLookupFlags
) -> Result<Option<Surface>, Error>
&self,
icon_name: &str,
size: i32,
scale: i32,
for_window: Option<&P>,
flags: IconLookupFlags
) -> Result<Option<Surface>, Error>
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 IconThemeExt::lookup_icon
followed by
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
Widget
::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 IconInfo::load_icon
.
scale
desired scale
for_window
gdk::Window
to optimize drawing for, or None
flags
flags 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. None
if the icon isn’t
found.
fn lookup_by_gicon<P: IsA<Icon>>(
&self,
icon: &P,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
&self,
icon: &P,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
Looks up an icon and returns a IconInfo
containing information
such as the filename of the icon. The icon can then be rendered
into a pixbuf using 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::WindowExt::get_scale_factor
. Instead, you should use
IconThemeExt::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
Returns
a IconInfo
containing
information about the icon, or None
if the icon wasn’t
found. Unref with gobject::ObjectExt::unref
fn lookup_by_gicon_for_scale<P: IsA<Icon>>(
&self,
icon: &P,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
&self,
icon: &P,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
Looks up an icon and returns a IconInfo
containing information
such as the filename of the icon. The icon can then be rendered into
a pixbuf using 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
Returns
a IconInfo
containing
information about the icon, or None
if the icon wasn’t
found. Unref with gobject::ObjectExt::unref
fn lookup_icon(
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
Looks up a named icon and returns a IconInfo
containing
information such as the filename of the icon. The icon
can then be rendered into a pixbuf using
IconInfo::load_icon
. (IconThemeExt::load_icon
combines these two steps if all you need is the pixbuf.)
When rendering on displays with high pixel densities you should not
use a size
multiplied by the scaling factor returned by functions
like gdk::WindowExt::get_scale_factor
. Instead, you should use
IconThemeExt::lookup_icon_for_scale
, as the assets loaded
for a given scaling factor may be different.
icon_name
the name of the icon to lookup
size
desired icon size
flags
flags modifying the behavior of the icon lookup
Returns
a IconInfo
object
containing information about the icon, or None
if the
icon wasn’t found.
fn lookup_icon_for_scale(
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
Looks up a named icon for a particular window scale and returns a
IconInfo
containing information such as the filename of the
icon. The icon can then be rendered into a pixbuf using
IconInfo::load_icon
. (IconThemeExt::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
Returns
a IconInfo
object
containing information about the icon, or None
if the
icon wasn’t found.
fn prepend_search_path<P: AsRef<Path>>(&self, path: P)
Prepends a directory to the search path.
See IconTheme::set_search_path
.
path
directory name to prepend to the icon path
fn rescan_if_needed(&self) -> bool
Checks to see if the icon theme has changed; if it has, any
currently cached information is discarded and will be reloaded
next time self
is accessed.
Returns
true
if the icon theme has changed and needed
to be reloaded.
fn set_custom_theme(&self, theme_name: Option<&str>)
Sets the name of the icon theme that the IconTheme
object uses
overriding system configuration. This function cannot be called
on the icon theme objects returned from IconTheme::get_default
and IconTheme::get_for_screen
.
theme_name
name of icon theme to use instead of
configured theme, or None
to unset a previously set custom theme
fn set_screen(&self, 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
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.
Implementors
impl<O: IsA<IconTheme>> IconThemeExt for O
[src]
fn add_resource_path(&self, path: &str)
[src]
fn append_search_path<P: AsRef<Path>>(&self, path: P)
[src]
fn get_example_icon_name(&self) -> Option<GString>
[src]
fn has_icon(&self, icon_name: &str) -> bool
[src]
fn list_contexts(&self) -> Vec<GString>
[src]
fn list_icons(&self, context: Option<&str>) -> Vec<GString>
[src]
fn load_icon(
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
[src]
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
fn load_icon_for_scale(
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
[src]
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Result<Option<Pixbuf>, Error>
fn load_surface<P: IsA<Window>>(
&self,
icon_name: &str,
size: i32,
scale: i32,
for_window: Option<&P>,
flags: IconLookupFlags
) -> Result<Option<Surface>, Error>
[src]
&self,
icon_name: &str,
size: i32,
scale: i32,
for_window: Option<&P>,
flags: IconLookupFlags
) -> Result<Option<Surface>, Error>
fn lookup_by_gicon<P: IsA<Icon>>(
&self,
icon: &P,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
[src]
&self,
icon: &P,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
fn lookup_by_gicon_for_scale<P: IsA<Icon>>(
&self,
icon: &P,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
[src]
&self,
icon: &P,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
fn lookup_icon(
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
[src]
&self,
icon_name: &str,
size: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
fn lookup_icon_for_scale(
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>
[src]
&self,
icon_name: &str,
size: i32,
scale: i32,
flags: IconLookupFlags
) -> Option<IconInfo>