2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkIconTheme.html
28 * strct = GtkIconTheme
54 * - GdkPixbuf* -> Pixbuf
55 * - GdkScreen* -> Screen
56 * - GtkIconInfo* -> IconInfo
57 * - GtkIconTheme* -> IconTheme
68 import tango
.io
.Stdout
; // use the tango loging?
72 private import gtkc
.gtktypes
;
74 private import gtkc
.gtk
;
77 private import glib
.Str
;
78 private import gtk
.IconTheme
;
79 private import gdk
.Screen
;
80 private import gtk
.IconInfo
;
81 private import gdk
.Pixbuf
;
82 private import glib
.ListG
;
89 * GtkIconTheme provides a facility for looking up icons by name
90 * and size. The main reason for using a name rather than simply
91 * providing a filename is to allow different icons to be used
92 * depending on what icon theme is selecetd
93 * by the user. The operation of icon themes on Linux and Unix
95 * Theme Specification. There is a default icon theme,
96 * named hicolor where applications should install
97 * their icons, but more additional application themes can be
98 * installed as operating system vendors and users choose.
99 * Named icons are similar to the Themeable Stock Images(3)
100 * facility, and the distinction between the two may be a bit confusing.
101 * A few things to keep in mind:
102 * Stock images usually are used in conjunction with
103 * Stock Items(3)., such as GTK_STOCK_OK or
104 * GTK_STOCK_OPEN. Named icons are easier to set up and therefore
105 * are more useful for new icons that an application wants to
106 * add, such as application icons or window icons.
107 * Stock images can only be loaded at the symbolic sizes defined
108 * by the GtkIconSize enumeration, or by custom sizes defined
109 * by gtk_icon_size_register(), while named icons are more flexible
110 * and any pixel size can be specified.
111 * Because stock images are closely tied to stock items, and thus
112 * to actions in the user interface, stock images may come in
113 * multiple variants for different widget states or writing
115 * A good rule of thumb is that if there is a stock image for what
116 * you want to use, use it, otherwise use a named icon. It turns
117 * out that internally stock images are generally defined in
118 * terms of one or more named icons. (An example of the
119 * more than one case is icons that depend on writing direction;
120 * GTK_STOCK_GO_FORWARD uses the two themed icons
121 * "gtk-stock-go-forward-ltr" and "gtk-stock-go-forward-rtl".)
122 * In many cases, named themes are used indirectly, via GtkImage
123 * or stock items, rather than directly, but looking up icons
124 * directly is also simple. The GtkIconTheme object acts
125 * as a database of all the icons in the current theme. You
126 * can create new GtkIconTheme objects, but its much more
127 * efficient to use the standard icon theme for the GdkScreen
128 * so that the icon information is shared with other people
129 * looking up icons. In the case where the default screen is
130 * being used, looking up an icon can be as simple as:
131 * GError *error = NULL;
132 * GtkIconTheme *icon_theme;
134 * icon_theme = gtk_icon_theme_get_default ();
135 * pixbuf = gtk_icon_theme_load_icon (icon_theme,
136 * "my-icon-name", /+* icon name +/
142 * g_warning ("Couldn't load icon: %s", error->message);
143 * g_error_free (error);
147 * /+* Use the pixbuf +/
148 * g_object_unref (pixbuf);
151 private import gobject
.ObjectG
;
152 public class IconTheme
: ObjectG
155 /** the main Gtk struct */
156 protected GtkIconTheme
* gtkIconTheme
;
159 public GtkIconTheme
* getIconThemeStruct()
165 /** the main Gtk struct as a void* */
166 protected void* getStruct()
168 return cast(void*)gtkIconTheme
;
172 * Sets our main struct and passes it to the parent class
174 public this (GtkIconTheme
* gtkIconTheme
)
178 if ( gtkIconTheme
is null )
183 Stdout("struct gtkIconTheme is null on constructor").newline
;
187 printf("struct gtkIconTheme is null on constructor");
194 assert(gtkIconTheme
!is null, "struct gtkIconTheme is null on constructor");
196 super(cast(GObject
*)gtkIconTheme
);
197 this.gtkIconTheme
= gtkIconTheme
;
203 // imports for the signal processing
204 private import gobject
.Signals
;
205 private import gtkc
.gdktypes
;
206 int[char[]] connectedSignals
;
208 void delegate(IconTheme
)[] onChangedListeners
;
209 void addOnChanged(void delegate(IconTheme
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
211 if ( !("changed" in connectedSignals
) )
216 cast(GCallback
)&callBackChanged
,
220 connectedSignals
["changed"] = 1;
222 onChangedListeners
~= dlg
;
224 extern(C
) static void callBackChanged(GtkIconTheme
* iconThemeStruct
, IconTheme iconTheme
)
226 bool consumed
= false;
228 foreach ( void delegate(IconTheme
) dlg
; iconTheme
.onChangedListeners
)
243 * Creates a new icon theme object. Icon theme objects are used
244 * to lookup up an icon by name in a particular icon theme.
245 * Usually, you'll want to use gtk_icon_theme_get_default()
246 * or gtk_icon_theme_get_for_screen() rather than creating
247 * a new icon theme object for scratch.
249 * the newly created GtkIconTheme object.
254 // GtkIconTheme* gtk_icon_theme_new (void);
255 this(cast(GtkIconTheme
*)gtk_icon_theme_new() );
259 * Gets the icon theme for the default screen. See
260 * gtk_icon_theme_get_for_screen().
262 * A unique GtkIconTheme associated with
263 * the default screen. This icon theme is associated with
264 * the screen and can be used as long as the screen
265 * is open. Do not ref or unref it.
268 public static IconTheme
getDefault()
270 // GtkIconTheme* gtk_icon_theme_get_default (void);
271 return new IconTheme( gtk_icon_theme_get_default() );
275 * Gets the icon theme object associated with screen; if this
276 * function has not previously been called for the given
277 * screen, a new icon theme object will be created and
278 * associated with the screen. Icon theme objects are
279 * fairly expensive to create, so using this function
280 * is usually a better choice than calling than gtk_icon_theme_new()
281 * and setting the screen yourself; by using this function
282 * a single icon theme object will be shared between users.
286 * A unique GtkIconTheme associated with
287 * the given screen. This icon theme is associated with
288 * the screen and can be used as long as the screen
289 * is open. Do not ref or unref it.
292 public static IconTheme
getForScreen(Screen screen
)
294 // GtkIconTheme* gtk_icon_theme_get_for_screen (GdkScreen *screen);
295 return new IconTheme( gtk_icon_theme_get_for_screen((screen
is null) ?
null : screen
.getScreenStruct()) );
299 * Sets the screen for an icon theme; the screen is used
300 * to track the user's currently configured icon theme,
301 * which might be different for different screens.
308 public void setScreen(Screen screen
)
310 // void gtk_icon_theme_set_screen (GtkIconTheme *icon_theme, GdkScreen *screen);
311 gtk_icon_theme_set_screen(gtkIconTheme
, (screen
is null) ?
null : screen
.getScreenStruct());
315 * Sets the search path for the icon theme object. When looking
316 * for an icon theme, GTK+ will search for a subdirectory of
317 * one or more of the directories in path with the same name
318 * as the icon theme. (Themes from multiple of the path elements
319 * are combined to allow themes to be extended by adding icons
320 * in the user's home directory.)
321 * In addition if an icon found isn't found either in the current
322 * icon theme or the default icon theme, and an image file with
323 * the right name is found directly in one of the elements of
324 * path, then that image will be used for the icon name.
325 * (This is legacy feature, and new icons should be put
326 * into the default icon theme, which is called DEFAULT_THEME_NAME,
327 * rather than directly on the icon path.)
331 * array of directories that are searched for icon themes
333 * number of elements in path.
336 public void setSearchPath(char*[] path
, int nElements
)
338 // void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme, const gchar *path[], gint n_elements);
339 gtk_icon_theme_set_search_path(gtkIconTheme
, path
, nElements
);
343 * Gets the current search path. See gtk_icon_theme_set_search_path().
347 * location to store a list of icon theme path directories or NULL
348 * The stored value should be freed with g_strfreev().
350 * location to store number of elements
354 public void getSearchPath(char**[] path
, int* nElements
)
356 // void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme, gchar **path[], gint *n_elements);
357 gtk_icon_theme_get_search_path(gtkIconTheme
, path
, nElements
);
361 * Appends a directory to the search path.
362 * See gtk_icon_theme_set_search_path().
366 * directory name to append to the icon path
369 public void appendSearchPath(char[] path
)
371 // void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme, const gchar *path);
372 gtk_icon_theme_append_search_path(gtkIconTheme
, Str
.toStringz(path
));
376 * Prepends a directory to the search path.
377 * See gtk_icon_theme_set_search_path().
381 * directory name to prepend to the icon path
384 public void prependSearchPath(char[] path
)
386 // void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme, const gchar *path);
387 gtk_icon_theme_prepend_search_path(gtkIconTheme
, Str
.toStringz(path
));
391 * Sets the name of the icon theme that the GtkIconTheme object uses
392 * overriding system configuration. This function cannot be called
393 * on the icon theme objects returned from gtk_icon_theme_get_default()
394 * and gtk_icon_theme_get_for_screen().
398 * name of icon theme to use instead of configured theme,
399 * or NULL to unset a previously set custom theme
402 public void setCustomTheme(char[] themeName
)
404 // void gtk_icon_theme_set_custom_theme (GtkIconTheme *icon_theme, const gchar *theme_name);
405 gtk_icon_theme_set_custom_theme(gtkIconTheme
, Str
.toStringz(themeName
));
409 * Checks whether an icon theme includes an icon
410 * for a particular name.
414 * the name of an icon
416 * TRUE if icon_theme includes an
417 * icon for icon_name.
420 public int hasIcon(char[] iconName
)
422 // gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme, const gchar *icon_name);
423 return gtk_icon_theme_has_icon(gtkIconTheme
, Str
.toStringz(iconName
));
427 * Looks up a named icon and returns a structure containing
428 * information such as the filename of the icon. The icon
429 * can then be rendered into a pixbuf using
430 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
431 * combines these two steps if all you need is the pixbuf.)
435 * the name of the icon to lookup
439 * flags modifying the behavior of the icon lookup
441 * a GtkIconInfo structure containing information
442 * about the icon, or NULL if the icon wasn't found. Free with
443 * gtk_icon_info_free()
446 public IconInfo
lookupIcon(char[] iconName
, int size
, GtkIconLookupFlags flags
)
448 // GtkIconInfo* gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags);
449 return new IconInfo( gtk_icon_theme_lookup_icon(gtkIconTheme
, Str
.toStringz(iconName
), size
, flags
) );
453 * Looks up an icon in an icon theme, scales it to the given size
454 * and renders it into a pixbuf. This is a convenience function;
455 * if more details about the icon are needed, use
456 * gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_icon().
457 * Note that you probably want to listen for icon theme changes and
458 * update the icon. This is usually done by connecting to the
459 * GtkWidget::style-set signal. If for some reason you do not want to
460 * update the icon when the icon theme changes, you should consider
461 * using gdk_pixbuf_copy() to make a private copy of the pixbuf
462 * returned by this function. Otherwise GTK+ may need to keep the old
463 * icon theme loaded, which would be a waste of memory.
467 * the name of the icon to lookup
469 * the desired icon size. The resulting icon may not be
470 * exactly this size; see gtk_icon_info_load_icon().
472 * flags modifying the behavior of the icon lookup
474 * Location to store error information on failure, or NULL.
476 * the rendered icon; this may be a newly created icon
477 * or a new reference to an internal icon, so you must not modify
478 * the icon. Use g_object_unref() to release your reference to the
479 * icon. NULL if the icon isn't found.
482 public Pixbuf
loadIcon(char[] iconName
, int size
, GtkIconLookupFlags flags
, GError
** error
)
484 // GdkPixbuf* gtk_icon_theme_load_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags, GError **error);
485 return new Pixbuf( gtk_icon_theme_load_icon(gtkIconTheme
, Str
.toStringz(iconName
), size
, flags
, error
) );
489 * Lists the icons in the current icon theme. Only a subset
490 * of the icons can be listed by providing a context string.
491 * The set of values for the context string is system dependent,
492 * but will typically include such values as "Applications" and
497 * a string identifying a particular type of icon,
498 * or NULL to list all icons.
500 * a GList list holding the names of all the
501 * icons in the theme. You must first free each element
502 * in the list with g_free(), then free the list itself
503 * with g_list_free().
506 public ListG
listIcons(char[] context
)
508 // GList* gtk_icon_theme_list_icons (GtkIconTheme *icon_theme, const gchar *context);
509 return new ListG( gtk_icon_theme_list_icons(gtkIconTheme
, Str
.toStringz(context
)) );
513 * Returns an array of integers describing the sizes at which
514 * the icon is available without scaling. A size of -1 means
515 * that the icon is available in a scalable format. The array
516 * is zero-terminated.
520 * the name of an icon
522 * An newly allocated array describing the sizes at
523 * which the icon is available. The array should be freed with g_free()
524 * when it is no longer needed.
527 public int* getIconSizes(char[] iconName
)
529 // gint* gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, const gchar *icon_name);
530 return gtk_icon_theme_get_icon_sizes(gtkIconTheme
, Str
.toStringz(iconName
));
534 * Gets the name of an icon that is representative of the
535 * current theme (for instance, to use when presenting
536 * a list of themes to the user.)
540 * the name of an example icon or NULL.
541 * Free with g_free().
544 public char[] getExampleIconName()
546 // char* gtk_icon_theme_get_example_icon_name (GtkIconTheme *icon_theme);
547 return Str
.toString(gtk_icon_theme_get_example_icon_name(gtkIconTheme
) );
551 * Checks to see if the icon theme has changed; if it has, any
552 * currently cached information is discarded and will be reloaded
553 * next time icon_theme is accessed.
557 * TRUE if the icon theme has changed and needed
561 public int rescanIfNeeded()
563 // gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
564 return gtk_icon_theme_rescan_if_needed(gtkIconTheme
);
568 * Registers a built-in icon for icon theme lookups. The idea
569 * of built-in icons is to allow an application or library
570 * that uses themed icons to function requiring files to
571 * be present in the file system. For instance, the default
572 * images for all of GTK+'s stock icons are registered
574 * In general, if you use gtk_icon_theme_add_builtin_icon()
575 * you should also install the icon in the icon theme, so
576 * that the icon is generally available.
577 * This function will generally be used with pixbufs loaded
578 * via gdk_pixbuf_new_from_inline().
580 * the name of the icon to register
582 * the size at which to register the icon (different
583 * images can be registered for the same icon name
584 * at different sizes.)
586 * GdkPixbuf that contains the image to use
590 public static void addBuiltinIcon(char[] iconName
, int size
, Pixbuf pixbuf
)
592 // void gtk_icon_theme_add_builtin_icon (const gchar *icon_name, gint size, GdkPixbuf *pixbuf);
593 gtk_icon_theme_add_builtin_icon(Str
.toStringz(iconName
), size
, (pixbuf
is null) ?
null : pixbuf
.getPixbufStruct());