gtk.IconSource.IconSource Class Reference

List of all members.

Detailed Description

Description 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 GtkIconSet; a GtkIconSet manages a set of variants of a particular icon (i.e. a GtkIconSet 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 GtkStyle has a list of GtkIconFactory 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 gtk_icon_factory_add_default() and gtk_icon_factory_remove_default(). 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 gtk_style_lookup_icon_set() on the widget that will display the icon, or the convenience function gtk_widget_render_icon(). These functions take the theme into account when looking up the icon to use for a given stock ID.


Public Member Functions

GtkIconSourcegetIconSourceStruct ()
 this (GtkIconSource *gtkIconSource)
 Sets our main struct and passes it to the parent class.
GtkIconSourcesourceCopy ()
 Creates a copy of source; mostly useful for language bindings.
void sourceFree ()
 Frees a dynamically-allocated icon source, along with its filename, size, and pixbuf fields if those are not NULL.
GtkTextDirection sourceGetDirection ()
 Obtains the text direction this icon source applies to.
int sourceGetDirectionWildcarded ()
 Gets the value set by gtk_icon_source_set_direction_wildcarded().
char[] sourceGetFilename ()
 Retrieves the source filename, or NULL if none is set.
Pixbuf sourceGetPixbuf ()
 Retrieves the source pixbuf, or NULL if none is set.
char[] sourceGetIconName ()
 Retrieves the source icon name, or NULL if none is set.
GtkIconSize sourceGetSize ()
 Obtains the icon size this source applies to.
int sourceGetSizeWildcarded ()
 Gets the value set by gtk_icon_source_set_size_wildcarded().
GtkStateType sourceGetState ()
 Obtains the widget state this icon source applies to.
int sourceGetStateWildcarded ()
 Gets the value set by gtk_icon_source_set_state_wildcarded().
void sourceSetDirection (GtkTextDirection direction)
 Sets the text direction this icon source is intended to be used with.
void sourceSetDirectionWildcarded (int setting)
 If the text direction is wildcarded, this source can be used as the base image for an icon in any GtkTextDirection.
void sourceSetFilename (char[] filename)
 Sets the name of an image file to use as a base image when creating icon variants for GtkIconSet.
void sourceSetPixbuf (Pixbuf pixbuf)
 Sets a pixbuf to use as a base image when creating icon variants for GtkIconSet.
void sourceSetIconName (char[] iconName)
 Sets the name of an icon to look up in the current icon theme to use as a base image when creating icon variants for GtkIconSet.
void sourceSetSize (GtkIconSize size)
 Sets the icon size this icon source is intended to be used with.
void sourceSetSizeWildcarded (int setting)
 If the icon size is wildcarded, this source can be used as the base image for an icon of any size.
void sourceSetState (GtkStateType state)
 Sets the widget state this icon source is intended to be used with.
void sourceSetStateWildcarded (int setting)
 If the widget state is wildcarded, this source can be used as the base image for an icon in any GtkStateType.

Static Public Member Functions

static void factoryAdd (GtkIconFactory *factory, char[] stockId, GtkIconSet *iconSet)
 Adds the given icon_set to the icon factory, under the name stock_id.
static void factoryAddDefault (GtkIconFactory *factory)
 Adds an icon factory to the list of icon factories searched by gtk_style_lookup_icon_set().
static GtkIconSetfactoryLookup (GtkIconFactory *factory, char[] stockId)
 Looks up stock_id in the icon factory, returning an icon set if found, otherwise NULL.
static GtkIconSetfactoryLookupDefault (char[] stockId)
 Looks for an icon in the list of default icon factories.
static GtkIconFactoryfactoryNew ()
 Creates a new GtkIconFactory.
static void factoryRemoveDefault (GtkIconFactory *factory)
 Removes an icon factory from the list of default icon factories.
static void setAddSource (GtkIconSet *iconSet, GtkIconSource *source)
 Icon sets have a list of GtkIconSource, which they use as base icons for rendering icons in different states and sizes.
static GtkIconSetsetCopy (GtkIconSet *iconSet)
 Copies icon_set by value.
static GtkIconSetsetNew ()
 Creates a new GtkIconSet.
static GtkIconSetsetNewFromPixbuf (Pixbuf pixbuf)
 Creates a new GtkIconSet with pixbuf as the default/fallback source image.
static GtkIconSetsetRef (GtkIconSet *iconSet)
 Increments the reference count on icon_set.
static Pixbuf setRenderIcon (GtkIconSet *iconSet, Style style, GtkTextDirection direction, GtkStateType state, GtkIconSize size, Widget widget, char[] detail)
 Renders an icon using gtk_style_render_icon().
static void setUnref (GtkIconSet *iconSet)
 Decrements the reference count on icon_set, and frees memory if the reference count reaches 0.
static int sizeLookup (GtkIconSize size, int *width, int *height)
 Obtains the pixel size of a semantic icon size, possibly modified by user preferences for the default GtkSettings.
static int sizeLookupForSettings (Settings settings, GtkIconSize size, int *width, int *height)
 Obtains the pixel size of a semantic icon size, possibly modified by user preferences for a particular GtkSettings.
static GtkIconSize sizeRegister (char[] name, int width, int height)
 Registers a new icon size, along the same lines as GTK_ICON_SIZE_MENU, etc.
static void sizeRegisterAlias (char[] alia, GtkIconSize target)
 Registers alias as another name for target.
static GtkIconSize sizeFromName (char[] name)
 Looks up the icon size associated with name.
static char[] sizeGetName (GtkIconSize size)
 Gets the canonical name of the given icon size.
static void setGetSizes (GtkIconSet *iconSet, GtkIconSize **sizes, int *nSizes)
 Obtains a list of icon sizes this icon set can render.
static GtkIconSourcesourceNew ()
 Creates a new GtkIconSource.

Protected Member Functions

void * getStruct ()
 the main Gtk struct as a void*

Protected Attributes

GtkIconSourcegtkIconSource
 the main Gtk struct


Constructor & Destructor Documentation

gtk.IconSource.IconSource.this ( GtkIconSource gtkIconSource  ) 

Sets our main struct and passes it to the parent class.


Member Function Documentation

static void gtk.IconSource.IconSource.factoryAdd ( GtkIconFactory factory,
char[]  stockId,
GtkIconSet iconSet 
) [static]

Adds the given icon_set to the icon factory, under the name stock_id.

stock_id should be namespaced for your application, e.g. "myapp-whatever-icon". Normally applications create a GtkIconFactory, then add it to the list of default factories with gtk_icon_factory_add_default(). Then they pass the stock_id to widgets such as GtkImage 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 stock_id, it is unreferenced and replaced with the new icon_set. factory: a GtkIconFactory stock_id: icon name icon_set: icon set

static void gtk.IconSource.IconSource.factoryAddDefault ( GtkIconFactory factory  )  [static]

Adds an icon factory to the list of icon factories searched by gtk_style_lookup_icon_set().

This means that, for example, gtk_image_new_from_stock() 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. factory: a GtkIconFactory

static GtkIconSet* gtk.IconSource.IconSource.factoryLookup ( GtkIconFactory factory,
char[]  stockId 
) [static]

Looks up stock_id in the icon factory, returning an icon set if found, otherwise NULL.

For display to the user, you should use gtk_style_lookup_icon_set() on the GtkStyle for the widget that will display the icon, instead of using this function directly, so that themes are taken into account. factory: a GtkIconFactory stock_id: an icon name Returns: icon set of stock_id.

static GtkIconSet* gtk.IconSource.IconSource.factoryLookupDefault ( char[]  stockId  )  [static]

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

For display to the user, you should use gtk_style_lookup_icon_set() on the GtkStyle for the widget that will display the icon, instead of using this function directly, so that themes are taken into account. stock_id: an icon name Returns: a GtkIconSet, or NULL

static GtkIconFactory* gtk.IconSource.IconSource.factoryNew (  )  [static]

Creates a new GtkIconFactory.

An icon factory manages a collection of GtkIconSets; a GtkIconSet manages a set of variants of a particular icon (i.e. a GtkIconSet 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 GtkStyle 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 gtk_icon_factory_add_default() and gtk_icon_factory_remove_default(). Applications with icons should add a default icon factory with their icons, which will allow themes to override the icons for the application. Returns: a new GtkIconFactory

static void gtk.IconSource.IconSource.factoryRemoveDefault ( GtkIconFactory factory  )  [static]

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. factory: a GtkIconFactory previously added with gtk_icon_factory_add_default()

GtkIconSource* gtk.IconSource.IconSource.getIconSourceStruct (  ) 

void* gtk.IconSource.IconSource.getStruct (  )  [protected]

the main Gtk struct as a void*

static void gtk.IconSource.IconSource.setAddSource ( GtkIconSet iconSet,
GtkIconSource source 
) [static]

Icon sets have a list of GtkIconSource, which they use as base icons for rendering icons in different states and sizes.

Icons are scaled, made to look insensitive, etc. in gtk_icon_set_render_icon(), but GtkIconSet needs base images to work with. The base images and when to use them are described by a GtkIconSource. This function copies source, so you can reuse the same source immediately without affecting the icon set. An example of when you'd use this function: a web browser's "Back to Previous Page" icon might point in a different direction in Hebrew and in English; it might look different when insensitive; and it might change size depending on toolbar mode (small/large icons). So a single icon set would contain all those variants of the icon, and you might add a separate source for each one. You should nearly always add a "default" icon source with all fields wildcarded, which will be used as a fallback if no more specific source matches. GtkIconSet always prefers more specific icon sources to more generic icon sources. The order in which you add the sources to the icon set does not matter. gtk_icon_set_new_from_pixbuf() creates a new icon set with a default icon source based on the given pixbuf. icon_set: a GtkIconSet source: a GtkIconSource

static GtkIconSet* gtk.IconSource.IconSource.setCopy ( GtkIconSet iconSet  )  [static]

Copies icon_set by value.

icon_set: a GtkIconSet Returns: a new GtkIconSet identical to the first.

static void gtk.IconSource.IconSource.setGetSizes ( GtkIconSet iconSet,
GtkIconSize **  sizes,
int nSizes 
) [static]

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

The returned array must be freed with g_free(). icon_set: a GtkIconSet sizes: return location for array of sizes n_sizes: location to store number of elements in returned array

static GtkIconSet* gtk.IconSource.IconSource.setNew (  )  [static]

Creates a new GtkIconSet.

A GtkIconSet represents a single icon in various sizes and widget states. It can provide a GdkPixbuf for a given size and state on request, and automatically caches some of the rendered GdkPixbuf objects. Normally you would use gtk_widget_render_icon() instead of using GtkIconSet directly. The one case where you'd use GtkIconSet is to create application-specific icon sets to place in a GtkIconFactory. Returns: a new GtkIconSet

static GtkIconSet* gtk.IconSource.IconSource.setNewFromPixbuf ( Pixbuf  pixbuf  )  [static]

Creates a new GtkIconSet with pixbuf as the default/fallback source image.

If you don't add any additional GtkIconSource to the icon set, all variants of the icon will be created from pixbuf, using scaling, pixelation, etc. as required to adjust the icon size or make the icon look insensitive/prelighted. pixbuf: a GdkPixbuf Returns: a new GtkIconSet

static GtkIconSet* gtk.IconSource.IconSource.setRef ( GtkIconSet iconSet  )  [static]

Increments the reference count on icon_set.

icon_set: a GtkIconSet. Returns: icon_set.

static Pixbuf gtk.IconSource.IconSource.setRenderIcon ( GtkIconSet iconSet,
Style  style,
GtkTextDirection  direction,
GtkStateType  state,
GtkIconSize  size,
Widget  widget,
char[]  detail 
) [static]

Renders an icon using gtk_style_render_icon().

In most cases, gtk_widget_render_icon() is better, since it automatically provides most of the arguments from the current widget settings. This function never returns NULL; if the icon can't be rendered (perhaps because an image file fails to load), a default "missing image" icon will be returned instead. icon_set: a GtkIconSet style: a GtkStyle associated with widget, or NULL direction: text direction state: widget state size: icon size. A size of (GtkIconSize)-1 means render at the size of the source and don't scale. widget: widget that will display the icon, or NULL. The only use that is typically made of this is to determine the appropriate GdkScreen. detail: detail to pass to the theme engine, or NULL. Note that passing a detail of anything but NULL will disable caching. Returns: a GdkPixbuf to be displayed

static void gtk.IconSource.IconSource.setUnref ( GtkIconSet iconSet  )  [static]

Decrements the reference count on icon_set, and frees memory if the reference count reaches 0.

icon_set: a GtkIconSet

static GtkIconSize gtk.IconSource.IconSource.sizeFromName ( char[]  name  )  [static]

Looks up the icon size associated with name.

name: the name to look up. Returns: the icon size with the given name.

static char [] gtk.IconSource.IconSource.sizeGetName ( GtkIconSize  size  )  [static]

Gets the canonical name of the given icon size.

The returned string is statically allocated and should not be freed. size: a GtkIconSize. Returns: the name of the given icon size.

static int gtk.IconSource.IconSource.sizeLookup ( GtkIconSize  size,
int width,
int height 
) [static]

Obtains the pixel size of a semantic icon size, possibly modified by user preferences for the default GtkSettings.

(See gtk_icon_size_lookup_for_settings().) Normally size would be GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_BUTTON, etc. This function isn't normally needed, gtk_widget_render_icon() is the usual way to get an icon for rendering, then just look at the size of the rendered pixbuf. The rendered pixbuf may not even correspond to the width/height returned by gtk_icon_size_lookup(), because themes are free to render the pixbuf however they like, including changing the usual size. size: an icon size width: location to store icon width height: location to store icon height Returns: TRUE if size was a valid size

static int gtk.IconSource.IconSource.sizeLookupForSettings ( Settings  settings,
GtkIconSize  size,
int width,
int height 
) [static]

Obtains the pixel size of a semantic icon size, possibly modified by user preferences for a particular GtkSettings.

Normally size would be GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_BUTTON, etc. This function isn't normally needed, gtk_widget_render_icon() is the usual way to get an icon for rendering, then just look at the size of the rendered pixbuf. The rendered pixbuf may not even correspond to the width/height returned by gtk_icon_size_lookup(), because themes are free to render the pixbuf however they like, including changing the usual size. settings: a GtkSettings object, used to determine which set of user preferences to used. size: an icon size width: location to store icon width height: location to store icon height Returns: TRUE if size was a valid size Since 2.2

static GtkIconSize gtk.IconSource.IconSource.sizeRegister ( char[]  name,
int  width,
int  height 
) [static]

Registers a new icon size, along the same lines as GTK_ICON_SIZE_MENU, etc.

Returns the integer value for the size. name: name of the icon size width: the icon width height: the icon height Returns: integer value representing the size

static void gtk.IconSource.IconSource.sizeRegisterAlias ( char[]  alia,
GtkIconSize  target 
) [static]

Registers alias as another name for target.

So calling gtk_icon_size_from_name() with alias as argument will return target. alias: an alias for target target: an existing icon size

GtkIconSource* gtk.IconSource.IconSource.sourceCopy (  ) 

Creates a copy of source; mostly useful for language bindings.

source: a GtkIconSource Returns: a new GtkIconSource

void gtk.IconSource.IconSource.sourceFree (  ) 

Frees a dynamically-allocated icon source, along with its filename, size, and pixbuf fields if those are not NULL.

source: a GtkIconSource

GtkTextDirection gtk.IconSource.IconSource.sourceGetDirection (  ) 

Obtains the text direction this icon source applies to.

The return value is only useful/meaningful if the text direction is not wildcarded. source: a GtkIconSource Returns: text direction this source matches

int gtk.IconSource.IconSource.sourceGetDirectionWildcarded (  ) 

Gets the value set by gtk_icon_source_set_direction_wildcarded().

source: a GtkIconSource Returns: TRUE if this icon source is a base for any text direction variant

char [] gtk.IconSource.IconSource.sourceGetFilename (  ) 

Retrieves the source filename, or NULL if none is set.

The filename is not a copy, and should not be modified or expected to persist beyond the lifetime of the icon source. source: a GtkIconSource Returns: image filename. This string must not be modified or freed.

char [] gtk.IconSource.IconSource.sourceGetIconName (  ) 

Retrieves the source icon name, or NULL if none is set.

The icon_name is not a copy, and should not be modified or expected to persist beyond the lifetime of the icon source. source: a GtkIconSource Returns: icon name. This string must not be modified or freed.

Pixbuf gtk.IconSource.IconSource.sourceGetPixbuf (  ) 

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

In addition, if a filename source is in use, this function in some cases will return the pixbuf from loaded from the filename. This is, for example, true for the GtkIconSource passed to the GtkStyle.render_icon() virtual function. The reference count on the pixbuf is not incremented. source: a GtkIconSource Returns: source pixbuf

GtkIconSize gtk.IconSource.IconSource.sourceGetSize (  ) 

Obtains the icon size this source applies to.

The return value is only useful/meaningful if the icon size is not wildcarded. source: a GtkIconSource Returns: icon size this source matches.

int gtk.IconSource.IconSource.sourceGetSizeWildcarded (  ) 

Gets the value set by gtk_icon_source_set_size_wildcarded().

source: a GtkIconSource Returns: TRUE if this icon source is a base for any icon size variant

GtkStateType gtk.IconSource.IconSource.sourceGetState (  ) 

Obtains the widget state this icon source applies to.

The return value is only useful/meaningful if the widget state is not wildcarded. source: a GtkIconSource Returns: widget state this source matches

int gtk.IconSource.IconSource.sourceGetStateWildcarded (  ) 

Gets the value set by gtk_icon_source_set_state_wildcarded().

source: a GtkIconSource Returns: TRUE if this icon source is a base for any widget state variant

static GtkIconSource* gtk.IconSource.IconSource.sourceNew (  )  [static]

Creates a new GtkIconSource.

A GtkIconSource contains a GdkPixbuf (or image filename) that serves as the base image for one or more of the icons in a GtkIconSet, along with a specification for which icons in the icon set will be based on that pixbuf or image file. An icon set contains a set of icons that represent "the same" logical concept in different states, different global text directions, and different sizes. So for example a web browser's "Back to Previous Page" icon might point in a different direction in Hebrew and in English; it might look different when insensitive; and it might change size depending on toolbar mode (small/large icons). So a single icon set would contain all those variants of the icon. GtkIconSet contains a list of GtkIconSource from which it can derive specific icon variants in the set. In the simplest case, GtkIconSet contains one source pixbuf from which it derives all variants. The convenience function gtk_icon_set_new_from_pixbuf() handles this case; if you only have one source pixbuf, just use that function. If you want to use a different base pixbuf for different icon variants, you create multiple icon sources, mark which variants they'll be used to create, and add them to the icon set with gtk_icon_set_add_source(). By default, the icon source has all parameters wildcarded. That is, the icon source will be used as the base icon for any desired text direction, widget state, or icon size. Returns: a new GtkIconSource

void gtk.IconSource.IconSource.sourceSetDirection ( GtkTextDirection  direction  ) 

Sets the text direction this icon source is intended to be used with.

Setting the text direction on an icon source makes no difference if the text direction is wildcarded. Therefore, you should usually call gtk_icon_source_set_direction_wildcarded() to un-wildcard it in addition to calling this function. source: a GtkIconSource direction: text direction this source applies to

void gtk.IconSource.IconSource.sourceSetDirectionWildcarded ( int  setting  ) 

If the text direction is wildcarded, this source can be used as the base image for an icon in any GtkTextDirection.

If the text direction is not wildcarded, then the text direction the icon source applies to should be set with gtk_icon_source_set_direction(), and the icon source will only be used with that text direction. GtkIconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible. source: a GtkIconSource setting: TRUE to wildcard the text direction

void gtk.IconSource.IconSource.sourceSetFilename ( char[]  filename  ) 

Sets the name of an image file to use as a base image when creating icon variants for GtkIconSet.

The filename must be absolute. source: a GtkIconSource filename: image file to use

void gtk.IconSource.IconSource.sourceSetIconName ( char[]  iconName  ) 

Sets the name of an icon to look up in the current icon theme to use as a base image when creating icon variants for GtkIconSet.

source: a GtkIconSource icon_name: name of icon to use

void gtk.IconSource.IconSource.sourceSetPixbuf ( Pixbuf  pixbuf  ) 

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

source: a GtkIconSource pixbuf: pixbuf to use as a source

void gtk.IconSource.IconSource.sourceSetSize ( GtkIconSize  size  ) 

Sets the icon size this icon source is intended to be used with.

Setting the icon size on an icon source makes no difference if the size is wildcarded. Therefore, you should usually call gtk_icon_source_set_size_wildcarded() to un-wildcard it in addition to calling this function. source: a GtkIconSource size: icon size this source applies to

void gtk.IconSource.IconSource.sourceSetSizeWildcarded ( int  setting  ) 

If the icon size is wildcarded, this source can be used as the base image for an icon of any size.

If the size is not wildcarded, then the size the source applies to should be set with gtk_icon_source_set_size() and the icon source will only be used with that specific size. GtkIconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible. GtkIconSet will normally scale wildcarded source images to produce an appropriate icon at a given size, but will not change the size of source images that match exactly. source: a GtkIconSource setting: TRUE to wildcard the widget state

void gtk.IconSource.IconSource.sourceSetState ( GtkStateType  state  ) 

Sets the widget state this icon source is intended to be used with.

Setting the widget state on an icon source makes no difference if the state is wildcarded. Therefore, you should usually call gtk_icon_source_set_state_wildcarded() to un-wildcard it in addition to calling this function. source: a GtkIconSource state: widget state this source applies to

void gtk.IconSource.IconSource.sourceSetStateWildcarded ( int  setting  ) 

If the widget state is wildcarded, this source can be used as the base image for an icon in any GtkStateType.

If the widget state is not wildcarded, then the state the source applies to should be set with gtk_icon_source_set_state() and the icon source will only be used with that specific state. GtkIconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible. GtkIconSet will normally transform wildcarded source images to produce an appropriate icon for a given state, for example lightening an image on prelight, but will not modify source images that match exactly. source: a GtkIconSource setting: TRUE to wildcard the widget state


Member Data Documentation

GtkIconSource* gtk.IconSource.IconSource.gtkIconSource [protected]

the main Gtk struct


SourceForge.net Logo DSource.org Logo digitalmars.com Logo