gi-gtk-3.0.37: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.IconFactory

Description

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.

# GtkIconFactory as GtkBuildable # {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.

## A IconFactory UI definition fragment. ##

<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

Exported types

newtype IconFactory Source #

Memory-managed wrapper type.

Constructors

IconFactory (ManagedPtr IconFactory) 

Instances

Instances details
Eq IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

GObject IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

ManagedPtrNewtype IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

Methods

toManagedPtr :: IconFactory -> ManagedPtr IconFactory

TypedObject IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

Methods

glibType :: IO GType

HasParentTypes IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

IsGValue (Maybe IconFactory) Source #

Convert IconFactory to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.IconFactory

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe IconFactory -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe IconFactory)

type ParentTypes IconFactory Source # 
Instance details

Defined in GI.Gtk.Objects.IconFactory

type ParentTypes IconFactory = '[Object, Buildable]

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

Instances details
(GObject o, IsDescendantOf IconFactory o) => IsIconFactory o Source # 
Instance details

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.

Methods

add

iconFactoryAdd Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconFactory a) 
=> a

factory: a IconFactory

-> Text

stockId: icon name

-> IconSet

iconSet: icon set

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

Arguments

:: (HasCallStack, MonadIO m, IsIconFactory a) 
=> a

factory: a IconFactory

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

iconFactoryLookup Source #

Arguments

:: (HasCallStack, MonadIO m, IsIconFactory a) 
=> a

factory: a IconFactory

-> Text

stockId: an icon name

-> m IconSet

Returns: icon set of stockId.

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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

stockId: an icon name

-> m IconSet

Returns: a IconSet, or Nothing

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

iconFactoryNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m IconFactory

Returns: a new IconFactory

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 #

Arguments

:: (HasCallStack, MonadIO m, IsIconFactory a) 
=> a

factory: a IconFactory previously added with iconFactoryAddDefault

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