gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.IconTheme

Contents

- Exported types
- Methods
  - addResourcePath
  - addSearchPath
  - getDisplay
  - getForDisplay
  - getIconNames
  - getIconSizes
  - getResourcePath
  - getSearchPath
  - getThemeName
  - hasGicon
  - hasIcon
  - lookupByGicon
  - lookupIcon
  - new
  - setResourcePath
  - setSearchPath
  - setThemeName
- Properties
  - display
  - iconNames
  - resourcePath
  - searchPath
  - themeName
- Signals
  - changed

Description

Loads 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

newtype IconTheme Source #

Memory-managed wrapper type.

Constructors

IconTheme (ManagedPtr IconTheme) |

#### Instances

Instances details

Eq IconTheme Source # |
Instance details Defined in GI.Gtk.Objects.IconTheme Methods (==) :: IconTheme -> IconTheme -> Bool Source # (/=) :: IconTheme -> IconTheme -> Bool Source #
GObject IconTheme Source # |
Instance details Defined in GI.Gtk.Objects.IconTheme
ManagedPtrNewtype IconTheme Source # |
Instance details Defined in GI.Gtk.Objects.IconTheme Methods toManagedPtr :: IconTheme -> ManagedPtr IconTheme Source #
TypedObject IconTheme Source # |
Instance details Defined in GI.Gtk.Objects.IconTheme Methods glibType :: IO GType Source #
HasParentTypes IconTheme Source # |
Instance details Defined in GI.Gtk.Objects.IconTheme
IsGValue (Maybe IconTheme) Source # | Convert `IconTheme` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.IconTheme Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe IconTheme -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe IconTheme) Source #
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

### Click to display all available methods, including inherited ones

Expand

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

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> 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 `GtkIconTheme`
-> [Char] | `path`: directory name to append to the icon path
-> m () |

Appends a directory to the search path.

See `iconThemeSetSearchPath`.

## getDisplay

iconThemeGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> m (Maybe Display) | Returns: the display of `iconTheme`

Returns the display that the `GtkIconTheme` object was created for.

## getForDisplay

iconThemeGetForDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsDisplay a) |
=> a | `display`: a `GdkDisplay`
-> m IconTheme | Returns: A unique `GtkIconTheme` 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 `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 `GtkIconTheme`
-> 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 `GtkIconTheme`
-> 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 `GtkIconTheme`
-> m (Maybe [Text]) | Returns: A list of resource paths

Gets the current resource path.

See `iconThemeSetResourcePath`.

## getSearchPath

iconThemeGetSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> m (Maybe [[Char]]) | Returns: a list of icon theme path directories

Gets the current search path.

See `iconThemeSetSearchPath`.

## getThemeName

iconThemeGetThemeName Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> m Text | Returns: the current icon theme name,

Gets the current icon theme name.

## hasGicon

iconThemeHasGicon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a, IsIcon b) |
=> a | `self`: a `GtkIconTheme`
-> b | `gicon`: a `GIcon`
-> m Bool | Returns: `True` if `self` includes an icon for `gicon`

Checks whether an icon theme includes an icon for a particular `GIcon`.

Since: 4.2

## hasIcon

iconThemeHasIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> 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 `GtkIconTheme`
-> b | `icon`: the `GIcon` to look up
-> Int32 | `size`: desired icon size, in application pixels
-> 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 `GtkIconPaintable` containing information about the icon. Unref with `objectUnref`

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

iconThemeLookupIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> Text | `iconName`: the name of the icon to lookup
-> Maybe [Text] | `fallbacks`: fallback names
-> Int32 | `size`: desired icon size, in application pixels
-> 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 `GtkIconPaintable` object containing the icon.

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

iconThemeNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m IconTheme | Returns: the newly created `GtkIconTheme` 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 `GtkIconTheme`
-> Maybe [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` 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 #

Arguments

:: (HasCallStack, MonadIO m, IsIconTheme a) |
=> a | `self`: a `GtkIconTheme`
-> 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 `GtkIconTheme`
-> 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 `GtkIconTheme` 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 `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 because 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