1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.IconTheme;
26 
27 private import cairo.Surface;
28 private import gdk.Screen;
29 private import gdk.Window;
30 private import gdkpixbuf.Pixbuf;
31 private import gio.IconIF;
32 private import glib.ConstructionException;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import glib.ListG;
36 private import glib.Str;
37 private import gobject.ObjectG;
38 private import gobject.Signals;
39 private import gtk.IconInfo;
40 public  import gtkc.gdktypes;
41 private import gtkc.gtk;
42 public  import gtkc.gtktypes;
43 private import std.algorithm;
44 
45 
46 /**
47  * #GtkIconTheme provides a facility for looking up icons by name
48  * and size. The main reason for using a name rather than simply
49  * providing a filename is to allow different icons to be used
50  * depending on what “icon theme” is selected
51  * by the user. The operation of icon themes on Linux and Unix
52  * follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
53  * There is a fallback icon theme, named `hicolor`, where applications
54  * should install their icons, but additional icon themes can be installed
55  * as operating system vendors and users choose.
56  * 
57  * Named icons are similar to the deprecated [Stock Items][gtkstock],
58  * and the distinction between the two may be a bit confusing.
59  * A few things to keep in mind:
60  * 
61  * - Stock images usually are used in conjunction with
62  * [Stock Items][gtkstock], such as %GTK_STOCK_OK or
63  * %GTK_STOCK_OPEN. Named icons are easier to set up and therefore
64  * are more useful for new icons that an application wants to
65  * add, such as application icons or window icons.
66  * 
67  * - Stock images can only be loaded at the symbolic sizes defined
68  * by the #GtkIconSize enumeration, or by custom sizes defined
69  * by gtk_icon_size_register(), while named icons are more flexible
70  * and any pixel size can be specified.
71  * 
72  * - Because stock images are closely tied to stock items, and thus
73  * to actions in the user interface, stock images may come in
74  * multiple variants for different widget states or writing
75  * directions.
76  * 
77  * A good rule of thumb is that if there is a stock image for what
78  * you want to use, use it, otherwise use a named icon. It turns
79  * out that internally stock images are generally defined in
80  * terms of one or more named icons. (An example of the
81  * more than one case is icons that depend on writing direction;
82  * %GTK_STOCK_GO_FORWARD uses the two themed icons
83  * “gtk-stock-go-forward-ltr” and “gtk-stock-go-forward-rtl”.)
84  * 
85  * In many cases, named themes are used indirectly, via #GtkImage
86  * or stock items, rather than directly, but looking up icons
87  * directly is also simple. The #GtkIconTheme object acts
88  * as a database of all the icons in the current theme. You
89  * can create new #GtkIconTheme objects, but it’s much more
90  * efficient to use the standard icon theme for the #GdkScreen
91  * so that the icon information is shared with other people
92  * looking up icons.
93  * |[<!-- language="C" -->
94  * GError *error = NULL;
95  * GtkIconTheme *icon_theme;
96  * GdkPixbuf *pixbuf;
97  * 
98  * icon_theme = gtk_icon_theme_get_default ();
99  * pixbuf = gtk_icon_theme_load_icon (icon_theme,
100  * "my-icon-name", // icon name
101  * 48, // icon size
102  * 0,  // flags
103  * &error);
104  * if (!pixbuf)
105  * {
106  * g_warning ("Couldn’t load icon: %s", error->message);
107  * g_error_free (error);
108  * }
109  * else
110  * {
111  * // Use the pixbuf
112  * g_object_unref (pixbuf);
113  * }
114  * ]|
115  */
116 public class IconTheme : ObjectG
117 {
118 	/** the main Gtk struct */
119 	protected GtkIconTheme* gtkIconTheme;
120 
121 	/** Get the main Gtk struct */
122 	public GtkIconTheme* getIconThemeStruct()
123 	{
124 		return gtkIconTheme;
125 	}
126 
127 	/** the main Gtk struct as a void* */
128 	protected override void* getStruct()
129 	{
130 		return cast(void*)gtkIconTheme;
131 	}
132 
133 	protected override void setStruct(GObject* obj)
134 	{
135 		gtkIconTheme = cast(GtkIconTheme*)obj;
136 		super.setStruct(obj);
137 	}
138 
139 	/**
140 	 * Sets our main struct and passes it to the parent class.
141 	 */
142 	public this (GtkIconTheme* gtkIconTheme, bool ownedRef = false)
143 	{
144 		this.gtkIconTheme = gtkIconTheme;
145 		super(cast(GObject*)gtkIconTheme, ownedRef);
146 	}
147 
148 
149 	/** */
150 	public static GType getType()
151 	{
152 		return gtk_icon_theme_get_type();
153 	}
154 
155 	/**
156 	 * Creates a new icon theme object. Icon theme objects are used
157 	 * to lookup up an icon by name in a particular icon theme.
158 	 * Usually, you’ll want to use gtk_icon_theme_get_default()
159 	 * or gtk_icon_theme_get_for_screen() rather than creating
160 	 * a new icon theme object for scratch.
161 	 *
162 	 * Return: the newly created #GtkIconTheme object.
163 	 *
164 	 * Since: 2.4
165 	 *
166 	 * Throws: ConstructionException GTK+ fails to create the object.
167 	 */
168 	public this()
169 	{
170 		auto p = gtk_icon_theme_new();
171 		
172 		if(p is null)
173 		{
174 			throw new ConstructionException("null returned by new");
175 		}
176 		
177 		this(cast(GtkIconTheme*) p, true);
178 	}
179 
180 	/**
181 	 * Registers a built-in icon for icon theme lookups. The idea
182 	 * of built-in icons is to allow an application or library
183 	 * that uses themed icons to function requiring files to
184 	 * be present in the file system. For instance, the default
185 	 * images for all of GTK+’s stock icons are registered
186 	 * as built-icons.
187 	 *
188 	 * In general, if you use gtk_icon_theme_add_builtin_icon()
189 	 * you should also install the icon in the icon theme, so
190 	 * that the icon is generally available.
191 	 *
192 	 * This function will generally be used with pixbufs loaded
193 	 * via gdk_pixbuf_new_from_inline().
194 	 *
195 	 * Deprecated: Use gtk_icon_theme_add_resource_path()
196 	 * to add application-specific icons to the icon theme.
197 	 *
198 	 * Params:
199 	 *     iconName = the name of the icon to register
200 	 *     size = the size in pixels at which to register the icon (different
201 	 *         images can be registered for the same icon name at different sizes.)
202 	 *     pixbuf = #GdkPixbuf that contains the image to use for @icon_name
203 	 *
204 	 * Since: 2.4
205 	 */
206 	public static void addBuiltinIcon(string iconName, int size, Pixbuf pixbuf)
207 	{
208 		gtk_icon_theme_add_builtin_icon(Str.toStringz(iconName), size, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
209 	}
210 
211 	/**
212 	 * Gets the icon theme for the default screen. See
213 	 * gtk_icon_theme_get_for_screen().
214 	 *
215 	 * Return: A unique #GtkIconTheme associated with
216 	 *     the default screen. This icon theme is associated with
217 	 *     the screen and can be used as long as the screen
218 	 *     is open. Do not ref or unref it.
219 	 *
220 	 * Since: 2.4
221 	 */
222 	public static IconTheme getDefault()
223 	{
224 		auto p = gtk_icon_theme_get_default();
225 		
226 		if(p is null)
227 		{
228 			return null;
229 		}
230 		
231 		return ObjectG.getDObject!(IconTheme)(cast(GtkIconTheme*) p);
232 	}
233 
234 	/**
235 	 * Gets the icon theme object associated with @screen; if this
236 	 * function has not previously been called for the given
237 	 * screen, a new icon theme object will be created and
238 	 * associated with the screen. Icon theme objects are
239 	 * fairly expensive to create, so using this function
240 	 * is usually a better choice than calling than gtk_icon_theme_new()
241 	 * and setting the screen yourself; by using this function
242 	 * a single icon theme object will be shared between users.
243 	 *
244 	 * Params:
245 	 *     screen = a #GdkScreen
246 	 *
247 	 * Return: A unique #GtkIconTheme associated with
248 	 *     the given screen. This icon theme is associated with
249 	 *     the screen and can be used as long as the screen
250 	 *     is open. Do not ref or unref it.
251 	 *
252 	 * Since: 2.4
253 	 */
254 	public static IconTheme getForScreen(Screen screen)
255 	{
256 		auto p = gtk_icon_theme_get_for_screen((screen is null) ? null : screen.getScreenStruct());
257 		
258 		if(p is null)
259 		{
260 			return null;
261 		}
262 		
263 		return ObjectG.getDObject!(IconTheme)(cast(GtkIconTheme*) p);
264 	}
265 
266 	/**
267 	 * Adds a resource path that will be looked at when looking
268 	 * for icons, similar to search paths.
269 	 *
270 	 * This function should be used to make application-specific icons
271 	 * available as part of the icon theme.
272 	 *
273 	 * The resources are considered as part of the hicolor icon theme
274 	 * and must be located in subdirectories that are defined in the
275 	 * hicolor icon theme, such as `@path/16x16/actions/run.png`.
276 	 * Icons that are directly placed in the resource path instead
277 	 * of a subdirectory are also considered as ultimate fallback.
278 	 *
279 	 * Params:
280 	 *     path = a resource path
281 	 *
282 	 * Since: 3.14
283 	 */
284 	public void addResourcePath(string path)
285 	{
286 		gtk_icon_theme_add_resource_path(gtkIconTheme, Str.toStringz(path));
287 	}
288 
289 	/**
290 	 * Appends a directory to the search path.
291 	 * See gtk_icon_theme_set_search_path().
292 	 *
293 	 * Params:
294 	 *     path = directory name to append to the icon path
295 	 *
296 	 * Since: 2.4
297 	 */
298 	public void appendSearchPath(string path)
299 	{
300 		gtk_icon_theme_append_search_path(gtkIconTheme, Str.toStringz(path));
301 	}
302 
303 	/**
304 	 * Looks up a named icon and returns a #GtkIconInfo containing
305 	 * information such as the filename of the icon. The icon
306 	 * can then be rendered into a pixbuf using
307 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
308 	 * combines these two steps if all you need is the pixbuf.)
309 	 *
310 	 * If @icon_names contains more than one name, this function
311 	 * tries them all in the given order before falling back to
312 	 * inherited icon themes.
313 	 *
314 	 * Params:
315 	 *     iconNames = %NULL-terminated array of
316 	 *         icon names to lookup
317 	 *     size = desired icon size
318 	 *     flags = flags modifying the behavior of the icon lookup
319 	 *
320 	 * Return: a #GtkIconInfo object
321 	 *     containing information about the icon, or %NULL if the icon wasn’t
322 	 *     found.
323 	 *
324 	 * Since: 2.12
325 	 */
326 	public IconInfo chooseIcon(string iconNames, int size, GtkIconLookupFlags flags)
327 	{
328 		auto p = gtk_icon_theme_choose_icon(gtkIconTheme, Str.toStringz(iconNames), size, flags);
329 		
330 		if(p is null)
331 		{
332 			return null;
333 		}
334 		
335 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
336 	}
337 
338 	/**
339 	 * Looks up a named icon for a particular window scale and returns
340 	 * a #GtkIconInfo containing information such as the filename of the
341 	 * icon. The icon can then be rendered into a pixbuf using
342 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
343 	 * combines these two steps if all you need is the pixbuf.)
344 	 *
345 	 * If @icon_names contains more than one name, this function
346 	 * tries them all in the given order before falling back to
347 	 * inherited icon themes.
348 	 *
349 	 * Params:
350 	 *     iconNames = %NULL-terminated
351 	 *         array of icon names to lookup
352 	 *     size = desired icon size
353 	 *     scale = desired scale
354 	 *     flags = flags modifying the behavior of the icon lookup
355 	 *
356 	 * Return: a #GtkIconInfo object
357 	 *     containing information about the icon, or %NULL if the
358 	 *     icon wasn’t found.
359 	 *
360 	 * Since: 3.10
361 	 */
362 	public IconInfo chooseIconForScale(string iconNames, int size, int scale, GtkIconLookupFlags flags)
363 	{
364 		auto p = gtk_icon_theme_choose_icon_for_scale(gtkIconTheme, Str.toStringz(iconNames), size, scale, flags);
365 		
366 		if(p is null)
367 		{
368 			return null;
369 		}
370 		
371 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
372 	}
373 
374 	/**
375 	 * Gets the name of an icon that is representative of the
376 	 * current theme (for instance, to use when presenting
377 	 * a list of themes to the user.)
378 	 *
379 	 * Return: the name of an example icon or %NULL.
380 	 *     Free with g_free().
381 	 *
382 	 * Since: 2.4
383 	 */
384 	public string getExampleIconName()
385 	{
386 		auto retStr = gtk_icon_theme_get_example_icon_name(gtkIconTheme);
387 		
388 		scope(exit) Str.freeString(retStr);
389 		return Str.toString(retStr);
390 	}
391 
392 	/**
393 	 * Returns an array of integers describing the sizes at which
394 	 * the icon is available without scaling. A size of -1 means
395 	 * that the icon is available in a scalable format. The array
396 	 * is zero-terminated.
397 	 *
398 	 * Params:
399 	 *     iconName = the name of an icon
400 	 *
401 	 * Return: An newly
402 	 *     allocated array describing the sizes at which the icon is
403 	 *     available. The array should be freed with g_free() when it is no
404 	 *     longer needed.
405 	 *
406 	 * Since: 2.6
407 	 */
408 	public int[] getIconSizes(string iconName)
409 	{
410 		auto p = gtk_icon_theme_get_icon_sizes(gtkIconTheme, Str.toStringz(iconName));
411 		
412 		return p[0 .. getArrayLength(p)];
413 	}
414 
415 	/**
416 	 * Gets the current search path. See gtk_icon_theme_set_search_path().
417 	 *
418 	 * Params:
419 	 *     path = location to store a list of icon theme path directories or %NULL.
420 	 *         The stored value should be freed with g_strfreev().
421 	 *     nElements = location to store number of elements in @path, or %NULL
422 	 *
423 	 * Since: 2.4
424 	 */
425 	public void getSearchPath(out string path)
426 	{
427 		char* outpath = null;
428 		int nElements;
429 		
430 		gtk_icon_theme_get_search_path(gtkIconTheme, &outpath, &nElements);
431 		
432 		path = Str.toString(outpath, nElements);
433 	}
434 
435 	/**
436 	 * Checks whether an icon theme includes an icon
437 	 * for a particular name.
438 	 *
439 	 * Params:
440 	 *     iconName = the name of an icon
441 	 *
442 	 * Return: %TRUE if @icon_theme includes an
443 	 *     icon for @icon_name.
444 	 *
445 	 * Since: 2.4
446 	 */
447 	public bool hasIcon(string iconName)
448 	{
449 		return gtk_icon_theme_has_icon(gtkIconTheme, Str.toStringz(iconName)) != 0;
450 	}
451 
452 	/**
453 	 * Gets the list of contexts available within the current
454 	 * hierarchy of icon themes.
455 	 * See gtk_icon_theme_list_icons() for details about contexts.
456 	 *
457 	 * Return: a #GList list
458 	 *     holding the names of all the contexts in the theme. You must first
459 	 *     free each element in the list with g_free(), then free the list
460 	 *     itself with g_list_free().
461 	 *
462 	 * Since: 2.12
463 	 */
464 	public ListG listContexts()
465 	{
466 		auto p = gtk_icon_theme_list_contexts(gtkIconTheme);
467 		
468 		if(p is null)
469 		{
470 			return null;
471 		}
472 		
473 		return new ListG(cast(GList*) p, true);
474 	}
475 
476 	/**
477 	 * Lists the icons in the current icon theme. Only a subset
478 	 * of the icons can be listed by providing a context string.
479 	 * The set of values for the context string is system dependent,
480 	 * but will typically include such values as “Applications” and
481 	 * “MimeTypes”. Contexts are explained in the
482 	 * [Icon Theme Specification](http://www.freedesktop.org/wiki/Specifications/icon-theme-spec).
483 	 * The standard contexts are listed in the
484 	 * [Icon Naming Specification](http://www.freedesktop.org/wiki/Specifications/icon-naming-spec).
485 	 * Also see gtk_icon_theme_list_contexts().
486 	 *
487 	 * Params:
488 	 *     context = a string identifying a particular type of
489 	 *         icon, or %NULL to list all icons.
490 	 *
491 	 * Return: a #GList list
492 	 *     holding the names of all the icons in the theme. You must
493 	 *     first free each element in the list with g_free(), then
494 	 *     free the list itself with g_list_free().
495 	 *
496 	 * Since: 2.4
497 	 */
498 	public ListG listIcons(string context)
499 	{
500 		auto p = gtk_icon_theme_list_icons(gtkIconTheme, Str.toStringz(context));
501 		
502 		if(p is null)
503 		{
504 			return null;
505 		}
506 		
507 		return new ListG(cast(GList*) p, true);
508 	}
509 
510 	/**
511 	 * Looks up an icon in an icon theme, scales it to the given size
512 	 * and renders it into a pixbuf. This is a convenience function;
513 	 * if more details about the icon are needed, use
514 	 * gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_icon().
515 	 *
516 	 * Note that you probably want to listen for icon theme changes and
517 	 * update the icon. This is usually done by connecting to the
518 	 * GtkWidget::style-set signal. If for some reason you do not want to
519 	 * update the icon when the icon theme changes, you should consider
520 	 * using gdk_pixbuf_copy() to make a private copy of the pixbuf
521 	 * returned by this function. Otherwise GTK+ may need to keep the old
522 	 * icon theme loaded, which would be a waste of memory.
523 	 *
524 	 * Params:
525 	 *     iconName = the name of the icon to lookup
526 	 *     size = the desired icon size. The resulting icon may not be
527 	 *         exactly this size; see gtk_icon_info_load_icon().
528 	 *     flags = flags modifying the behavior of the icon lookup
529 	 *
530 	 * Return: the rendered icon; this may be
531 	 *     a newly created icon or a new reference to an internal icon, so
532 	 *     you must not modify the icon. Use g_object_unref() to release
533 	 *     your reference to the icon. %NULL if the icon isn’t found.
534 	 *
535 	 * Since: 2.4
536 	 *
537 	 * Throws: GException on failure.
538 	 */
539 	public Pixbuf loadIcon(string iconName, int size, GtkIconLookupFlags flags)
540 	{
541 		GError* err = null;
542 		
543 		auto p = gtk_icon_theme_load_icon(gtkIconTheme, Str.toStringz(iconName), size, flags, &err);
544 		
545 		if (err !is null)
546 		{
547 			throw new GException( new ErrorG(err) );
548 		}
549 		
550 		if(p is null)
551 		{
552 			return null;
553 		}
554 		
555 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
556 	}
557 
558 	/**
559 	 * Looks up an icon in an icon theme for a particular window scale,
560 	 * scales it to the given size and renders it into a pixbuf. This is a
561 	 * convenience function; if more details about the icon are needed,
562 	 * use gtk_icon_theme_lookup_icon() followed by
563 	 * gtk_icon_info_load_icon().
564 	 *
565 	 * Note that you probably want to listen for icon theme changes and
566 	 * update the icon. This is usually done by connecting to the
567 	 * GtkWidget::style-set signal. If for some reason you do not want to
568 	 * update the icon when the icon theme changes, you should consider
569 	 * using gdk_pixbuf_copy() to make a private copy of the pixbuf
570 	 * returned by this function. Otherwise GTK+ may need to keep the old
571 	 * icon theme loaded, which would be a waste of memory.
572 	 *
573 	 * Params:
574 	 *     iconName = the name of the icon to lookup
575 	 *     size = the desired icon size. The resulting icon may not be
576 	 *         exactly this size; see gtk_icon_info_load_icon().
577 	 *     scale = desired scale
578 	 *     flags = flags modifying the behavior of the icon lookup
579 	 *
580 	 * Return: the rendered icon; this may be
581 	 *     a newly created icon or a new reference to an internal icon, so
582 	 *     you must not modify the icon. Use g_object_unref() to release
583 	 *     your reference to the icon. %NULL if the icon isn’t found.
584 	 *
585 	 * Since: 3.10
586 	 *
587 	 * Throws: GException on failure.
588 	 */
589 	public Pixbuf loadIconForScale(string iconName, int size, int scale, GtkIconLookupFlags flags)
590 	{
591 		GError* err = null;
592 		
593 		auto p = gtk_icon_theme_load_icon_for_scale(gtkIconTheme, Str.toStringz(iconName), size, scale, flags, &err);
594 		
595 		if (err !is null)
596 		{
597 			throw new GException( new ErrorG(err) );
598 		}
599 		
600 		if(p is null)
601 		{
602 			return null;
603 		}
604 		
605 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
606 	}
607 
608 	/**
609 	 * Looks up an icon in an icon theme for a particular window scale,
610 	 * scales it to the given size and renders it into a cairo surface. This is a
611 	 * convenience function; if more details about the icon are needed,
612 	 * use gtk_icon_theme_lookup_icon() followed by
613 	 * gtk_icon_info_load_surface().
614 	 *
615 	 * Note that you probably want to listen for icon theme changes and
616 	 * update the icon. This is usually done by connecting to the
617 	 * GtkWidget::style-set signal.
618 	 *
619 	 * Params:
620 	 *     iconName = the name of the icon to lookup
621 	 *     size = the desired icon size. The resulting icon may not be
622 	 *         exactly this size; see gtk_icon_info_load_icon().
623 	 *     scale = desired scale
624 	 *     forWindow = #GdkWindow to optimize drawing for, or %NULL
625 	 *     flags = flags modifying the behavior of the icon lookup
626 	 *
627 	 * Return: the rendered icon; this may be
628 	 *     a newly created icon or a new reference to an internal icon, so
629 	 *     you must not modify the icon. Use cairo_surface_destroy() to
630 	 *     release your reference to the icon. %NULL if the icon isn’t
631 	 *     found.
632 	 *
633 	 * Since: 3.10
634 	 *
635 	 * Throws: GException on failure.
636 	 */
637 	public Surface loadSurface(string iconName, int size, int scale, Window forWindow, GtkIconLookupFlags flags)
638 	{
639 		GError* err = null;
640 		
641 		auto p = gtk_icon_theme_load_surface(gtkIconTheme, Str.toStringz(iconName), size, scale, (forWindow is null) ? null : forWindow.getWindowStruct(), flags, &err);
642 		
643 		if (err !is null)
644 		{
645 			throw new GException( new ErrorG(err) );
646 		}
647 		
648 		if(p is null)
649 		{
650 			return null;
651 		}
652 		
653 		return new Surface(cast(cairo_surface_t*) p);
654 	}
655 
656 	/**
657 	 * Looks up an icon and returns a #GtkIconInfo containing information
658 	 * such as the filename of the icon. The icon can then be rendered
659 	 * into a pixbuf using gtk_icon_info_load_icon().
660 	 *
661 	 * When rendering on displays with high pixel densities you should not
662 	 * use a @size multiplied by the scaling factor returned by functions
663 	 * like gdk_window_get_scale_factor(). Instead, you should use
664 	 * gtk_icon_theme_lookup_by_gicon_for_scale(), as the assets loaded
665 	 * for a given scaling factor may be different.
666 	 *
667 	 * Params:
668 	 *     icon = the #GIcon to look up
669 	 *     size = desired icon size
670 	 *     flags = flags modifying the behavior of the icon lookup
671 	 *
672 	 * Return: a #GtkIconInfo containing
673 	 *     information about the icon, or %NULL if the icon wasn’t
674 	 *     found. Unref with g_object_unref()
675 	 *
676 	 * Since: 2.14
677 	 */
678 	public IconInfo lookupByGicon(IconIF icon, int size, GtkIconLookupFlags flags)
679 	{
680 		auto p = gtk_icon_theme_lookup_by_gicon(gtkIconTheme, (icon is null) ? null : icon.getIconStruct(), size, flags);
681 		
682 		if(p is null)
683 		{
684 			return null;
685 		}
686 		
687 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
688 	}
689 
690 	/**
691 	 * Looks up an icon and returns a #GtkIconInfo containing information
692 	 * such as the filename of the icon. The icon can then be rendered into
693 	 * a pixbuf using gtk_icon_info_load_icon().
694 	 *
695 	 * Params:
696 	 *     icon = the #GIcon to look up
697 	 *     size = desired icon size
698 	 *     scale = the desired scale
699 	 *     flags = flags modifying the behavior of the icon lookup
700 	 *
701 	 * Return: a #GtkIconInfo containing
702 	 *     information about the icon, or %NULL if the icon wasn’t
703 	 *     found. Unref with g_object_unref()
704 	 *
705 	 * Since: 3.10
706 	 */
707 	public IconInfo lookupByGiconForScale(IconIF icon, int size, int scale, GtkIconLookupFlags flags)
708 	{
709 		auto p = gtk_icon_theme_lookup_by_gicon_for_scale(gtkIconTheme, (icon is null) ? null : icon.getIconStruct(), size, scale, flags);
710 		
711 		if(p is null)
712 		{
713 			return null;
714 		}
715 		
716 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
717 	}
718 
719 	/**
720 	 * Looks up a named icon and returns a #GtkIconInfo containing
721 	 * information such as the filename of the icon. The icon
722 	 * can then be rendered into a pixbuf using
723 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
724 	 * combines these two steps if all you need is the pixbuf.)
725 	 *
726 	 * When rendering on displays with high pixel densities you should not
727 	 * use a @size multiplied by the scaling factor returned by functions
728 	 * like gdk_window_get_scale_factor(). Instead, you should use
729 	 * gtk_icon_theme_lookup_icon_for_scale(), as the assets loaded
730 	 * for a given scaling factor may be different.
731 	 *
732 	 * Params:
733 	 *     iconName = the name of the icon to lookup
734 	 *     size = desired icon size
735 	 *     flags = flags modifying the behavior of the icon lookup
736 	 *
737 	 * Return: a #GtkIconInfo object
738 	 *     containing information about the icon, or %NULL if the
739 	 *     icon wasn’t found.
740 	 *
741 	 * Since: 2.4
742 	 */
743 	public IconInfo lookupIcon(string iconName, int size, GtkIconLookupFlags flags)
744 	{
745 		auto p = gtk_icon_theme_lookup_icon(gtkIconTheme, Str.toStringz(iconName), size, flags);
746 		
747 		if(p is null)
748 		{
749 			return null;
750 		}
751 		
752 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
753 	}
754 
755 	/**
756 	 * Looks up a named icon for a particular window scale and returns a
757 	 * #GtkIconInfo containing information such as the filename of the
758 	 * icon. The icon can then be rendered into a pixbuf using
759 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines
760 	 * these two steps if all you need is the pixbuf.)
761 	 *
762 	 * Params:
763 	 *     iconName = the name of the icon to lookup
764 	 *     size = desired icon size
765 	 *     scale = the desired scale
766 	 *     flags = flags modifying the behavior of the icon lookup
767 	 *
768 	 * Return: a #GtkIconInfo object
769 	 *     containing information about the icon, or %NULL if the
770 	 *     icon wasn’t found.
771 	 *
772 	 * Since: 3.10
773 	 */
774 	public IconInfo lookupIconForScale(string iconName, int size, int scale, GtkIconLookupFlags flags)
775 	{
776 		auto p = gtk_icon_theme_lookup_icon_for_scale(gtkIconTheme, Str.toStringz(iconName), size, scale, flags);
777 		
778 		if(p is null)
779 		{
780 			return null;
781 		}
782 		
783 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
784 	}
785 
786 	/**
787 	 * Prepends a directory to the search path.
788 	 * See gtk_icon_theme_set_search_path().
789 	 *
790 	 * Params:
791 	 *     path = directory name to prepend to the icon path
792 	 *
793 	 * Since: 2.4
794 	 */
795 	public void prependSearchPath(string path)
796 	{
797 		gtk_icon_theme_prepend_search_path(gtkIconTheme, Str.toStringz(path));
798 	}
799 
800 	/**
801 	 * Checks to see if the icon theme has changed; if it has, any
802 	 * currently cached information is discarded and will be reloaded
803 	 * next time @icon_theme is accessed.
804 	 *
805 	 * Return: %TRUE if the icon theme has changed and needed
806 	 *     to be reloaded.
807 	 *
808 	 * Since: 2.4
809 	 */
810 	public bool rescanIfNeeded()
811 	{
812 		return gtk_icon_theme_rescan_if_needed(gtkIconTheme) != 0;
813 	}
814 
815 	/**
816 	 * Sets the name of the icon theme that the #GtkIconTheme object uses
817 	 * overriding system configuration. This function cannot be called
818 	 * on the icon theme objects returned from gtk_icon_theme_get_default()
819 	 * and gtk_icon_theme_get_for_screen().
820 	 *
821 	 * Params:
822 	 *     themeName = name of icon theme to use instead of
823 	 *         configured theme, or %NULL to unset a previously set custom theme
824 	 *
825 	 * Since: 2.4
826 	 */
827 	public void setCustomTheme(string themeName)
828 	{
829 		gtk_icon_theme_set_custom_theme(gtkIconTheme, Str.toStringz(themeName));
830 	}
831 
832 	/**
833 	 * Sets the screen for an icon theme; the screen is used
834 	 * to track the user’s currently configured icon theme,
835 	 * which might be different for different screens.
836 	 *
837 	 * Params:
838 	 *     screen = a #GdkScreen
839 	 *
840 	 * Since: 2.4
841 	 */
842 	public void setScreen(Screen screen)
843 	{
844 		gtk_icon_theme_set_screen(gtkIconTheme, (screen is null) ? null : screen.getScreenStruct());
845 	}
846 
847 	/**
848 	 * Sets the search path for the icon theme object. When looking
849 	 * for an icon theme, GTK+ will search for a subdirectory of
850 	 * one or more of the directories in @path with the same name
851 	 * as the icon theme containing an index.theme file. (Themes from
852 	 * multiple of the path elements are combined to allow themes to be
853 	 * extended by adding icons in the user’s home directory.)
854 	 *
855 	 * In addition if an icon found isn’t found either in the current
856 	 * icon theme or the default icon theme, and an image file with
857 	 * the right name is found directly in one of the elements of
858 	 * @path, then that image will be used for the icon name.
859 	 * (This is legacy feature, and new icons should be put
860 	 * into the fallback icon theme, which is called hicolor,
861 	 * rather than directly on the icon path.)
862 	 *
863 	 * Params:
864 	 *     path = array of
865 	 *         directories that are searched for icon themes
866 	 *     nElements = number of elements in @path.
867 	 *
868 	 * Since: 2.4
869 	 */
870 	public void setSearchPath(string[] path)
871 	{
872 		gtk_icon_theme_set_search_path(gtkIconTheme, Str.toStringzArray(path), cast(int)path.length);
873 	}
874 
875 	protected class OnChangedDelegateWrapper
876 	{
877 		void delegate(IconTheme) dlg;
878 		gulong handlerId;
879 		ConnectFlags flags;
880 		this(void delegate(IconTheme) dlg, gulong handlerId, ConnectFlags flags)
881 		{
882 			this.dlg = dlg;
883 			this.handlerId = handlerId;
884 			this.flags = flags;
885 		}
886 	}
887 	protected OnChangedDelegateWrapper[] onChangedListeners;
888 
889 	/**
890 	 * Emitted when the current icon theme is switched or GTK+ detects
891 	 * that a change has occurred in the contents of the current
892 	 * icon theme.
893 	 */
894 	gulong addOnChanged(void delegate(IconTheme) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
895 	{
896 		onChangedListeners ~= new OnChangedDelegateWrapper(dlg, 0, connectFlags);
897 		onChangedListeners[onChangedListeners.length - 1].handlerId = Signals.connectData(
898 			this,
899 			"changed",
900 			cast(GCallback)&callBackChanged,
901 			cast(void*)onChangedListeners[onChangedListeners.length - 1],
902 			cast(GClosureNotify)&callBackChangedDestroy,
903 			connectFlags);
904 		return onChangedListeners[onChangedListeners.length - 1].handlerId;
905 	}
906 	
907 	extern(C) static void callBackChanged(GtkIconTheme* iconthemeStruct,OnChangedDelegateWrapper wrapper)
908 	{
909 		wrapper.dlg(wrapper.outer);
910 	}
911 	
912 	extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
913 	{
914 		wrapper.outer.internalRemoveOnChanged(wrapper);
915 	}
916 
917 	protected void internalRemoveOnChanged(OnChangedDelegateWrapper source)
918 	{
919 		foreach(index, wrapper; onChangedListeners)
920 		{
921 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
922 			{
923 				onChangedListeners[index] = null;
924 				onChangedListeners = std.algorithm.remove(onChangedListeners, index);
925 				break;
926 			}
927 		}
928 	}
929 	
930 }