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 gobject.TypeInterface;
26 
27 private import gobject.ObjectG;
28 private import gobject.TypeClass;
29 private import gobject.TypePluginIF;
30 private import gobject.c.functions;
31 public  import gobject.c.types;
32 public  import gtkc.gobjecttypes;
33 
34 
35 /**
36  * An opaque structure used as the base of all interface types.
37  */
38 public class TypeInterface
39 {
40 	/** the main Gtk struct */
41 	protected GTypeInterface* gTypeInterface;
42 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public GTypeInterface* getTypeInterfaceStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gTypeInterface;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)gTypeInterface;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GTypeInterface* gTypeInterface, bool ownedRef = false)
62 	{
63 		this.gTypeInterface = gTypeInterface;
64 		this.ownedRef = ownedRef;
65 	}
66 
67 
68 	/**
69 	 * Returns the corresponding #GTypeInterface structure of the parent type
70 	 * of the instance type to which @g_iface belongs. This is useful when
71 	 * deriving the implementation of an interface from the parent type and
72 	 * then possibly overriding some methods.
73 	 *
74 	 * Returns: the
75 	 *     corresponding #GTypeInterface structure of the parent type of the
76 	 *     instance type to which @g_iface belongs, or %NULL if the parent
77 	 *     type doesn't conform to the interface
78 	 */
79 	public TypeInterface peekParent()
80 	{
81 		auto __p = g_type_interface_peek_parent(gTypeInterface);
82 
83 		if(__p is null)
84 		{
85 			return null;
86 		}
87 
88 		return ObjectG.getDObject!(TypeInterface)(cast(GTypeInterface*) __p);
89 	}
90 
91 	/**
92 	 * Adds @prerequisite_type to the list of prerequisites of @interface_type.
93 	 * This means that any type implementing @interface_type must also implement
94 	 * @prerequisite_type. Prerequisites can be thought of as an alternative to
95 	 * interface derivation (which GType doesn't support). An interface can have
96 	 * at most one instantiatable prerequisite type.
97 	 *
98 	 * Params:
99 	 *     interfaceType = #GType value of an interface type
100 	 *     prerequisiteType = #GType value of an interface or instantiatable type
101 	 */
102 	public static void addPrerequisite(GType interfaceType, GType prerequisiteType)
103 	{
104 		g_type_interface_add_prerequisite(interfaceType, prerequisiteType);
105 	}
106 
107 	/**
108 	 * Returns the #GTypePlugin structure for the dynamic interface
109 	 * @interface_type which has been added to @instance_type, or %NULL
110 	 * if @interface_type has not been added to @instance_type or does
111 	 * not have a #GTypePlugin structure. See g_type_add_interface_dynamic().
112 	 *
113 	 * Params:
114 	 *     instanceType = #GType of an instantiatable type
115 	 *     interfaceType = #GType of an interface type
116 	 *
117 	 * Returns: the #GTypePlugin for the dynamic
118 	 *     interface @interface_type of @instance_type
119 	 */
120 	public static TypePluginIF getPlugin(GType instanceType, GType interfaceType)
121 	{
122 		auto __p = g_type_interface_get_plugin(instanceType, interfaceType);
123 
124 		if(__p is null)
125 		{
126 			return null;
127 		}
128 
129 		return ObjectG.getDObject!(TypePluginIF)(cast(GTypePlugin*) __p);
130 	}
131 
132 	/**
133 	 * Returns the #GTypeInterface structure of an interface to which the
134 	 * passed in class conforms.
135 	 *
136 	 * Params:
137 	 *     instanceClass = a #GTypeClass structure
138 	 *     ifaceType = an interface ID which this class conforms to
139 	 *
140 	 * Returns: the #GTypeInterface
141 	 *     structure of @iface_type if implemented by @instance_class, %NULL
142 	 *     otherwise
143 	 */
144 	public static TypeInterface peek(TypeClass instanceClass, GType ifaceType)
145 	{
146 		auto __p = g_type_interface_peek((instanceClass is null) ? null : instanceClass.getTypeClassStruct(), ifaceType);
147 
148 		if(__p is null)
149 		{
150 			return null;
151 		}
152 
153 		return ObjectG.getDObject!(TypeInterface)(cast(GTypeInterface*) __p);
154 	}
155 
156 	/**
157 	 * Returns the prerequisites of an interfaces type.
158 	 *
159 	 * Params:
160 	 *     interfaceType = an interface type
161 	 *
162 	 * Returns: a
163 	 *     newly-allocated zero-terminated array of #GType containing
164 	 *     the prerequisites of @interface_type
165 	 *
166 	 * Since: 2.2
167 	 */
168 	public static GType[] prerequisites(GType interfaceType)
169 	{
170 		uint nPrerequisites;
171 
172 		auto __p = g_type_interface_prerequisites(interfaceType, &nPrerequisites);
173 
174 		return __p[0 .. nPrerequisites];
175 	}
176 }