gtk3-0.15.10: Binding to the Gtk+ 3 graphical user interface library

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell98

Graphics.UI.Gtk.General.IconFactory

Contents

- Detail
- Class Hierarchy
- Types
- Constructors
- Methods
- Orphan instances

Description

Manipulating stock icons

Synopsis

- data IconFactory
- class GObjectClass o => IconFactoryClass o
- castToIconFactory :: GObjectClass obj => obj -> IconFactory
- gTypeIconFactory :: GType
- toIconFactory :: IconFactoryClass o => o -> IconFactory
- iconFactoryNew :: IO IconFactory
- iconFactoryAdd :: IconFactory -> StockId -> IconSet -> IO ()
- iconFactoryAddDefault :: IconFactory -> IO ()
- iconFactoryLookup :: IconFactory -> StockId -> IO (Maybe IconSet)
- iconFactoryLookupDefault :: StockId -> IO (Maybe IconSet)
- iconFactoryRemoveDefault :: IconFactory -> IO ()
- data IconSet
- iconSetNew :: IO IconSet
- iconSetNewFromPixbuf :: Pixbuf -> IO IconSet
- iconSetAddSource :: IconSet -> IconSource -> IO ()
- iconSetRenderIcon :: WidgetClass widget => IconSet -> TextDirection -> StateType -> IconSize -> widget -> IO Pixbuf
- iconSetGetSizes :: IconSet -> IO [IconSize]
- data IconSource
- iconSourceNew :: IO IconSource
- data TextDirection
  - = TextDirNone
  - | TextDirLtr
  - | TextDirRtl
- iconSourceGetDirection :: IconSource -> IO (Maybe TextDirection)
- iconSourceSetDirection :: IconSource -> TextDirection -> IO ()
- iconSourceResetDirection :: IconSource -> IO ()
- iconSourceGetFilename :: GlibString string => IconSource -> IO (Maybe string)
- iconSourceSetFilename :: GlibFilePath fp => IconSource -> fp -> IO ()
- iconSourceGetPixbuf :: IconSource -> IO (Maybe Pixbuf)
- iconSourceSetPixbuf :: IconSource -> Pixbuf -> IO ()
- iconSourceGetSize :: IconSource -> IO (Maybe IconSize)
- iconSourceSetSize :: IconSource -> IconSize -> IO ()
- iconSourceResetSize :: IconSource -> IO ()
- data StateType
  - = StateNormal
  - | StateActive
  - | StatePrelight
  - | StateSelected
  - | StateInsensitive
  - | StateInconsistent
  - | StateFocused
- iconSourceGetState :: IconSource -> IO (Maybe StateType)
- iconSourceSetState :: IconSource -> StateType -> IO ()
- iconSourceResetState :: IconSource -> IO ()
- data IconSize
  - = IconSizeInvalid
  - | IconSizeMenu
  - | IconSizeSmallToolbar
  - | IconSizeLargeToolbar
  - | IconSizeButton
  - | IconSizeDnd
  - | IconSizeDialog
  - | IconSizeUser Int
- iconSizeCheck :: IconSize -> IO Bool
- iconSizeRegister :: GlibString string => string -> Int -> Int -> IO IconSize
- iconSizeRegisterAlias :: GlibString string => IconSize -> string -> IO ()
- iconSizeFromName :: GlibString string => string -> IO IconSize
- iconSizeGetName :: GlibString string => IconSize -> IO (Maybe string)

# Detail

Browse the available stock icons in the list of stock IDs found here. You can also use the gtk-demo application for this purpose.

An icon factory manages a collection of `IconSet`; a `IconSet` manages a set of variants of a particular icon (i.e. a `IconSet` contains variants for different sizes and widget states). Icons in an icon factory are named by a stock ID, which is a simple string identifying the icon. Each `Style` has a list of `IconFactory` derived from the current theme; those icon factories are consulted first when searching for an icon. If the theme doesn't set a particular icon, Gtk+ looks for the icon in a list of default icon factories, maintained by `iconFactoryAddDefault` and `iconFactoryRemoveDefault`. Applications with icons should add a default icon factory with their icons, which will allow themes to override the icons for the application.

