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