gi-gtk-4.0.2: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.IconTheme

Description

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 Image rather than directly, but looking up icons directly is also simple. The IconTheme object acts as a database of all the icons in the current theme. You can create new IconTheme objects, but it’s much more efficient to use the standard icon theme of the Widget so that the icon information is shared with other people looking up icons.

C code

GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;

icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
                                   "my-icon-name", // icon name
                                   48, // icon size
                                   1,  // scale
                                   0,  // flags);
 paintable = GDK_PAINTABLE (icon);
 // Use the paintable
 g_object_unref (icon);
Synopsis

Exported types

newtype IconTheme Source #

Memory-managed wrapper type.

Instances

Instances details
Eq IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

IsGValue IconTheme Source #

Convert IconTheme to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.IconTheme

ManagedPtrNewtype IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

TypedObject IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

Methods

glibType :: IO GType #

GObject IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

HasParentTypes IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

type ParentTypes IconTheme Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

type ParentTypes IconTheme = '[Object]

class (GObject o, IsDescendantOf IconTheme o) => IsIconTheme o Source #

Type class for types which can be safely cast to IconTheme, for instance with toIconTheme.

Instances

Instances details
(GObject o, IsDescendantOf IconTheme o) => IsIconTheme o Source # 
Instance details

Defined in GI.Gtk.Objects.IconTheme

toIconTheme :: (MonadIO m, IsIconTheme o) => o -> m IconTheme Source #

Cast to IconTheme, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

addResourcePath

iconThemeAddResourcePath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Text

path: a resource path

-> m () 

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

See iconThemeSetResourcePath.

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

addSearchPath

iconThemeAddSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> [Char]

path: directory name to append to the icon path

-> m () 

Appends a directory to the search path. See iconThemeSetSearchPath.

getForDisplay

iconThemeGetForDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsDisplay a) 
=> a

display: a Display

-> m IconTheme

Returns: A unique 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.

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 iconThemeNew and setting the display yourself; by using this function a single icon theme object will be shared between users.

getIconNames

iconThemeGetIconNames Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> m [Text]

Returns: a string array holding the names of all the icons in the theme. You must free the array using strfreev.

Lists the names of icons in the current icon theme.

getIconSizes

iconThemeGetIconSizes Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Text

iconName: the name of an icon

-> m [Int32]

Returns: A newly allocated array describing the sizes at which the icon is available. The array should be freed with free when it is no longer needed.

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.

getResourcePath

iconThemeGetResourcePath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> m (Maybe [Text])

Returns: A list of resource paths or Nothing. The returned value should be freed with strfreev.

Gets the current resource path.

See iconThemeSetResourcePath.

getSearchPath

iconThemeGetSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> m (Maybe [[Char]])

Returns: a list of icon theme path directories or Nothing. The returned value should be freed with strfreev.

Gets the current search path. See iconThemeSetSearchPath.

getThemeName

iconThemeGetThemeName Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> m Text 

Gets the current icon theme name.

Returns (transfer full): the current icon theme name,

hasIcon

iconThemeHasIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Text

iconName: the name of an icon

-> m Bool

Returns: True if self includes an icon for iconName.

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

lookupByGicon

iconThemeLookupByGicon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) 
=> a

self: a IconTheme

-> b

icon: the Icon to look up

-> Int32

size: desired icon size

-> Int32

scale: the desired scale

-> TextDirection

direction: text direction the icon will be displayed in

-> [IconLookupFlags]

flags: flags modifying the behavior of the icon lookup

-> m IconPaintable

Returns: a IconPaintable containing information about the icon. Unref with objectUnref

Looks up a icon for a desired size and window scale, returning a IconPaintable. The icon can then be rendered by using it as a Paintable, or you can get information such as the filename and size.

lookupIcon

iconThemeLookupIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Text

iconName: the name of the icon to lookup

-> Maybe [Text] 
-> Int32

size: desired icon size.

-> Int32

scale: the window scale this will be displayed on

-> TextDirection

direction: text direction the icon will be displayed in

-> [IconLookupFlags]

flags: flags modifying the behavior of the icon lookup

-> m IconPaintable

Returns: a IconPaintable object containing the icon.

Looks up a named icon for a desired size and window scale, returning a IconPaintable. The icon can then be rendered by using it as a Paintable, or you can get information such as the filename and size.

If the available iconName 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 iconThemeHasIcon.

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the WidgetClass.css-changed() function.

new

iconThemeNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m IconTheme

