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