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.Emblem;
26 
27 private import gio.IconIF;
28 private import gio.IconT;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * #GEmblem is an implementation of #GIcon that supports
38  * having an emblem, which is an icon with additional properties.
39  * It can than be added to a #GEmblemedIcon.
40  * 
41  * Currently, only metainformation about the emblem's origin is
42  * supported. More may be added in the future.
43  */
44 public class Emblem : ObjectG, IconIF
45 {
46 	/** the main Gtk struct */
47 	protected GEmblem* gEmblem;
48 
49 	/** Get the main Gtk struct */
50 	public GEmblem* getEmblemStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gEmblem;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gEmblem;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gEmblem = cast(GEmblem*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GEmblem* gEmblem, bool ownedRef = false)
73 	{
74 		this.gEmblem = gEmblem;
75 		super(cast(GObject*)gEmblem, ownedRef);
76 	}
77 
78 	// add the Icon capabilities
79 	mixin IconT!(GEmblem);
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return g_emblem_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new emblem for @icon.
90 	 *
91 	 * Params:
92 	 *     icon = a GIcon containing the icon.
93 	 *
94 	 * Returns: a new #GEmblem.
95 	 *
96 	 * Since: 2.18
97 	 *
98 	 * Throws: ConstructionException GTK+ fails to create the object.
99 	 */
100 	public this(IconIF icon)
101 	{
102 		auto p = g_emblem_new((icon is null) ? null : icon.getIconStruct());
103 
104 		if(p is null)
105 		{
106 			throw new ConstructionException("null returned by new");
107 		}
108 
109 		this(cast(GEmblem*) p, true);
110 	}
111 
112 	/**
113 	 * Creates a new emblem for @icon.
114 	 *
115 	 * Params:
116 	 *     icon = a GIcon containing the icon.
117 	 *     origin = a GEmblemOrigin enum defining the emblem's origin
118 	 *
119 	 * Returns: a new #GEmblem.
120 	 *
121 	 * Since: 2.18
122 	 *
123 	 * Throws: ConstructionException GTK+ fails to create the object.
124 	 */
125 	public this(IconIF icon, GEmblemOrigin origin)
126 	{
127 		auto p = g_emblem_new_with_origin((icon is null) ? null : icon.getIconStruct(), origin);
128 
129 		if(p is null)
130 		{
131 			throw new ConstructionException("null returned by new_with_origin");
132 		}
133 
134 		this(cast(GEmblem*) p, true);
135 	}
136 
137 	/**
138 	 * Gives back the icon from @emblem.
139 	 *
140 	 * Returns: a #GIcon. The returned object belongs to
141 	 *     the emblem and should not be modified or freed.
142 	 *
143 	 * Since: 2.18
144 	 */
145 	public IconIF getIcon()
146 	{
147 		auto p = g_emblem_get_icon(gEmblem);
148 
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 
154 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) p);
155 	}
156 
157 	/**
158 	 * Gets the origin of the emblem.
159 	 *
160 	 * Returns: the origin of the emblem
161 	 *
162 	 * Since: 2.18
163 	 */
164 	public GEmblemOrigin getOrigin()
165 	{
166 		return g_emblem_get_origin(gEmblem);
167 	}
168 }