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  * Conversion parameters:
26  * inFile  = gtk3-Themeable-Stock-Images.html
27  * outPack = gtk
28  * outFile = IconSource
29  * strct   = GtkIconSource
30  * realStrct=
31  * ctorStrct=
32  * clss    = IconSource
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_icon_source_
41  * omit structs:
42  * omit prefixes:
43  * 	- gtk_icon_factory_
44  * 	- gtk_icon_set_
45  * 	- gtk_icon_size_
46  * omit code:
47  * omit signals:
48  * imports:
49  * 	- glib.Str
50  * 	- gdk.Pixbuf
51  * 	- gtkc.paths
52  * 	- gtkc.Loader
53  * structWrap:
54  * 	- GdkPixbuf* -> Pixbuf
55  * 	- GtkIconSource* -> IconSource
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module gtk.IconSource;
62 
63 public  import gtkc.gtktypes;
64 
65 private import gtkc.gtk;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 
70 private import glib.Str;
71 private import gdk.Pixbuf;
72 private import gtkc.paths;
73 private import gtkc.Loader;
74 
75 
76 
77 
78 /**
79  * Browse the available stock icons in the list of stock IDs found here. You can also use
80  * the gtk-demo application for this purpose.
81  *
82  * An icon factory manages a collection of GtkIconSet; a GtkIconSet manages a
83  * set of variants of a particular icon (i.e. a GtkIconSet contains variants for
84  * different sizes and widget states). Icons in an icon factory are named by a
85  * stock ID, which is a simple string identifying the icon. Each GtkStyle has a
86  * list of GtkIconFactory derived from the current theme; those icon factories
87  * are consulted first when searching for an icon. If the theme doesn't set a
88  * particular icon, GTK+ looks for the icon in a list of default icon factories,
89  * maintained by gtk_icon_factory_add_default() and
90  * gtk_icon_factory_remove_default(). Applications with icons should add a default
91  * icon factory with their icons, which will allow themes to override the icons
92  * for the application.
93  *
94  * To display an icon, always use gtk_style_lookup_icon_set() on the widget that
95  * will display the icon, or the convenience function
96  * gtk_widget_render_icon(). These functions take the theme into account when
97  * looking up the icon to use for a given stock ID.
98  *
99  * GtkIconFactory as GtkBuildable
100  *
101  * GtkIconFactory supports a custom <sources> element, which can contain
102  * multiple <source> elements.
103  * The following attributes are allowed:
104  *
105  * stock-id
106  *
107  * The stock id of the source, a string.
108  * This attribute is mandatory
109  *
110  * filename
111  *
112  * The filename of the source, a string.
113  * This attribute is optional
114  *
115  * icon-name
116  *
117  * The icon name for the source, a string.
118  * This attribute is optional.
119  *
120  * size
121  *
122  * Size of the icon, a GtkIconSize enum value.
123  * This attribute is optional.
124  *
125  * direction
126  *
127  * Direction of the source, a GtkTextDirection enum value.
128  * This attribute is optional.
129  *
130  * state
131  *
132  * State of the source, a GtkStateType enum value.
133  * This attribute is optional.
134  *
135  * $(DDOC_COMMENT example)
136  */
137 public class IconSource
138 {
139 	
140 	/** the main Gtk struct */
141 	protected GtkIconSource* gtkIconSource;
142 	
143 	
144 	public GtkIconSource* getIconSourceStruct()
145 	{
146 		return gtkIconSource;
147 	}
148 	
149 	
150 	/** the main Gtk struct as a void* */
151 	protected void* getStruct()
152 	{
153 		return cast(void*)gtkIconSource;
154 	}
155 	
156 	/**
157 	 * Sets our main struct and passes it to the parent class
158 	 */
159 	public this (GtkIconSource* gtkIconSource)
160 	{
161 		this.gtkIconSource = gtkIconSource;
162 	}
163 	
164 	~this ()
165 	{
166 		if (  Linker.isLoaded(LIBRARY.GTK) && gtkIconSource !is null )
167 		{
168 			gtk_icon_source_free(gtkIconSource);
169 		}
170 	}
171 	
172 	/**
173 	 */
174 	
175 	/**
176 	 * Warning
177 	 * gtk_icon_source_copy has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
178 	 * Creates a copy of source; mostly useful for language bindings.
179 	 * Returns: a new GtkIconSource
180 	 */
181 	public IconSource copy()
182 	{
183 		// GtkIconSource * gtk_icon_source_copy (const GtkIconSource *source);
184 		auto p = gtk_icon_source_copy(gtkIconSource);
185 		
186 		if(p is null)
187 		{
188 			return null;
189 		}
190 		
191 		return ObjectG.getDObject!(IconSource)(cast(GtkIconSource*) p);
192 	}
193 	
194 	/**
195 	 * Warning
196 	 * gtk_icon_source_free has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
197 	 * Frees a dynamically-allocated icon source, along with its
198 	 * filename, size, and pixbuf fields if those are not NULL.
199 	 */
200 	public void free()
201 	{
202 		// void gtk_icon_source_free (GtkIconSource *source);
203 		gtk_icon_source_free(gtkIconSource);
204 	}
205 	
206 	/**
207 	 * Warning
208 	 * gtk_icon_source_get_direction has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
209 	 * Obtains the text direction this icon source applies to. The return
210 	 * value is only useful/meaningful if the text direction is not
211 	 * wildcarded.
212 	 * Returns: text direction this source matches
213 	 */
214 	public GtkTextDirection getDirection()
215 	{
216 		// GtkTextDirection gtk_icon_source_get_direction (const GtkIconSource *source);
217 		return gtk_icon_source_get_direction(gtkIconSource);
218 	}
219 	
220 	/**
221 	 * Warning
222 	 * gtk_icon_source_get_direction_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
223 	 * Gets the value set by gtk_icon_source_set_direction_wildcarded().
224 	 * Returns: TRUE if this icon source is a base for any text direction variant
225 	 */
226 	public int getDirectionWildcarded()
227 	{
228 		// gboolean gtk_icon_source_get_direction_wildcarded  (const GtkIconSource *source);
229 		return gtk_icon_source_get_direction_wildcarded(gtkIconSource);
230 	}
231 	
232 	/**
233 	 * Warning
234 	 * gtk_icon_source_get_filename has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
235 	 * Retrieves the source filename, or NULL if none is set. The
236 	 * filename is not a copy, and should not be modified or expected to
237 	 * persist beyond the lifetime of the icon source.
238 	 * Returns: image filename. This string must not be modified or freed. [type filename]
239 	 */
240 	public string getFilename()
241 	{
242 		// const gchar * gtk_icon_source_get_filename (const GtkIconSource *source);
243 		return Str.toString(gtk_icon_source_get_filename(gtkIconSource));
244 	}
245 	
246 	/**
247 	 * Warning
248 	 * gtk_icon_source_get_pixbuf has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
249 	 * Retrieves the source pixbuf, or NULL if none is set.
250 	 * In addition, if a filename source is in use, this
251 	 * function in some cases will return the pixbuf from
252 	 * loaded from the filename. This is, for example, true
253 	 * for the GtkIconSource passed to the GtkStyle::render_icon()
254 	 * virtual function. The reference count on the pixbuf is
255 	 * not incremented.
256 	 * Returns: source pixbuf. [transfer none]
257 	 */
258 	public Pixbuf getPixbuf()
259 	{
260 		// GdkPixbuf * gtk_icon_source_get_pixbuf (const GtkIconSource *source);
261 		auto p = gtk_icon_source_get_pixbuf(gtkIconSource);
262 		
263 		if(p is null)
264 		{
265 			return null;
266 		}
267 		
268 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
269 	}
270 	
271 	/**
272 	 * Warning
273 	 * gtk_icon_source_get_icon_name has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
274 	 * Retrieves the source icon name, or NULL if none is set. The
275 	 * icon_name is not a copy, and should not be modified or expected to
276 	 * persist beyond the lifetime of the icon source.
277 	 * Returns: icon name. This string must not be modified or freed.
278 	 */
279 	public string getIconName()
280 	{
281 		// const gchar * gtk_icon_source_get_icon_name (const GtkIconSource *source);
282 		return Str.toString(gtk_icon_source_get_icon_name(gtkIconSource));
283 	}
284 	
285 	/**
286 	 * Warning
287 	 * gtk_icon_source_get_size has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
288 	 * Obtains the icon size this source applies to. The return value
289 	 * is only useful/meaningful if the icon size is not wildcarded.
290 	 * Returns: icon size this source matches. [type int]
291 	 */
292 	public GtkIconSize getSize()
293 	{
294 		// GtkIconSize gtk_icon_source_get_size (const GtkIconSource *source);
295 		return gtk_icon_source_get_size(gtkIconSource);
296 	}
297 	
298 	/**
299 	 * Warning
300 	 * gtk_icon_source_get_size_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
301 	 * Gets the value set by gtk_icon_source_set_size_wildcarded().
302 	 * Returns: TRUE if this icon source is a base for any icon size variant
303 	 */
304 	public int getSizeWildcarded()
305 	{
306 		// gboolean gtk_icon_source_get_size_wildcarded (const GtkIconSource *source);
307 		return gtk_icon_source_get_size_wildcarded(gtkIconSource);
308 	}
309 	
310 	/**
311 	 * Warning
312 	 * gtk_icon_source_get_state has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
313 	 * Obtains the widget state this icon source applies to. The return
314 	 * value is only useful/meaningful if the widget state is not
315 	 * wildcarded.
316 	 * Returns: widget state this source matches
317 	 */
318 	public GtkStateType getState()
319 	{
320 		// GtkStateType gtk_icon_source_get_state (const GtkIconSource *source);
321 		return gtk_icon_source_get_state(gtkIconSource);
322 	}
323 	
324 	/**
325 	 * Warning
326 	 * gtk_icon_source_get_state_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
327 	 * Gets the value set by gtk_icon_source_set_state_wildcarded().
328 	 * Returns: TRUE if this icon source is a base for any widget state variant
329 	 */
330 	public int getStateWildcarded()
331 	{
332 		// gboolean gtk_icon_source_get_state_wildcarded  (const GtkIconSource *source);
333 		return gtk_icon_source_get_state_wildcarded(gtkIconSource);
334 	}
335 	
336 	/**
337 	 * Warning
338 	 * gtk_icon_source_new has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
339 	 * Creates a new GtkIconSource. A GtkIconSource contains a GdkPixbuf (or
340 	 * image filename) that serves as the base image for one or more of the
341 	 * icons in a GtkIconSet, along with a specification for which icons in the
342 	 * icon set will be based on that pixbuf or image file. An icon set contains
343 	 * a set of icons that represent "the same" logical concept in different states,
344 	 * different global text directions, and different sizes.
345 	 * So for example a web browser's "Back to Previous Page" icon might
346 	 * point in a different direction in Hebrew and in English; it might
347 	 * look different when insensitive; and it might change size depending
348 	 * on toolbar mode (small/large icons). So a single icon set would
349 	 * contain all those variants of the icon. GtkIconSet contains a list
350 	 * of GtkIconSource from which it can derive specific icon variants in
351 	 * the set.
352 	 * In the simplest case, GtkIconSet contains one source pixbuf from
353 	 * which it derives all variants. The convenience function
354 	 * gtk_icon_set_new_from_pixbuf() handles this case; if you only have
355 	 * one source pixbuf, just use that function.
356 	 * If you want to use a different base pixbuf for different icon
357 	 * variants, you create multiple icon sources, mark which variants
358 	 * they'll be used to create, and add them to the icon set with
359 	 * gtk_icon_set_add_source().
360 	 * By default, the icon source has all parameters wildcarded. That is,
361 	 * the icon source will be used as the base icon for any desired text
362 	 * direction, widget state, or icon size.
363 	 * Throws: ConstructionException GTK+ fails to create the object.
364 	 */
365 	public this ()
366 	{
367 		// GtkIconSource * gtk_icon_source_new (void);
368 		auto p = gtk_icon_source_new();
369 		if(p is null)
370 		{
371 			throw new ConstructionException("null returned by gtk_icon_source_new()");
372 		}
373 		this(cast(GtkIconSource*) p);
374 	}
375 	
376 	/**
377 	 * Warning
378 	 * gtk_icon_source_set_direction has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
379 	 * Sets the text direction this icon source is intended to be used
380 	 * with.
381 	 * Setting the text direction on an icon source makes no difference
382 	 * if the text direction is wildcarded. Therefore, you should usually
383 	 * call gtk_icon_source_set_direction_wildcarded() to un-wildcard it
384 	 * in addition to calling this function.
385 	 * Params:
386 	 * direction = text direction this source applies to
387 	 */
388 	public void setDirection(GtkTextDirection direction)
389 	{
390 		// void gtk_icon_source_set_direction (GtkIconSource *source,  GtkTextDirection direction);
391 		gtk_icon_source_set_direction(gtkIconSource, direction);
392 	}
393 	
394 	/**
395 	 * Warning
396 	 * gtk_icon_source_set_direction_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
397 	 * If the text direction is wildcarded, this source can be used
398 	 * as the base image for an icon in any GtkTextDirection.
399 	 * If the text direction is not wildcarded, then the
400 	 * text direction the icon source applies to should be set
401 	 * with gtk_icon_source_set_direction(), and the icon source
402 	 * will only be used with that text direction.
403 	 * GtkIconSet prefers non-wildcarded sources (exact matches) over
404 	 * wildcarded sources, and will use an exact match when possible.
405 	 * Params:
406 	 * setting = TRUE to wildcard the text direction
407 	 */
408 	public void setDirectionWildcarded(int setting)
409 	{
410 		// void gtk_icon_source_set_direction_wildcarded  (GtkIconSource *source,  gboolean setting);
411 		gtk_icon_source_set_direction_wildcarded(gtkIconSource, setting);
412 	}
413 	
414 	/**
415 	 * Warning
416 	 * gtk_icon_source_set_filename has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
417 	 * Sets the name of an image file to use as a base image when creating
418 	 * icon variants for GtkIconSet. The filename must be absolute.
419 	 * Params:
420 	 * filename = image file to use. [type filename]
421 	 */
422 	public void setFilename(string filename)
423 	{
424 		// void gtk_icon_source_set_filename (GtkIconSource *source,  const gchar *filename);
425 		gtk_icon_source_set_filename(gtkIconSource, Str.toStringz(filename));
426 	}
427 	
428 	/**
429 	 * Warning
430 	 * gtk_icon_source_set_pixbuf has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
431 	 * Sets a pixbuf to use as a base image when creating icon variants
432 	 * for GtkIconSet.
433 	 * Params:
434 	 * pixbuf = pixbuf to use as a source
435 	 */
436 	public void setPixbuf(Pixbuf pixbuf)
437 	{
438 		// void gtk_icon_source_set_pixbuf (GtkIconSource *source,  GdkPixbuf *pixbuf);
439 		gtk_icon_source_set_pixbuf(gtkIconSource, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
440 	}
441 	
442 	/**
443 	 * Warning
444 	 * gtk_icon_source_set_icon_name has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
445 	 * Sets the name of an icon to look up in the current icon theme
446 	 * to use as a base image when creating icon variants for GtkIconSet.
447 	 * Params:
448 	 * iconName = name of icon to use. [allow-none]
449 	 */
450 	public void setIconName(string iconName)
451 	{
452 		// void gtk_icon_source_set_icon_name (GtkIconSource *source,  const gchar *icon_name);
453 		gtk_icon_source_set_icon_name(gtkIconSource, Str.toStringz(iconName));
454 	}
455 	
456 	/**
457 	 * Warning
458 	 * gtk_icon_source_set_size has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
459 	 * Sets the icon size this icon source is intended to be used
460 	 * with.
461 	 * Setting the icon size on an icon source makes no difference
462 	 * if the size is wildcarded. Therefore, you should usually
463 	 * call gtk_icon_source_set_size_wildcarded() to un-wildcard it
464 	 * in addition to calling this function.
465 	 * Params:
466 	 * size = icon size this source applies to. [type int]
467 	 */
468 	public void setSize(GtkIconSize size)
469 	{
470 		// void gtk_icon_source_set_size (GtkIconSource *source,  GtkIconSize size);
471 		gtk_icon_source_set_size(gtkIconSource, size);
472 	}
473 	
474 	/**
475 	 * Warning
476 	 * gtk_icon_source_set_size_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
477 	 * If the icon size is wildcarded, this source can be used as the base
478 	 * image for an icon of any size. If the size is not wildcarded, then
479 	 * the size the source applies to should be set with
480 	 * gtk_icon_source_set_size() and the icon source will only be used
481 	 * with that specific size.
482 	 * GtkIconSet prefers non-wildcarded sources (exact matches) over
483 	 * wildcarded sources, and will use an exact match when possible.
484 	 * GtkIconSet will normally scale wildcarded source images to produce
485 	 * an appropriate icon at a given size, but will not change the size
486 	 * of source images that match exactly.
487 	 * Params:
488 	 * setting = TRUE to wildcard the widget state
489 	 */
490 	public void setSizeWildcarded(int setting)
491 	{
492 		// void gtk_icon_source_set_size_wildcarded (GtkIconSource *source,  gboolean setting);
493 		gtk_icon_source_set_size_wildcarded(gtkIconSource, setting);
494 	}
495 	
496 	/**
497 	 * Warning
498 	 * gtk_icon_source_set_state has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
499 	 * Sets the widget state this icon source is intended to be used
500 	 * with.
501 	 * Setting the widget state on an icon source makes no difference
502 	 * if the state is wildcarded. Therefore, you should usually
503 	 * call gtk_icon_source_set_state_wildcarded() to un-wildcard it
504 	 * in addition to calling this function.
505 	 * Params:
506 	 * state = widget state this source applies to
507 	 */
508 	public void setState(GtkStateType state)
509 	{
510 		// void gtk_icon_source_set_state (GtkIconSource *source,  GtkStateType state);
511 		gtk_icon_source_set_state(gtkIconSource, state);
512 	}
513 	
514 	/**
515 	 * Warning
516 	 * gtk_icon_source_set_state_wildcarded has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
517 	 * If the widget state is wildcarded, this source can be used as the
518 	 * base image for an icon in any GtkStateType. If the widget state
519 	 * is not wildcarded, then the state the source applies to should be
520 	 * set with gtk_icon_source_set_state() and the icon source will
521 	 * only be used with that specific state.
522 	 * GtkIconSet prefers non-wildcarded sources (exact matches) over
523 	 * wildcarded sources, and will use an exact match when possible.
524 	 * GtkIconSet will normally transform wildcarded source images to
525 	 * produce an appropriate icon for a given state, for example
526 	 * lightening an image on prelight, but will not modify source images
527 	 * that match exactly.
528 	 * Params:
529 	 * setting = TRUE to wildcard the widget state
530 	 */
531 	public void setStateWildcarded(int setting)
532 	{
533 		// void gtk_icon_source_set_state_wildcarded  (GtkIconSource *source,  gboolean setting);
534 		gtk_icon_source_set_state_wildcarded(gtkIconSource, setting);
535 	}
536 }