gtk-0.12.2: Binding to the Gtk+ graphical user interface library.

Portability | portable (depends on GHC)
Stability | provisional
Maintainer | gtk2hs-users@lists.sourceforge.net

Graphics.UI.Gtk.General.IconTheme

Contents

- Detail
- Class Hierarchy
- Types
- Enums
- Constructors
- Methods
- Signals

Description

Looking up icons by name

- Module available since Gtk+ version 2.4

Synopsis

- data IconTheme
- class GObjectClass o => IconThemeClass o
- castToIconTheme :: GObjectClass obj => obj -> IconTheme
- toIconTheme :: IconThemeClass o => o -> IconTheme
- data IconInfo
- data IconLookupFlags
  - = IconLookupNoSvg
  - | IconLookupForceSvg
  - | IconLookupUseBuiltin
  - | IconLookupGenericFallback
  - | IconLookupForceSize
- data IconThemeError
  - = IconThemeNotFound
  - | IconThemeFailed
- iconThemeNew :: IO IconTheme
- iconInfoNewForPixbuf :: IconThemeClass iconTheme => iconTheme -> Pixbuf -> IO IconInfo
- iconThemeGetDefault :: IO IconTheme
- iconThemeGetForScreen :: Screen -> IO IconTheme
- iconThemeSetScreen :: IconThemeClass self => self -> Screen -> IO ()
- iconThemeSetSearchPath :: IconThemeClass self => self -> [FilePath] -> Int -> IO ()
- iconThemeGetSearchPath :: IconThemeClass self => self -> IO ([FilePath], Int)
- iconThemeAppendSearchPath :: IconThemeClass self => self -> FilePath -> IO ()
- iconThemePrependSearchPath :: IconThemeClass self => self -> FilePath -> IO ()
- iconThemeSetCustomTheme :: IconThemeClass self => self -> Maybe String -> IO ()
- iconThemeHasIcon :: IconThemeClass self => self -> String -> IO Bool
- iconThemeLookupIcon :: IconThemeClass self => self -> String -> Int -> IconLookupFlags -> IO (Maybe IconInfo)
- iconThemeChooseIcon :: IconThemeClass self => self -> [String] -> Int -> IconLookupFlags -> IO (Maybe IconInfo)
- iconThemeLoadIcon :: IconThemeClass self => self -> String -> Int -> IconLookupFlags -> IO (Maybe Pixbuf)
- iconThemeListContexts :: IconThemeClass self => self -> IO [String]
- iconThemeListIcons :: IconThemeClass self => self -> Maybe String -> IO [String]
- iconThemeGetIconSizes :: IconThemeClass self => self -> String -> IO [Int]
- iconThemeGetExampleIconName :: IconThemeClass self => self -> IO (Maybe String)
- iconThemeRescanIfNeeded :: IconThemeClass self => self -> IO Bool
- iconThemeAddBuiltinIcon :: String -> Int -> Pixbuf -> IO ()
- iconThemeErrorQuark :: IO Quark
- iconInfoCopy :: IconInfo -> IO IconInfo
- iconInfoGetAttachPoints :: IconInfo -> IO (Maybe [Point])
- iconInfoGetBaseSize :: IconInfo -> IO Int
- iconInfoGetBuiltinPixbuf :: IconInfo -> IO (Maybe Pixbuf)
- iconInfoGetDisplayName :: IconInfo -> IO (Maybe String)
- iconInfoGetEmbeddedRect :: IconInfo -> IO (Maybe Rectangle)
- iconInfoGetFilename :: IconInfo -> IO (Maybe String)
- iconInfoLoadIcon :: IconInfo -> IO Pixbuf
- iconInfoSetRawCoordinates :: IconInfo -> Bool -> IO ()
- iconThemeChanged :: IconThemeClass self => Signal self (IO ())

# Detail

