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