To display an icon, always use `styleLookupIconSet` on the widget that will display the icon, or the convenience function `widgetRenderIcon`. These functions take the theme into account when looking up the icon to use for a given stock ID.

# Class Hierarchy

    | GObject
    | +----IconFactory

# Types

data IconFactory Source #

#### Instances

Instances details

Eq IconFactory Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods (==) :: IconFactory -> IconFactory -> Bool Source # (/=) :: IconFactory -> IconFactory -> Bool Source #
Ord IconFactory Source # |

Instance details

Defined in Graphics.UI.Gtk.Types

Methods

compare :: IconFactory -> IconFactory -> Ordering Source #

(<) :: IconFactory -> IconFactory -> Bool Source #

(<=) :: IconFactory -> IconFactory -> Bool Source #

(>) :: IconFactory -> IconFactory -> Bool Source #

(>=) :: IconFactory -> IconFactory -> Bool Source #

max :: IconFactory -> IconFactory -> IconFactory Source #

min :: IconFactory -> IconFactory -> IconFactory Source #

GObjectClass IconFactory Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods toGObject :: IconFactory -> GObject Source # unsafeCastGObject :: GObject -> IconFactory Source #
IconFactoryClass IconFactory Source # |
Instance details Defined in Graphics.UI.Gtk.Types

class GObjectClass o => IconFactoryClass o Source #

#### Instances

Instances details

IconFactoryClass IconFactory Source # |
Instance details Defined in Graphics.UI.Gtk.Types

castToIconFactory :: GObjectClass obj => obj -> IconFactory Source #

gTypeIconFactory :: GType Source #

toIconFactory :: IconFactoryClass o => o -> IconFactory Source #

# Constructors

iconFactoryNew :: IO IconFactory Source #

Create a new IconFactory.

- An application should create a new `IconFactory` and add all needed icons. By calling `iconFactoryAddDefault` these icons become available as stock objects and can easily be displayed by `Image`. Furthermore, a theme can override the icons defined by the application.

# Methods

iconFactoryAdd :: IconFactory -> StockId -> IconSet -> IO () Source #

Add an IconSet to an IconFactory.

In order to use the new stock object, the factory as to be added to the default factories by `iconFactoryAddDefault`.

iconFactoryAddDefault :: IconFactory -> IO () Source #

Add all entries of the IconFactory to the applications stock object database.

iconFactoryLookup :: IconFactory -> StockId -> IO (Maybe IconSet) Source #

Looks up the stock id in the icon factory, returning an icon set if found, otherwise Nothing.

For display to the user, you should use `styleLookupIconSet` on the `Style` for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.

iconFactoryLookupDefault :: StockId -> IO (Maybe IconSet) Source #

Looks for an icon in the list of default icon factories.

For display to the user, you should use `styleLookupIconSet` on the `Style` for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.

iconFactoryRemoveDefault :: IconFactory -> IO () Source #

Remove an IconFactory from the application's stock database.

data IconSet Source #

iconSetNew :: IO IconSet Source #

Create a new IconSet.

- Each icon in an application is contained in an `IconSet`. The `IconSet` contains several variants (`IconSource`s) to accommodate for different sizes and states.

iconSetNewFromPixbuf :: Pixbuf -> IO IconSet Source #

Creates a new `IconSet` with the given pixbuf as the default/fallback source image. If you don't add any additional IconSource to the icon set, all variants of the icon will be created from the pixbuf, using scaling, pixelation, etc. as required to adjust the icon size or make the icon look insensitive/prelighted.

iconSetAddSource :: IconSet -> IconSource -> IO () Source #

Add an `IconSource` (an Icon with attributes) to an `IconSet`.

- If an icon is looked up in the IconSet `set` the best matching IconSource will be taken. It is therefore advisable to add a default (wildcarded) icon, than can be used if no exact match is found.

