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 gtkc.gtk;
41 public  import gtkc.gtktypes;
42 private import std.algorithm;
43 
44 
45 /**
46  * #GtkIconTheme provides a facility for looking up icons by name
47  * and size. The main reason for using a name rather than simply
48  * providing a filename is to allow different icons to be used
49  * depending on what “icon theme” is selected
50  * by the user. The operation of icon themes on Linux and Unix
51  * follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
52  * There is a fallback icon theme, named `hicolor`, where applications
53  * should install their icons, but additional icon themes can be installed
54  * as operating system vendors and users choose.
55  * 
56  * Named icons are similar to the deprecated [Stock Items][gtkstock],
57  * and the distinction between the two may be a bit confusing.
58  * A few things to keep in mind:
59  * 
60  * - Stock images usually are used in conjunction with
61  * [Stock Items][gtkstock], such as %GTK_STOCK_OK or
62  * %GTK_STOCK_OPEN. Named icons are easier to set up and therefore
63  * are more useful for new icons that an application wants to
64  * add, such as application icons or window icons.
65  * 
66  * - Stock images can only be loaded at the symbolic sizes defined
67  * by the #GtkIconSize enumeration, or by custom sizes defined
68  * by gtk_icon_size_register(), while named icons are more flexible
69  * and any pixel size can be specified.
70  * 
71  * - Because stock images are closely tied to stock items, and thus
72  * to actions in the user interface, stock images may come in
73  * multiple variants for different widget states or writing
74  * directions.
75  * 
76  * A good rule of thumb is that if there is a stock image for what
77  * you want to use, use it, otherwise use a named icon. It turns
78  * out that internally stock images are generally defined in
79  * terms of one or more named icons. (An example of the
80  * more than one case is icons that depend on writing direction;
81  * %GTK_STOCK_GO_FORWARD uses the two themed icons
82  * “gtk-stock-go-forward-ltr” and “gtk-stock-go-forward-rtl”.)
83  * 
84  * In many cases, named themes are used indirectly, via #GtkImage
85  * or stock items, rather than directly, but looking up icons
86  * directly is also simple. The #GtkIconTheme object acts
87  * as a database of all the icons in the current theme. You
88  * can create new #GtkIconTheme objects, but it’s much more
89  * efficient to use the standard icon theme for the #GdkScreen
90  * so that the icon information is shared with other people
91  * looking up icons.
92  * |[<!-- language="C" -->
93  * GError *error = NULL;
94  * GtkIconTheme *icon_theme;
95  * GdkPixbuf *pixbuf;
96  * 
97  * icon_theme = gtk_icon_theme_get_default ();
98  * pixbuf = gtk_icon_theme_load_icon (icon_theme,
99  * "my-icon-name", // icon name
100  * 48, // icon size
101  * 0,  // flags
102  * &error);
103  * if (!pixbuf)
104  * {
105  * g_warning ("Couldn’t load icon: %s", error->message);
106  * g_error_free (error);
107  * }
108  * else
109  * {
110  * // Use the pixbuf
111  * g_object_unref (pixbuf);
112  * }
113  * ]|
114  */
115 public class IconTheme : ObjectG
116 {
117 	/** the main Gtk struct */
118 	protected GtkIconTheme* gtkIconTheme;
119 
120 	/** Get the main Gtk struct */
121 	public GtkIconTheme* getIconThemeStruct(bool transferOwnership = false)
122 	{
123 		if (transferOwnership)
124 			ownedRef = false;
125 		return gtkIconTheme;
126 	}
127 
128 	/** the main Gtk struct as a void* */
129 	protected override void* getStruct()
130 	{
131 		return cast(void*)gtkIconTheme;
132 	}
133 
134 	protected override void setStruct(GObject* obj)
135 	{
136 		gtkIconTheme = cast(GtkIconTheme*)obj;
137 		super.setStruct(obj);
138 	}
139 
140 	/**
141 	 * Sets our main struct and passes it to the parent class.
142 	 */
143 	public this (GtkIconTheme* gtkIconTheme, bool ownedRef = false)
144 	{
145 		this.gtkIconTheme = gtkIconTheme;
146 		super(cast(GObject*)gtkIconTheme, ownedRef);
147 	}
148 
149 
150 	/** */
151 	public static GType getType()
152 	{
153 		return gtk_icon_theme_get_type();
154 	}
155 
156 	/**
157 	 * Creates a new icon theme object. Icon theme objects are used
158 	 * to lookup up an icon by name in a particular icon theme.
159 	 * Usually, you’ll want to use gtk_icon_theme_get_default()
160 	 * or gtk_icon_theme_get_for_screen() rather than creating
161 	 * a new icon theme object for scratch.
162 	 *
163 	 * Returns: the newly created #GtkIconTheme object.
164 	 *
165 	 * Since: 2.4
166 	 *
167 	 * Throws: ConstructionException GTK+ fails to create the object.
168 	 */
169 	public this()
170 	{
171 		auto p = gtk_icon_theme_new();
172 		
173 		if(p is null)
174 		{
175 			throw new ConstructionException("null returned by new");
176 		}
177 		
178 		this(cast(GtkIconTheme*) p, true);
179 	}
180 
181 	/**
182 	 * Registers a built-in icon for icon theme lookups. The idea
183 	 * of built-in icons is to allow an application or library
184 	 * that uses themed icons to function requiring files to
185 	 * be present in the file system. For instance, the default
186 	 * images for all of GTK+’s stock icons are registered
187 	 * as built-icons.
188 	 *
189 	 * In general, if you use gtk_icon_theme_add_builtin_icon()
190 	 * you should also install the icon in the icon theme, so
191 	 * that the icon is generally available.
192 	 *
193 	 * This function will generally be used with pixbufs loaded
194 	 * via gdk_pixbuf_new_from_inline().
195 	 *
196 	 * Deprecated: Use gtk_icon_theme_add_resource_path()
197 	 * to add application-specific icons to the icon theme.
198 	 *
199 	 * Params:
200 	 *     iconName = the name of the icon to register
201 	 *     size = the size in pixels at which to register the icon (different
202 	 *         images can be registered for the same icon name at different sizes.)
203 	 *     pixbuf = #GdkPixbuf that contains the image to use for @icon_name
204 	 *
205 	 * Since: 2.4
206 	 */
207 	public static void addBuiltinIcon(string iconName, int size, Pixbuf pixbuf)
208 	{
209 		gtk_icon_theme_add_builtin_icon(Str.toStringz(iconName), size, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
210 	}
211 
212 	/**
213 	 * Gets the icon theme for the default screen. See
214 	 * gtk_icon_theme_get_for_screen().
215 	 *
216 	 * Returns: A unique #GtkIconTheme associated with
217 	 *     the default screen. This icon theme is associated with
218 	 *     the screen and can be used as long as the screen
219 	 *     is open. Do not ref or unref it.
220 	 *
221 	 * Since: 2.4
222 	 */
223 	public static IconTheme getDefault()
224 	{
225 		auto p = gtk_icon_theme_get_default();
226 		
227 		if(p is null)
228 		{
229 			return null;
230 		}
231 		
232 		return ObjectG.getDObject!(IconTheme)(cast(GtkIconTheme*) p);
233 	}
234 
235 	/**
236 	 * Gets the icon theme object associated with @screen; if this
237 	 * function has not previously been called for the given
238 	 * screen, a new icon theme object will be created and
239 	 * associated with the screen. Icon theme objects are
240 	 * fairly expensive to create, so using this function
241 	 * is usually a better choice than calling than gtk_icon_theme_new()
242 	 * and setting the screen yourself; by using this function
243 	 * a single icon theme object will be shared between users.
244 	 *
245 	 * Params:
246 	 *     screen = a #GdkScreen
247 	 *
248 	 * Returns: A unique #GtkIconTheme associated with
249 	 *     the given screen. This icon theme is associated with
250 	 *     the screen and can be used as long as the screen
251 	 *     is open. Do not ref or unref it.
252 	 *
253 	 * Since: 2.4
254 	 */
255 	public static IconTheme getForScreen(Screen screen)
256 	{
257 		auto p = gtk_icon_theme_get_for_screen((screen is null) ? null : screen.getScreenStruct());
258 		
259 		if(p is null)
260 		{
261 			return null;
262 		}
263 		
264 		return ObjectG.getDObject!(IconTheme)(cast(GtkIconTheme*) p);
265 	}
266 
267 	/**
268 	 * Adds a resource path that will be looked at when looking
269 	 * for icons, similar to search paths.
270 	 *
271 	 * This function should be used to make application-specific icons
272 	 * available as part of the icon theme.
273 	 *
274 	 * The resources are considered as part of the hicolor icon theme
275 	 * and must be located in subdirectories that are defined in the
276 	 * hicolor icon theme, such as `@path/16x16/actions/run.png`.
277 	 * Icons that are directly placed in the resource path instead
278 	 * of a subdirectory are also considered as ultimate fallback.
279 	 *
280 	 * Params:
281 	 *     path = a resource path
282 	 *
283 	 * Since: 3.14
284 	 */
285 	public void addResourcePath(string path)
286 	{
287 		gtk_icon_theme_add_resource_path(gtkIconTheme, Str.toStringz(path));
288 	}
289 
290 	/**
291 	 * Appends a directory to the search path.
292 	 * See gtk_icon_theme_set_search_path().
293 	 *
294 	 * Params:
295 	 *     path = directory name to append to the icon path
296 	 *
297 	 * Since: 2.4
298 	 */
299 	public void appendSearchPath(string path)
300 	{
301 		gtk_icon_theme_append_search_path(gtkIconTheme, Str.toStringz(path));
302 	}
303 
304 	/**
305 	 * Looks up a named icon and returns a #GtkIconInfo containing
306 	 * information such as the filename of the icon. The icon
307 	 * can then be rendered into a pixbuf using
308 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
309 	 * combines these two steps if all you need is the pixbuf.)
310 	 *
311 	 * If @icon_names contains more than one name, this function
312 	 * tries them all in the given order before falling back to
313 	 * inherited icon themes.
314 	 *
315 	 * Params:
316 	 *     iconNames = %NULL-terminated array of
317 	 *         icon names to lookup
318 	 *     size = desired icon size
319 	 *     flags = flags modifying the behavior of the icon lookup
320 	 *
321 	 * Returns: a #GtkIconInfo object
322 	 *     containing information about the icon, or %NULL if the icon wasn’t
323 	 *     found.
324 	 *
325 	 * Since: 2.12
326 	 */
327 	public IconInfo chooseIcon(string iconNames, int size, GtkIconLookupFlags flags)
328 	{
329 		auto p = gtk_icon_theme_choose_icon(gtkIconTheme, Str.toStringz(iconNames), size, flags);
330 		
331 		if(p is null)
332 		{
333 			return null;
334 		}
335 		
336 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
337 	}
338 
339 	/**
340 	 * Looks up a named icon for a particular window scale and returns
341 	 * a #GtkIconInfo containing information such as the filename of the
342 	 * icon. The icon can then be rendered into a pixbuf using
343 	 * gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon()
344 	 * combines these two steps if all you need is the pixbuf.)
345 	 *
346 	 * If @icon_names contains more than one name, this function
347 	 * tries them all in the given order before falling back to
348 	 * inherited icon themes.
349 	 *
350 	 * Params:
351 	 *     iconNames = %NULL-terminated
352 	 *         array of icon names to lookup
353 	 *     size = desired icon size
354 	 *     scale = desired scale
355 	 *     flags = flags modifying the behavior of the icon lookup
356 	 *
357 	 * Returns: a #GtkIconInfo object
358 	 *     containing information about the icon, or %NULL if the
359 	 *     icon wasn’t found.
360 	 *
361 	 * Since: 3.10
362 	 */
363 	public IconInfo chooseIconForScale(string iconNames, int size, int scale, GtkIconLookupFlags flags)
364 	{
365 		auto p = gtk_icon_theme_choose_icon_for_scale(gtkIconTheme, Str.toStringz(iconNames), size, scale, flags);
366 		
367 		if(p is null)
368 		{
369 			return null;
370 		}
371 		
372 		return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p, true);
373 	}
374 
375 	/**
376 	 * Gets the name of an icon that is representative of the
377 	 * current theme (for instance, to use when presenting
378 	 * a list of themes to the user.)
379 	 *
380 	 * Returns: the name of an example icon or %NULL.
381 	 *     Free with g_free().
382 	 *
383 	 * Since: 2.4
384 	 */
385 	public string getExampleIconName()
386 	{
387 		auto retStr = gtk_icon_theme_get_example_icon_name(gtkIconTheme);
388 		
389 		scope(exit) Str.freeString(retStr);
390 		return Str.toString(retStr);
391 	}
392 
393 	/**
394 	 * Returns an array of integers describing the sizes at which
395 	 * the icon is available without scaling. A size of -1 means
396 	 * that the icon is available in a scalable format. The array
397 	 * is zero-terminated.
398 	 *
399 	 * Params:
400 	 *     iconName = the name of an icon
401 	 *
402 	 * Returns: An newly
403 	 *     allocated array describing the sizes at which the icon is
404 	 *     available. The array should be freed with g_free() when it is no
405 	 *     longer needed.
406 	 *
407 	 * Since: 2.6
408 	 */
409 	public int[] getIconSizes(string iconName)
410 	{
411 		auto p = gtk_icon_theme_get_icon_sizes(gtkIconTheme, Str.toStringz(iconName));
412 		
413 		return p[0 .. getArrayLength(p)];
414 	}
415 
416 	/**
417 	 * Gets the current search path. See gtk_icon_theme_set_search_path().
418 	 *
419 	 * Params:
420 	 *     path = location to store a list of icon theme path directories or %NULL.
421 	 *         The stored value should be freed with g_strfreev().
422 	 *     nElements = location to store number of elements in @path, or %NULL
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 	 *     nElements = number of elements in @path.
868 	 *
869 	 * Since: 2.4
870 	 */
871 	public void setSearchPath(string[] path)
872 	{
873 		gtk_icon_theme_set_search_path(gtkIconTheme, Str.toStringzArray(path), cast(int)path.length);
874 	}
875 
876 	protected class OnChangedDelegateWrapper
877 	{
878 		static OnChangedDelegateWrapper[] listeners;
879 		void delegate(IconTheme) dlg;
880 		gulong handlerId;
881 		
882 		this(void delegate(IconTheme) dlg)
883 		{
884 			this.dlg = dlg;
885 			this.listeners ~= this;
886 		}
887 		
888 		void remove(OnChangedDelegateWrapper source)
889 		{
890 			foreach(index, wrapper; listeners)
891 			{
892 				if (wrapper.handlerId == source.handlerId)
893 				{
894 					listeners[index] = null;
895 					listeners = std.algorithm.remove(listeners, index);
896 					break;
897 				}
898 			}
899 		}
900 	}
901 
902 	/**
903 	 * Emitted when the current icon theme is switched or GTK+ detects
904 	 * that a change has occurred in the contents of the current
905 	 * icon theme.
906 	 */
907 	gulong addOnChanged(void delegate(IconTheme) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
908 	{
909 		auto wrapper = new OnChangedDelegateWrapper(dlg);
910 		wrapper.handlerId = Signals.connectData(
911 			this,
912 			"changed",
913 			cast(GCallback)&callBackChanged,
914 			cast(void*)wrapper,
915 			cast(GClosureNotify)&callBackChangedDestroy,
916 			connectFlags);
917 		return wrapper.handlerId;
918 	}
919 	
920 	extern(C) static void callBackChanged(GtkIconTheme* iconthemeStruct, OnChangedDelegateWrapper wrapper)
921 	{
922 		wrapper.dlg(wrapper.outer);
923 	}
924 	
925 	extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
926 	{
927 		wrapper.remove(wrapper);
928 	}
929 }