Trait gtk::prelude::IconThemeExt[][src]

pub trait IconThemeExt: 'static {
Show methods fn add_resource_path(&self, path: &str);
fn append_search_path<P: AsRef<Path>>(&self, path: P);
fn example_icon_name(&self) -> Option<GString>;
fn has_icon(&self, icon_name: &str) -> bool;
fn list_contexts(&self) -> Vec<GString>;
fn list_icons(&self, context: Option<&str>) -> Vec<GString>;
fn load_icon(
        &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>;
fn load_surface(
        &self,
        icon_name: &str,
        size: i32,
        scale: i32,
        for_window: Option<&Window>,
        flags: IconLookupFlags
    ) -> Result<Option<Surface>, Error>;
fn lookup_by_gicon<P: IsA<Icon>>(
        &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>;
fn lookup_icon(
        &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>;
fn prepend_search_path<P: AsRef<Path>>(&self, path: P);
fn rescan_if_needed(&self) -> bool;
fn set_custom_theme(&self, theme_name: Option<&str>);
fn set_screen(&self, screen: &Screen);
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
Expand description

Trait containing all IconTheme methods.

Implementors

IconTheme

Required methods

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

Appends a directory to the search path. See gtk_icon_theme_set_search_path().

path

directory name to append to the icon path

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

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.

Gets the list of contexts available within the current hierarchy of icon themes. See list_icons() for details about contexts.

Returns

a GList 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 g_list_free().

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 list_contexts().

context

a string identifying a particular type of icon, or None to list all icons.

Returns

a GList 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 g_list_free().

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 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 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 g_object_unref() to release your reference to the icon. None if the icon isn’t found.

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 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 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 g_object_unref() to release your reference to the icon. None if the icon isn’t found.

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

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 Window::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

Returns

a IconInfo containing information about the icon, or None if the icon wasn’t found. Unref with g_object_unref()

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 g_object_unref()

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(). (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 Window::scale_factor(). Instead, you should use 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.

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

Prepends a directory to the search path. See gtk_icon_theme_set_search_path().

path

directory name to prepend to the icon path

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.

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::default() and IconTheme::for_screen().

theme_name

name of icon theme to use instead of configured theme, or None to unset a previously set custom theme

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

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