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