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