Returns: the newly created IconTheme object.

Creates a new icon theme object. Icon theme objects are used to lookup up an icon by name in a particular icon theme. Usually, you’ll want to use iconThemeGetForDisplay rather than creating a new icon theme object for scratch.

setResourcePath

iconThemeSetResourcePath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Text

path: NULL-terminated array of resource paths that are searched for icons

-> m () 

Sets the resource paths that will be looked at when looking for icons, similar to search paths.

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.

setSearchPath

iconThemeSetSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Maybe [[Char]]

path: NULL-terminated array of directories that are searched for icon themes

-> m () 

Sets the search path for the icon theme object. When looking for an icon theme, GTK will search for a subdirectory of one or more of the directories in path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)

In addition if an icon found isn’t found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of path, then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)

setThemeName

iconThemeSetThemeName Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) 
=> a

self: a IconTheme

-> Maybe Text

themeName: name of icon theme to use instead of configured theme, or Nothing to unset a previously set custom theme

-> m () 

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

Properties

display

The display that this icon theme object is attached to.

clearIconThemeDisplay :: (MonadIO m, IsIconTheme o) => o -> m () Source #

Set the value of the “display” property to Nothing. When overloading is enabled, this is equivalent to

clear #display

constructIconThemeDisplay :: (IsIconTheme o, MonadIO m, IsDisplay a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “display” property. This is rarely needed directly, but it is used by new.

getIconThemeDisplay :: (MonadIO m, IsIconTheme o) => o -> m (Maybe Display) Source #

Get the value of the “display” property. When overloading is enabled, this is equivalent to

get iconTheme #display

setIconThemeDisplay :: (MonadIO m, IsIconTheme o, IsDisplay a) => o -> a -> m () Source #

Set the value of the “display” property. When overloading is enabled, this is equivalent to

set iconTheme [ #display := value ]

iconNames

The icon names that are supported by the icon theme.

getIconThemeIconNames :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text]) Source #

Get the value of the “icon-names” property. When overloading is enabled, this is equivalent to

get iconTheme #iconNames

resourcePath

Resource paths that will be looked at when looking for icons, similar to search paths.

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.

clearIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> m () Source #

Set the value of the “resource-path” property to Nothing. When overloading is enabled, this is equivalent to

clear #resourcePath

constructIconThemeResourcePath :: (IsIconTheme o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “resource-path” property. This is rarely needed directly, but it is used by new.

getIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text]) Source #

Get the value of the “resource-path” property. When overloading is enabled, this is equivalent to

get iconTheme #resourcePath

setIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> [Text] -> m () Source #

Set the value of the “resource-path” property. When overloading is enabled, this is equivalent to

set iconTheme [ #resourcePath := value ]

searchPath

The search path for this icon theme.

When looking for icons, GTK will search for a subdirectory of one or more of the directories in the search path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)

clearIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> m () Source #

Set the value of the “search-path” property to Nothing. When overloading is enabled, this is equivalent to

clear #searchPath

constructIconThemeSearchPath :: (IsIconTheme o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “search-path” property. This is rarely needed directly, but it is used by new.

getIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text]) Source #

Get the value of the “search-path” property. When overloading is enabled, this is equivalent to

get iconTheme #searchPath

setIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> [Text] -> m () Source #

Set the value of the “search-path” property. When overloading is enabled, this is equivalent to

set iconTheme [ #searchPath := value ]

themeName

The name of the icon theme that is being used.

Unless set to a different value, this will be the value of the Settings:gtk-icon-theme-name property of the Settings object associated to the display of the icontheme object.

clearIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> m () Source #

Set the value of the “theme-name” property to Nothing. When overloading is enabled, this is equivalent to

clear #themeName

constructIconThemeThemeName :: (IsIconTheme o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “theme-name” property. This is rarely needed directly, but it is used by new.

getIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> m (Maybe Text) Source #

Get the value of the “theme-name” property. When overloading is enabled, this is equivalent to

get iconTheme #themeName

setIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> Text -> m () Source #

Set the value of the “theme-name” property. When overloading is enabled, this is equivalent to

set iconTheme [ #themeName := value ]

Signals

changed

type C_IconThemeChangedCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type IconThemeChangedCallback = IO () Source #

Emitted when the current icon theme is switched or GTK+ detects that a change has occurred in the contents of the current icon theme.

afterIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> IconThemeChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after iconTheme #changed callback

onIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> IconThemeChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on iconTheme #changed callback