`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 selecetd by the user. The operation of icon themes on Linux and Unix follows the Icon Theme Specification. There is a default icon theme, named hicolor where applications should install their icons, but more additional application themes can be installed as operating system vendors and users choose.

Named icons are similar to the Themeable Stock Images facility, and the distinction between the two may be a bit confusing. A few things to keep in mind:

- Stock images usually are used in conjunction with Stock Items, such as ''StockOk'' or ''StockOpen''. Named icons are easier to set up and therefore are more useful for new icons that an application wants to add, such as application icons or window icons.
- Stock images can only be loaded at the symbolic sizes defined by the `IconSize` enumeration, or by custom sizes defined by `iconSizeRegister`, while named icons are more flexible and any pixel size can be specified.
- Because stock images are closely tied to stock items, and thus to actions in the user interface, stock images may come in multiple variants for different widget states or writing directions.

A good rule of thumb is that if there is a stock image for what you want to use, use it, otherwise use a named icon. It turns out that internally stock images are generally defined in terms of one or more named icons. (An example of the more than one case is icons that depend on writing direction; ''StockGoForward'' uses the two themed icons `gtkStockGoForwardLtr` and `gtkStockGoForwardRtl`.)

In many cases, named themes are used indirectly, via `Image` or stock items, 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 its much more efficient to use the standard icon theme for the `Screen` so that the icon information is shared with other people looking up icons. In the case where the default screen is being used, looking up an icon can be as simple as:

# Class Hierarchy

     | GObject
     | +----IconTheme

# Types

data IconTheme

Instances

Eq IconTheme |
Ord IconTheme |
GObjectClass IconTheme |
IconThemeClass IconTheme |

class GObjectClass o => IconThemeClass o

Instances

IconThemeClass IconTheme |

castToIconTheme :: GObjectClass obj => obj -> IconTheme

toIconTheme :: IconThemeClass o => o -> IconTheme

data IconInfo

# Enums

data IconLookupFlags

Constructors

IconLookupNoSvg |
IconLookupForceSvg |
IconLookupUseBuiltin |
IconLookupGenericFallback |
IconLookupForceSize |

Instances

Bounded IconLookupFlags |
Enum IconLookupFlags |
Eq IconLookupFlags |
Show IconLookupFlags |

data IconThemeError

Constructors

IconThemeNotFound |
IconThemeFailed |

Instances

Bounded IconThemeError |
Enum IconThemeError |
Eq IconThemeError |
Show IconThemeError |

# Constructors

iconThemeNew :: IO IconTheme

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 `iconThemeGetDefault` or `iconThemeGetForScreen` rather than creating a new icon theme object for scratch.

iconInfoNewForPixbuf :: IconThemeClass iconTheme => iconTheme -> Pixbuf -> IO IconInfo

# Methods

iconThemeGetDefault

Arguments

:: IO IconTheme | returns A unique `IconTheme` associated with the default screen. This icon theme is associated with the screen and can be used as long as the screen is open.

Gets the icon theme for the default screen. See `iconThemeGetForScreen`.

iconThemeGetForScreen

Arguments

:: Screen | `screen` - a `Screen`
-> IO IconTheme | returns A unique `IconTheme` associated with the given screen.

Gets the icon theme object associated with `screen`; if this function has not previously been called for the given screen, a new icon theme object will be created and associated with the screen. Icon theme objects are fairly expensive to create, so using this function is usually a better choice than calling than `iconThemeNew` and setting the screen yourself; by using this function a single icon theme object will be shared between users.

iconThemeSetScreen

Arguments

:: IconThemeClass self |
=> self |
-> Screen | `screen` - a `Screen`
-> IO () |

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.

iconThemeSetSearchPath

Arguments

:: IconThemeClass self |
=> self |
-> [FilePath] | `path` - list of directories that are searched for icon themes
-> Int | `nElements` - number of elements in `path`.
-> IO () |

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. (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 default icon theme, which is called DEFAULT_THEME_NAME, rather than directly on the icon path.)

iconThemeGetSearchPath

Arguments

:: IconThemeClass self |
=> self |
-> IO ([FilePath], Int) | `(path, nElements)` `path` - location to store a list of icon theme path directories.

Gets the current search path. See `iconThemeSetSearchPath`.

iconThemeAppendSearchPath

Arguments

:: IconThemeClass self |
=> self |
-> FilePath | `path` - directory name to append to the icon path
-> IO () |

Appends a directory to the search path. See `iconThemeSetSearchPath`.

iconThemePrependSearchPath

Arguments

:: IconThemeClass self |
=> self |
-> FilePath | `path` - directory name to prepend to the icon path
-> IO () |

Prepends a directory to the search path. See `iconThemeSetSearchPath`.

iconThemeSetCustomTheme

Arguments

:: IconThemeClass self |
=> self |
-> Maybe String | `themeName` name of icon theme to use instead of configured theme, or `Nothing` to unset a previously set custom theme
-> IO () |

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 `iconThemeGetDefault` and `iconThemeGetForScreen`.

iconThemeHasIcon

Arguments

:: IconThemeClass self |
=> self |
-> String | `iconName` - the name of an icon
-> IO Bool | returns `True` if `iconTheme` includes an icon for `iconName`.

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

iconThemeLookupIcon

Arguments

:: IconThemeClass self |
=> self |
-> String | `iconName` - the name of the icon to lookup
-> Int | `size` - desired icon size
-> IconLookupFlags | `flags` - flags modifying the behavior of the icon lookup
-> IO (Maybe IconInfo) | returns a `IconInfo` structure containing information about the icon, or `Nothing` if the icon wasn't found.

Looks up a named icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using `iconInfoLoadIcon`. (`iconThemeLoadIcon` combines these two steps if all you need is the pixbuf.)

iconThemeChooseIcon

Arguments

:: IconThemeClass self |
=> self |
-> [String] | `iconNames` terminated list of icon names to lookup
-> Int | `size` - desired icon size
-> IconLookupFlags | `flags` - flags modifying the behavior of the icon lookup
-> IO (Maybe IconInfo) | returns a `IconInfo` structure containing information about the icon, or `Nothing` if the icon wasn't found.

Looks up a named icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using `iconInfoLoadIcon`. (`iconThemeLoadIcon` combines these two steps if all you need is the pixbuf.)

If `iconNames` contains more than one name, this function tries them all in the given order before falling back to inherited icon themes.

- Available since Gtk+ version 2.12

iconThemeLoadIcon

Arguments

:: IconThemeClass self |
=> self |
-> String | `iconName` - the name of the icon to lookup
-> Int | `size` - the desired icon size. The resulting icon may not be exactly this size; see `iconInfoLoadIcon`.
-> IconLookupFlags | `flags` - flags modifying the behavior of the icon lookup
-> IO (Maybe Pixbuf) | 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. `Nothing` if the icon isn't found.

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 `iconThemeLookupIcon` followed by `iconInfoLoadIcon`.

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the `Widget`::style-set signal. If for some reason you do not want to update the icon when the icon theme changes, you should consider using `pixbufCopy` 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.

iconThemeListContexts

Arguments

:: IconThemeClass self |
=> self |
-> IO [String] | returns a String list holding the names of all the contexts in the theme.

Gets the list of contexts available within the current hierarchy of icon themes

- Available since Gtk+ version 2.12

iconThemeListIcons

Arguments

:: IconThemeClass self |
=> self |
-> Maybe String | `context` a string identifying a particular type of icon, or `Nothing` to list all icons.
-> IO [String] | returns a String list holding the names of all the icons in the theme.

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

iconThemeGetIconSizes

Arguments

:: IconThemeClass self |
=> self |
-> String | `iconName` - the name of an icon
-> IO [Int] | returns An newly allocated list describing the sizes at which the icon is available.

Returns an list 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 list is zero-terminated.

- Available since Gtk+ version 2.6

iconThemeGetExampleIconName

Arguments

:: IconThemeClass self |
=> self |
-> IO (Maybe String) | returns the name of an example icon or `Nothing`

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

iconThemeRescanIfNeeded

Arguments

:: IconThemeClass self |
=> self |
-> IO Bool | returns `True` if the icon theme has changed and needed to be reloaded.

Checks to see if the icon theme has changed; if it has, any currently cached information is discarded and will be reloaded next time `iconTheme` is accessed.

iconThemeAddBuiltinIcon

Arguments

:: String | `iconName` - the name of the icon to register
-> Int | `size` - the size at which to register the icon (different images can be registered for the same icon name at different sizes.)
-> Pixbuf | `pixbuf` - `Pixbuf` that contains the image to use for `iconName`.
-> IO () |

Registers a built-in icon for icon theme lookups. The idea of built-in icons is to allow an application or library that uses themed icons to function requiring files to be present in the file system. For instance, the default images for all of Gtk+'s stock icons are registered as built-icons.

In general, if you use `iconThemeAddBuiltinIcon` you should also install the icon in the icon theme, so that the icon is generally available.

This function will generally be used with pixbufs loaded via `pixbufNewFromInline`.

iconThemeErrorQuark :: IO Quark

iconInfoCopy :: IconInfo -> IO IconInfo

iconInfoGetAttachPoints :: IconInfo -> IO (Maybe [Point])

Fetches the set of attach points for an icon. An attach point is a location in the icon that can be used as anchor points for attaching emblems or overlays to the icon.

iconInfoGetBaseSize :: IconInfo -> IO Int

Gets the base size for the icon. The base size is a size for the icon that was specified by the icon theme creator. This may be different than the actual size of image; an example of this is small emblem icons that can be attached to a larger icon. These icons will be given the same base size as the larger icons to which they are attached.

iconInfoGetBuiltinPixbuf

Arguments

:: IconInfo |
-> IO (Maybe Pixbuf) | returns the built-in image pixbuf, or `Nothing`.

Gets the built-in image for this icon, if any. To allow GTK+ to use built in icon images, you must pass the ''IconLookupUseBuiltin'' to `iconThemeLookupIcon`.

iconInfoGetDisplayName

Arguments

:: IconInfo |
-> IO (Maybe String) | returns the display name for the icon or `Nothing`, if the icon doesn't have a specified display name.

Gets the display name for an icon. A display name is a string to be used in place of the icon name in a user visible context like a list of icons.

iconInfoGetEmbeddedRect

Arguments

:: IconInfo |
-> IO (Maybe Rectangle) | `rectangle` `Rectangle` in which to store embedded rectangle coordinates.

Gets the coordinates of a rectangle within the icon that can be used for display of information such as a preview of the contents of a text file. See `iconInfoSetRawCoordinates` for further information about the coordinate system.

iconInfoGetFilename

Arguments

:: IconInfo |
-> IO (Maybe String) | returns the filename for the icon, or `Nothing` if `iconInfoGetBuiltinPixbuf` should be used instead.

Gets the filename for the icon. If the ''IconLookupUseBuiltin'' flag was passed to `iconThemeLookupIcon`, there may be no filename if a builtin icon is returned; in this case, you should use `iconInfoGetBuiltinPixbuf`.

iconInfoLoadIcon :: IconInfo -> IO Pixbuf

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 `iconThemeLookupIcon` followed by `iconInfoLoadIcon`.

Note that you probably want to listen for icon theme changes and update the icon. This is usually done by connecting to the `styleSet` signal. If for some reason you do not want to update the icon when the icon theme changes, you should consider using `pixbufCopy` 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.

iconInfoSetRawCoordinates

Arguments

:: IconInfo |
-> Bool | `rawCoordinates` whether the coordinates of embedded rectangles and attached points should be returned in their original
-> IO () |

Sets whether the coordinates returned by `iconInfoGetEmbeddedRect` and `iconInfoGetAttachPoints` should be returned in their original form as specified in the icon theme, instead of scaled appropriately for the pixbuf returned by `iconInfoLoadIcon`.

Raw coordinates are somewhat strange; they are specified to be with respect to the unscaled pixmap for PNG and XPM icons, but for SVG icons, they are in a 1000x1000 coordinate space that is scaled to the final size of the icon. You can determine if the icon is an SVG icon by using `iconInfoGetFilename`, and seeing if it is non-`Nothing` and ends in '.svg'.

This function is provided primarily to allow compatibility wrappers for older API's, and is not expected to be useful for applications.

# Signals

iconThemeChanged :: IconThemeClass self => Signal self (IO ())

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