iconSetRenderIcon :: WidgetClass widget => IconSet -> TextDirection -> StateType -> IconSize -> widget -> IO Pixbuf Source #

iconSetGetSizes :: IconSet -> IO [IconSize] Source #

Obtains a list of icon sizes this icon set can render.

data IconSource Source #

iconSourceNew :: IO IconSource Source #

Create a new IconSource.

- An IconSource is a single image that is usually added to an IconSet. Next to the image it contains information about which state, text direction and size it should apply.

data TextDirection Source #

Constructors

TextDirNone |
TextDirLtr |
TextDirRtl |

#### Instances

Instances details

Enum TextDirection Source # |

Instance details

Defined in Graphics.UI.Gtk.General.Enums

Methods

succ :: TextDirection -> TextDirection Source #

pred :: TextDirection -> TextDirection Source #

toEnum :: Int -> TextDirection Source #

fromEnum :: TextDirection -> Int Source #

enumFrom :: TextDirection -> [TextDirection] Source #

enumFromThen :: TextDirection -> TextDirection -> [TextDirection] Source #

enumFromTo :: TextDirection -> TextDirection -> [TextDirection] Source #

enumFromThenTo :: TextDirection -> TextDirection -> TextDirection -> [TextDirection] Source #

Show TextDirection Source # |
Instance details Defined in Graphics.UI.Gtk.General.Enums Methods showsPrec :: Int -> TextDirection -> ShowS Source # show :: TextDirection -> String Source # showList :: [TextDirection] -> ShowS Source #
Eq TextDirection Source # |
Instance details Defined in Graphics.UI.Gtk.General.Enums Methods (==) :: TextDirection -> TextDirection -> Bool Source # (/=) :: TextDirection -> TextDirection -> Bool Source #

iconSourceGetDirection :: IconSource -> IO (Maybe TextDirection) Source #

Retrieve the `TextDirection` of this IconSource.

- `Nothing` is returned if no explicit direction was set.

iconSourceSetDirection :: IconSource -> TextDirection -> IO () Source #

Mark this `IconSource` that it should only apply to the specified `TextDirection`.

iconSourceResetDirection :: IconSource -> IO () Source #

Reset the specific `TextDirection` set with `iconSourceSetDirection`.

iconSourceGetFilename :: GlibString string => IconSource -> IO (Maybe string) Source #

Retrieve the filename this IconSource was based on.

- Returns `Nothing` if the IconSource was generated by a Pixbuf.

iconSourceSetFilename :: GlibFilePath fp => IconSource -> fp -> IO () Source #

Load an icon picture from this filename.

iconSourceGetPixbuf :: IconSource -> IO (Maybe Pixbuf) Source #

Retrieves the source pixbuf, or Nothing if none is set.

iconSourceSetPixbuf :: IconSource -> Pixbuf -> IO () Source #

Sets a pixbuf to use as a base image when creating icon variants for `IconSet`.

iconSourceGetSize :: IconSource -> IO (Maybe IconSize) Source #

Retrieve the `IconSize` of this IconSource.

- `Nothing` is returned if no explicit size was set (i.e. this `IconSource` matches all sizes).

iconSourceSetSize :: IconSource -> IconSize -> IO () Source #

Set this `IconSource` to a specific size.

iconSourceResetSize :: IconSource -> IO () Source #

Reset the `IconSize` of this `IconSource` so that is matches anything.

data StateType Source #

Widget states

Constructors

StateNormal |
StateActive |
StatePrelight |
StateSelected |
StateInsensitive |
StateInconsistent |
StateFocused |

#### Instances

Instances details

Enum StateType Source # |

Instance details

Defined in Graphics.UI.Gtk.General.Enums

Methods

succ :: StateType -> StateType Source #

pred :: StateType -> StateType Source #

toEnum :: Int -> StateType Source #

fromEnum :: StateType -> Int Source #

enumFrom :: StateType -> [StateType] Source #

enumFromThen :: StateType -> StateType -> [StateType] Source #

