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