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 |
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.
{tIconFactory
-BUILDER-UI}
GtkIconFactory supports a custom <sources> element, which can contain multiple <source> elements. The following attributes are allowed:
- stock-id
The stock id of the source, a string. This attribute is mandatory
- filename
The filename of the source, a string. This attribute is optional
- icon-name
The icon name for the source, a string. This attribute is optional.
- size
Size of the icon, a IconSize
enum value. This attribute is
optional.
- direction
Direction of the source, a TextDirection
enum value. This
attribute is optional.
- state
State of the source, a StateType
enum value. This
attribute is optional.
<object class="GtkIconFactory" id="iconfactory1"> <sources> <source stock-id="apple-red" filename="apple-red.png"/> </sources> </object> <object class="GtkWindow" id="window1"> <child> <object class="GtkButton" id="apple_button"> <property name="label">apple-red</property> <property name="use-stock">True</property> </object> </child> </object>
Synopsis
- newtype IconFactory = IconFactory (ManagedPtr IconFactory)
- class (GObject o, IsDescendantOf IconFactory o) => IsIconFactory o
- toIconFactory :: (MonadIO m, IsIconFactory o) => o -> m IconFactory
- noIconFactory :: Maybe IconFactory
- iconFactoryAdd :: (HasCallStack, MonadIO m, IsIconFactory a) => a -> Text -> IconSet -> m ()
- iconFactoryAddDefault :: (HasCallStack, MonadIO m, IsIconFactory a) => a -> m ()
- iconFactoryLookup :: (HasCallStack, MonadIO m, IsIconFactory a) => a -> Text -> m IconSet
- iconFactoryLookupDefault :: (HasCallStack, MonadIO m) => Text -> m IconSet
- iconFactoryNew :: (HasCallStack, MonadIO m) => m IconFactory
- iconFactoryRemoveDefault :: (HasCallStack, MonadIO m, IsIconFactory a) => a -> m ()
Exported types
newtype IconFactory Source #
Memory-managed wrapper type.
Instances
Eq IconFactory Source # | |
Defined in GI.Gtk.Objects.IconFactory (==) :: IconFactory -> IconFactory -> Bool # (/=) :: IconFactory -> IconFactory -> Bool # | |
IsGValue IconFactory Source # | Convert |
Defined in GI.Gtk.Objects.IconFactory toGValue :: IconFactory -> IO GValue # fromGValue :: GValue -> IO IconFactory # | |
GObject IconFactory Source # | |
Defined in GI.Gtk.Objects.IconFactory gobjectType :: IO GType # | |
HasParentTypes IconFactory Source # | |
Defined in GI.Gtk.Objects.IconFactory | |
type ParentTypes IconFactory Source # | |
Defined in GI.Gtk.Objects.IconFactory |
class (GObject o, IsDescendantOf IconFactory o) => IsIconFactory o Source #
Type class for types which can be safely cast to IconFactory
, for instance with toIconFactory
.
Instances
(GObject o, IsDescendantOf IconFactory o) => IsIconFactory o Source # | |
Defined in GI.Gtk.Objects.IconFactory |
toIconFactory :: (MonadIO m, IsIconFactory o) => o -> m IconFactory Source #
Cast to IconFactory
, for types for which this is known to be safe. For general casts, use castTo
.
noIconFactory :: Maybe IconFactory Source #
A convenience alias for Nothing
:: Maybe
IconFactory
.
Methods
Overloaded methods
add
:: (HasCallStack, MonadIO m, IsIconFactory a) | |
=> a |
|
-> Text |
|
-> IconSet |
|
-> m () |
Deprecated: (Since version 3.10)Use IconTheme
instead.
Adds the given iconSet
to the icon factory, under the name
stockId
. stockId
should be namespaced for your application,
e.g. “myapp-whatever-icon”. Normally applications create a
IconFactory
, then add it to the list of default factories with
iconFactoryAddDefault
. Then they pass the stockId
to
widgets such as Image
to display the icon. Themes can provide
an icon with the same name (such as "myapp-whatever-icon") to
override your application’s default icons. If an icon already
existed in factory
for stockId
, it is unreferenced and replaced
with the new iconSet
.
addDefault
iconFactoryAddDefault Source #
:: (HasCallStack, MonadIO m, IsIconFactory a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.10)Use IconTheme
instead.
Adds an icon factory to the list of icon factories searched by
styleLookupIconSet
. This means that, for example,
imageNewFromStock
will be able to find icons in factory
.
There will normally be an icon factory added for each library or
application that comes with icons. The default icon factories
can be overridden by themes.
lookup
:: (HasCallStack, MonadIO m, IsIconFactory a) | |
=> a |
|
-> Text |
|
-> m IconSet | Returns: icon set of |
Deprecated: (Since version 3.10)Use IconTheme
instead.
Looks up stockId
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.
lookupDefault
iconFactoryLookupDefault Source #
Deprecated: (Since version 3.10)Use IconTheme
instead.
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.
new
:: (HasCallStack, MonadIO m) | |
=> m IconFactory | Returns: a new |
Deprecated: (Since version 3.10)Use IconTheme
instead.
Creates a new IconFactory
. An icon factory manages a collection
of GtkIconSets
; 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 GtkIconFactorys
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.
removeDefault
iconFactoryRemoveDefault Source #
:: (HasCallStack, MonadIO m, IsIconFactory a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.10)Use IconTheme
instead.
Removes an icon factory from the list of default icon factories. Not normally used; you might use it for a library that can be unloaded or shut down.