enumFromTo :: StateType -> StateType -> [StateType] Source #

enumFromThenTo :: StateType -> StateType -> StateType -> [StateType] Source #

Show StateType Source # |
Instance details Defined in Graphics.UI.Gtk.General.Enums Methods showsPrec :: Int -> StateType -> ShowS Source # show :: StateType -> String Source # showList :: [StateType] -> ShowS Source #
Eq StateType Source # |
Instance details Defined in Graphics.UI.Gtk.General.Enums Methods (==) :: StateType -> StateType -> Bool Source # (/=) :: StateType -> StateType -> Bool Source #

iconSourceGetState :: IconSource -> IO (Maybe StateType) Source #

Retrieve the `StateType` of this `IconSource`.

- `Nothing` is returned if the `IconSource` matches all states.

iconSourceSetState :: IconSource -> StateType -> IO () Source #

Mark this icon to be used only with this specific state.

iconSourceResetState :: IconSource -> IO () Source #

Reset the `StateType` of this `IconSource` so that is matches anything.

data IconSize Source #

The size of an icon in pixels.

- This enumeration contains one case that is not exported and which is used when new sizes are registered using `iconSizeRegister`.
- Applying `show` to this type will reveal the name of the size that is registered with Gtk+.

Constructors

IconSizeInvalid | Don't scale but use any of the available sizes.
IconSizeMenu | Icon size to use in next to menu items in drop-down menus.
IconSizeSmallToolbar | Icon size for small toolbars.
IconSizeLargeToolbar | Icon size for larger toolbars.
IconSizeButton | Icon size for icons in buttons, next to the label.
IconSizeDnd | Icon size for icons in drag-and-drop.
IconSizeDialog | Icon size for icons next to dialog text.
IconSizeUser Int |

#### Instances

Instances details

Enum IconSize Source # |

Instance details

Defined in Graphics.UI.Gtk.General.Structs

Methods

succ :: IconSize -> IconSize Source #

pred :: IconSize -> IconSize Source #

toEnum :: Int -> IconSize Source #

fromEnum :: IconSize -> Int Source #

enumFrom :: IconSize -> [IconSize] Source #

enumFromThen :: IconSize -> IconSize -> [IconSize] Source #

enumFromTo :: IconSize -> IconSize -> [IconSize] Source #

enumFromThenTo :: IconSize -> IconSize -> IconSize -> [IconSize] Source #

Show IconSize Source # |
Instance details Defined in Graphics.UI.Gtk.General.IconFactory Methods showsPrec :: Int -> IconSize -> ShowS Source # show :: IconSize -> String Source # showList :: [IconSize] -> ShowS Source #
Eq IconSize Source # |
Instance details Defined in Graphics.UI.Gtk.General.Structs Methods (==) :: IconSize -> IconSize -> Bool Source # (/=) :: IconSize -> IconSize -> Bool Source #

iconSizeCheck :: IconSize -> IO Bool Source #

Check if a given IconSize is registered.

- Useful if your application expects a theme to install a set with a specific size. You can test if this actually happens and use another size if not.

iconSizeRegister Source #

Arguments

:: GlibString string |
=> string | the new name of the size
-> Int | the width of the icon
-> Int | the height of the icon
-> IO IconSize | the new icon size

Register a new IconSize.

iconSizeRegisterAlias :: GlibString string => IconSize -> string -> IO () Source #

Register an additional alias for a name.

iconSizeFromName :: GlibString string => string -> IO IconSize Source #

Lookup an IconSize by name.

- This fixed value `iconSizeInvalid` is returned if the name was not found.

iconSizeGetName :: GlibString string => IconSize -> IO (Maybe string) Source #

Lookup the name of an IconSize.

- Returns `Nothing` if the name was not found.

# Orphan instances

Show IconSize Source # |
Instance details Methods showsPrec :: Int -> IconSize -> ShowS Source # show :: IconSize -> String Source # showList :: [IconSize] -> ShowS Source #