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