Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
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
- 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 ()
- 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
- 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 -> 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 C_IconThemeChangedCallback = Ptr () -> Ptr () -> IO ()
- type IconThemeChangedCallback = IO ()
- afterIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> IconThemeChangedCallback -> m SignalHandlerId
- genClosure_IconThemeChanged :: MonadIO m => IconThemeChangedCallback -> m (GClosure C_IconThemeChangedCallback)
- mk_IconThemeChangedCallback :: C_IconThemeChangedCallback -> IO (FunPtr C_IconThemeChangedCallback)
- noIconThemeChangedCallback :: Maybe IconThemeChangedCallback
- onIconThemeChanged :: (IsIconTheme a, MonadIO m) => a -> IconThemeChangedCallback -> m SignalHandlerId
- wrap_IconThemeChangedCallback :: IconThemeChangedCallback -> C_IconThemeChangedCallback
Exported types
Memory-managed wrapper type.
Instances
Eq IconTheme Source # | |
IsGValue IconTheme Source # | Convert |
ManagedPtrNewtype IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
TypedObject IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
GObject IconTheme Source # | |
Defined in GI.Gtk.Objects.IconTheme | |
HasParentTypes IconTheme Source # | |
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
Overloaded methods
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.
See iconThemeSetSearchPath
.
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 than 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 or |
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 or |
Gets the current search path. See iconThemeSetSearchPath
.
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,
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, 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
:: (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
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
:: (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 iconThemeGetForDisplay
rather than creating a new icon theme object for scratch.
setResourcePath
iconThemeSetResourcePath Source #
:: (HasCallStack, MonadIO m, IsIconTheme a) | |
=> a |
|
-> 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
.
Icons that are directly placed in the resource path instead
of a subdirectory are also considered as ultimate fallback.
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 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
genClosure_IconThemeChanged :: MonadIO m => IconThemeChangedCallback -> m (GClosure C_IconThemeChangedCallback) Source #
Wrap the callback into a GClosure
.
mk_IconThemeChangedCallback :: C_IconThemeChangedCallback -> IO (FunPtr C_IconThemeChangedCallback) Source #
Generate a function pointer callable from C code, from a C_IconThemeChangedCallback
.
noIconThemeChangedCallback :: Maybe IconThemeChangedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
IconThemeChangedCallback
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