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