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