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