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