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 * Conversion parameters: 26 * inFile = 27 * outPack = gtk 28 * outFile = TreeModel 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * omit structs: 41 * omit prefixes: 42 * omit code: 43 * omit signals: 44 * imports: 45 * - glib.Str 46 * - gobject.Type 47 * - gobject.ObjectG 48 * - gobject.Signals 49 * - gobject.Value 50 * - gtk.TreeIter 51 * - gtk.TreePath 52 * - gtk.TreeModelT 53 * - gtk.TreeModelIF 54 * - gtkc.gobject 55 * - gtkc.Loader 56 * - gtkc.paths 57 * structWrap: 58 * module aliases: 59 * local aliases: 60 * overrides: 61 */ 62 63 module gtk.TreeModel; 64 65 public import gtkc.gtktypes; 66 67 private import gtkc.gtk; 68 private import glib.ConstructionException; 69 private import gobject.ObjectG; 70 71 72 private import glib.Str; 73 private import gobject.Type; 74 private import gobject.ObjectG; 75 private import gobject.Signals; 76 private import gobject.Value; 77 private import gtk.TreeIter; 78 private import gtk.TreePath; 79 private import gtk.TreeModelT; 80 private import gtk.TreeModelIF; 81 private import gtkc.gobject; 82 private import gtkc.Loader; 83 private import gtkc.paths; 84 85 86 87 88 struct CustomTreeModelClass 89 { 90 GObjectClass parentClass; 91 } 92 93 //We need this function for the interface implementation. 94 extern(C) GType function() c_gtk_tree_model_get_type; 95 alias c_gtk_tree_model_get_type gtk_tree_model_get_type; 96 97 /** 98 */ 99 public class TreeModel : ObjectG, TreeModelIF 100 { 101 static GObjectClass* parentClass = null; 102 103 mixin( _shared ~ "static this() 104 { 105 Linker.link(gtk_tree_model_get_type, \"gtk_tree_model_get_type\", LIBRARY.GTK); 106 }"); 107 108 // Minimal implementation. 109 mixin TreeModelT!(GtkTreeModel); 110 111 /** the main Gtk struct as a void* */ 112 protected override void* getStruct() 113 { 114 return cast(void*)gtkTreeModel; 115 } 116 117 public this () 118 { 119 auto p = super(customTreeModelgetType(), null); 120 gtkTreeModel = cast(GtkTreeModel*) p.getObjectGStruct(); 121 122 setDataFull("customTreeModel", cast(void*)this, cast(GDestroyNotify)&destroyNotify); 123 } 124 125 /** 126 * Sets our main struct and passes it to the parent class 127 */ 128 public this (GtkTreeModel* gtkTreeModel) 129 { 130 super(cast(GObject*)gtkTreeModel); 131 this.gtkTreeModel = gtkTreeModel; 132 } 133 134 135 extern(C) 136 { 137 /* 138 * here we register our new type and its interfaces 139 * with the type system. If you want to implement 140 * additional interfaces like GtkTreeSortable, you 141 * will need to do it here. 142 */ 143 144 static GType customTreeModelgetType() 145 { 146 GType customTreeModelType = Type.fromName("CustomTreeModel"); 147 148 /* Some boilerplate type registration stuff */ 149 if (customTreeModelType == GType.INVALID) 150 { 151 GTypeInfo customTreeModelInfo = 152 { 153 CustomTreeModelClass.sizeof, /* class size */ 154 null, /* base_init */ 155 null, /* base_finalize */ 156 cast(GClassInitFunc) &customTreeModelClassInit,/* class init function */ 157 null, /* class finalize */ 158 null, /* class_data */ 159 GObject.sizeof, /* instance size */ 160 0, /* n_preallocs */ 161 //cast(GInstanceInitFunc) &customTreeModelInit /* instance init */ 162 null 163 }; 164 GInterfaceInfo treeModelInfo = 165 { 166 cast(GInterfaceInitFunc) &customTreeModelInit, 167 null, 168 null 169 }; 170 171 /* First register the new derived type with the GObject type system */ 172 customTreeModelType = Type.registerStatic (GType.OBJECT, "CustomTreeModel", 173 &customTreeModelInfo, cast(GTypeFlags)0); 174 175 /* Now register our GtkTreeModel interface with the type system */ 176 Type.addInterfaceStatic (customTreeModelType, gtk_tree_model_get_type() /*GTK_TYPE_TREE_MODEL*/, &treeModelInfo); 177 } 178 179 return customTreeModelType; 180 } 181 182 /* 183 * boilerplate GObject/GType stuff. 184 * Init callback for the type system, 185 * called once when our new class is created. 186 */ 187 188 static void customTreeModelClassInit (void* klass) 189 { 190 GObjectClass* objectClass; 191 192 parentClass = cast(GObjectClass*) Type.classPeekParent(klass); 193 objectClass = cast(GObjectClass*) klass; 194 195 objectClass.finalize = &customTreeModelFinalize; 196 } 197 198 /* 199 * init callback for the interface registration 200 * in customTreeModelGetType. Here we override 201 * the GtkTreeModel interface functions that 202 * we implement. 203 */ 204 205 static void customTreeModelInit (GtkTreeModelIface *iface) 206 { 207 iface.getFlags = &customTreeModelGetFlags; 208 iface.getNColumns = &customTreeModelGetNColumns; 209 iface.getColumnType = &customTreeModelGetColumnType; 210 iface.getIter = &customTreeModelGetIter; 211 iface.getPath = &customTreeModelGetPath; 212 iface.getValue = &customTreeModelGetValue; 213 iface.iterNext = &customTreeModelIterNext; 214 iface.iterChildren = &customTreeModelIterChildren; 215 iface.iterHasChild = &customTreeModelIterHasChild; 216 iface.iterNChildren = &customTreeModelIterNChildren; 217 iface.iterNthChild = &customTreeModelIterNthChild; 218 iface.iterParent = &customTreeModelIterParent; 219 } 220 221 /* 222 * this is called just before a custom list is 223 * destroyed. Free dynamically allocated memory here. 224 */ 225 226 static void customTreeModelFinalize (GObject *object) 227 { 228 /* must chain up - finalize parent */ 229 parentClass.finalize(object); 230 } 231 232 static GtkTreeModelFlags customTreeModelGetFlags(GtkTreeModel *tree_model) 233 { 234 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 235 236 return tm.getFlags(); 237 } 238 239 static int customTreeModelGetNColumns(GtkTreeModel *tree_model) 240 { 241 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 242 243 return tm.getNColumns(); 244 } 245 246 static GType customTreeModelGetColumnType(GtkTreeModel *tree_model, int index) 247 { 248 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 249 250 return tm.getColumnType(index); 251 } 252 253 static gboolean customTreeModelGetIter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path) 254 { 255 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 256 257 return tm.getIter(ObjectG.getDObject!(TreeIter)(iter), ObjectG.getDObject!(TreePath)(gtk_tree_path_copy(path))); 258 } 259 260 static GtkTreePath* customTreeModelGetPath(GtkTreeModel *tree_model, GtkTreeIter *iter) 261 { 262 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 263 TreePath path = tm.getPath(ObjectG.getDObject!(TreeIter)(iter)); 264 265 return (path is null) ? null : gtk_tree_path_copy(path.getTreePathStruct()); 266 } 267 268 static void customTreeModelGetValue(GtkTreeModel *tree_model, GtkTreeIter *iter, int column, GValue *value) 269 { 270 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 271 272 tm.getValue(ObjectG.getDObject!(TreeIter)(iter), column, ObjectG.getDObject!(Value)(value)); 273 } 274 275 static gboolean customTreeModelIterNext(GtkTreeModel *tree_model, GtkTreeIter *iter) 276 { 277 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 278 279 return tm.iterNext(ObjectG.getDObject!(TreeIter)(iter)); 280 } 281 282 static gboolean customTreeModelIterChildren(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent) 283 { 284 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 285 286 return tm.iterChildren(ObjectG.getDObject!(TreeIter)(iter), ObjectG.getDObject!(TreeIter)(parent)); 287 } 288 289 static gboolean customTreeModelIterHasChild(GtkTreeModel *tree_model, GtkTreeIter *iter) 290 { 291 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 292 293 return tm.iterHasChild(ObjectG.getDObject!(TreeIter)(iter)); 294 } 295 296 static int customTreeModelIterNChildren(GtkTreeModel *tree_model, GtkTreeIter *iter) 297 { 298 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 299 300 return tm.iterNChildren(ObjectG.getDObject!(TreeIter)(iter)); 301 } 302 303 static gboolean customTreeModelIterNthChild(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, int n) 304 { 305 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 306 307 return tm.iterNthChild(ObjectG.getDObject!(TreeIter)(iter), ObjectG.getDObject!(TreeIter)(parent), n); 308 } 309 310 static gboolean customTreeModelIterParent(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child) 311 { 312 auto tm = ObjectG.getDObject!(TreeModel)(tree_model); 313 314 return tm.iterParent(ObjectG.getDObject!(TreeIter)(iter), ObjectG.getDObject!(TreeIter)(child)); 315 } 316 } 317 } 318 319 /** 320 */ 321