Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GtkIconTheme
provides a facility for loading themed icons.
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
GtkIconTheme
object acts as a database of all the icons in the current
theme. You can create new GtkIconTheme
objects, but it’s much more
efficient to use the standard icon theme of the GtkWidget
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
- newtype IconTheme = IconTheme (ManagedPtr IconTheme)
- class (GObject o, IsDescendantOf IconTheme o) => IsIconTheme o
- toIconTheme :: (MonadIO m, IsIconTheme o) => o -> m IconTheme
- iconThemeAddResourcePath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Text -> m ()
- iconThemeAddSearchPath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> [Char] -> m ()
- iconThemeGetDisplay :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> m (Maybe Display)
- iconThemeGetForDisplay :: (HasCallStack, MonadIO m, IsDisplay a) => a -> m IconTheme
- iconThemeGetIconNames :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> m [Text]
- iconThemeGetIconSizes :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Text -> m [Int32]
- iconThemeGetResourcePath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> m (Maybe [Text])
- iconThemeGetSearchPath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> m (Maybe [[Char]])
- iconThemeGetThemeName :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> m Text
- iconThemeHasGicon :: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) => a -> b -> m Bool
- iconThemeHasIcon :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Text -> m Bool
- iconThemeLookupByGicon :: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) => a -> b -> Int32 -> Int32 -> TextDirection -> [IconLookupFlags] -> m IconPaintable
- iconThemeLookupIcon :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Text -> Maybe [Text] -> Int32 -> Int32 -> TextDirection -> [IconLookupFlags] -> m IconPaintable
- iconThemeNew :: (HasCallStack, MonadIO m) => m IconTheme
- iconThemeSetResourcePath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Maybe [Text] -> m ()
- iconThemeSetSearchPath :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Maybe [[Char]] -> m ()
- iconThemeSetThemeName :: (HasCallStack, MonadIO m, IsIconTheme a) => a -> Maybe Text -> m ()
- clearIconThemeDisplay :: (MonadIO m, IsIconTheme o) => o -> m ()
- constructIconThemeDisplay :: (IsIconTheme o, MonadIO m, IsDisplay a) => a -> m (GValueConstruct o)
- getIconThemeDisplay :: (MonadIO m, IsIconTheme o) => o -> m (Maybe Display)
- setIconThemeDisplay :: (MonadIO m, IsIconTheme o, IsDisplay a) => o -> a -> m ()
- getIconThemeIconNames :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text])
- clearIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> m ()
- constructIconThemeResourcePath :: (IsIconTheme o, MonadIO m) => [Text] -> m (GValueConstruct o)
- getIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text])
- setIconThemeResourcePath :: (MonadIO m, IsIconTheme o) => o -> [Text] -> m ()
- clearIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> m ()
- constructIconThemeSearchPath :: (IsIconTheme o, MonadIO m) => [Text] -> m (GValueConstruct o)
- getIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> m (Maybe [Text])
- setIconThemeSearchPath :: (MonadIO m, IsIconTheme o) => o -> [Text] -> m ()
- clearIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> m ()
- constructIconThemeThemeName :: (IsIconTheme o, MonadIO m) => Text -> m (GValueConstruct o)
- getIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> m (Maybe Text)
- setIconThemeThemeName :: (MonadIO m, IsIconTheme o) => o -> Text -> m ()
- type IconThemeChangedCallback = IO ()
- afterIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> ((?self :: a) => IconThemeChangedCallback) -> m SignalHandlerId
- onIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> ((?self :: a) => IconThemeChangedCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq IconTheme Source # | |
GObject IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
ManagedPtrNewtype IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
TypedObject IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
HasParentTypes IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
IsGValue (Maybe IconTheme) Source # | Convert |
Defined in GI.Gtk.Objects.IconTheme | |
type ParentTypes IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme |
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
(GObject o, IsDescendantOf IconTheme o) => IsIconTheme o Source # | |
Defined in GI.Gtk.Objects.IconTheme |
toIconTheme :: (MonadIO m, IsIconTheme o) => o -> m IconTheme Source #
Methods
Click to display all available methods, including inherited ones
Methods
addResourcePath, addSearchPath, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, hasGicon, hasIcon, isFloating, lookupByGicon, lookupIcon, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getDisplay, getIconNames, getIconSizes, getProperty, getQdata, getResourcePath, getSearchPath, getThemeName.
Setters
setData, setDataFull, setProperty, setResourcePath, setSearchPath, setThemeName.
addResourcePath
iconThemeAddResourcePath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Text |
|
-> m () |
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.
addSearchPath
iconThemeAddSearchPath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> [Char] |
|
-> m () |
Appends a directory to the search path.
getDisplay
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> m (Maybe Display) | Returns: the display of |
Returns the display that the GtkIconTheme
object was
created for.
getForDisplay
iconThemeGetForDisplay Source #
:: (HasCallStack, MonadIO m, IsDisplay a) | |
=> a |
|
-> m IconTheme | Returns: A unique |
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
iconThemeNew
and setting the display yourself; by using
this function a single icon theme object will be shared between users.
getIconNames
iconThemeGetIconNames Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> m [Text] | Returns: a string array
holding the names of all the icons in the theme. You must
free the array using |
Lists the names of icons in the current icon theme.
getIconSizes
iconThemeGetIconSizes Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Text |
|
-> m [Int32] | Returns: A newly
allocated array describing the sizes at which the icon is
available. The array should be freed with |
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 #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> m (Maybe [Text]) | Returns: A list of resource paths |
Gets the current resource path.
getSearchPath
iconThemeGetSearchPath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> m (Maybe [[Char]]) | Returns: a list of icon theme path directories |
Gets the current search path.
getThemeName
iconThemeGetThemeName Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> m Text |
Gets the current icon theme name.
Returns (transfer full): the current icon theme name,
hasGicon
:: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
Checks whether an icon theme includes an icon
for a particular GIcon
.
Since: 4.2
hasIcon
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: |
Checks whether an icon theme includes an icon for a particular name.
lookupByGicon
iconThemeLookupByGicon Source #
:: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) | |
=> a |
|
-> b |
|
-> Int32 |
|
-> Int32 |
|
-> TextDirection |
|
-> [IconLookupFlags] |
|
-> m IconPaintable | Returns: a |
Looks up a icon for a desired size and window scale.
The icon can then be rendered by using it as a GdkPaintable
,
or you can get information such as the filename and size.
lookupIcon
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Text |
|
-> Maybe [Text] | |
-> Int32 |
|
-> Int32 |
|
-> TextDirection |
|
-> [IconLookupFlags] |
|
-> m IconPaintable | Returns: a |
Looks up a named icon for a desired size and window scale,
returning a GtkIconPaintable
.
The icon can then be rendered by using it as a GdkPaintable
,
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
GtkWidgetClass.css-changed()
function.
new
:: (HasCallStack, MonadIO m) | |
=> m IconTheme | Returns: the newly created |
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
[funcgtk
.IconTheme.get_for_display] rather than creating
a new icon theme object for scratch.
setResourcePath
iconThemeSetResourcePath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Maybe [Text] |
|
-> 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
or @path/scalable/actions/run.svg
.
Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback, but they are treated like unthemed icons.
setSearchPath
iconThemeSetSearchPath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Maybe [[Char]] |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets the name of the icon theme that the GtkIconTheme
object uses
overriding system configuration.
This function cannot be called on the icon theme objects returned
from [funcgtk
.IconTheme.get_for_display].
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 GtkSettings:gtk-icon-theme-name
property of the GtkSettings
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 IconThemeChangedCallback = IO () Source #
Emitted when the icon theme changes.
This can happen becuase current icon theme is switched or because GTK detects that a change has occurred in the contents of the current icon theme.
afterIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> ((?self :: 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