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