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