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 gio.BytesIcon;
26 
27 private import gio.IconIF;
28 private import gio.IconT;
29 private import gio.LoadableIconIF;
30 private import gio.LoadableIconT;
31 private import glib.Bytes;
32 private import glib.ConstructionException;
33 private import gobject.ObjectG;
34 private import gtkc.gio;
35 public  import gtkc.giotypes;
36 
37 
38 /**
39  * #GBytesIcon specifies an image held in memory in a common format (usually
40  * png) to be used as icon.
41  */
42 public class BytesIcon : ObjectG, IconIF, LoadableIconIF
43 {
44 	/** the main Gtk struct */
45 	protected GBytesIcon* gBytesIcon;
46 
47 	/** Get the main Gtk struct */
48 	public GBytesIcon* getBytesIconStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gBytesIcon;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gBytesIcon;
59 	}
60 
61 	protected override void setStruct(GObject* obj)
62 	{
63 		gBytesIcon = cast(GBytesIcon*)obj;
64 		super.setStruct(obj);
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GBytesIcon* gBytesIcon, bool ownedRef = false)
71 	{
72 		this.gBytesIcon = gBytesIcon;
73 		super(cast(GObject*)gBytesIcon, ownedRef);
74 	}
75 
76 	// add the Icon capabilities
77 	mixin IconT!(GBytesIcon);
78 
79 	// add the LoadableIcon capabilities
80 	mixin LoadableIconT!(GBytesIcon);
81 
82 
83 	/** */
84 	public static GType getType()
85 	{
86 		return g_bytes_icon_get_type();
87 	}
88 
89 	/**
90 	 * Creates a new icon for a bytes.
91 	 *
92 	 * Params:
93 	 *     bytes = a #GBytes.
94 	 *
95 	 * Returns: a #GIcon for the given
96 	 *     @bytes, or %NULL on error.
97 	 *
98 	 * Since: 2.38
99 	 *
100 	 * Throws: ConstructionException GTK+ fails to create the object.
101 	 */
102 	public this(Bytes bytes)
103 	{
104 		auto p = g_bytes_icon_new((bytes is null) ? null : bytes.getBytesStruct());
105 		
106 		if(p is null)
107 		{
108 			throw new ConstructionException("null returned by new");
109 		}
110 		
111 		this(cast(GBytesIcon*) p, true);
112 	}
113 
114 	/**
115 	 * Gets the #GBytes associated with the given @icon.
116 	 *
117 	 * Returns: a #GBytes, or %NULL.
118 	 *
119 	 * Since: 2.38
120 	 */
121 	public Bytes getBytes()
122 	{
123 		auto p = g_bytes_icon_get_bytes(gBytesIcon);
124 		
125 		if(p is null)
126 		{
127 			return null;
128 		}
129 		
130 		return new Bytes(cast(GBytes*) p);
131 	}
132 }