alternative to assert
[gtkD.git] / src / gtk / TreeModelSort.d
blobabca674831d4f590986d92a5248970b5dbed854e
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkTreeModelSort.html
26 * outPack = gtk
27 * outFile = TreeModelSort
28 * strct = GtkTreeModelSort
29 * realStrct=
30 * ctorStrct=
31 * clss = TreeModelSort
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_tree_model_sort_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.TreeModel
47 * - gtk.TreePath
48 * - gtk.TreeIter
49 * structWrap:
50 * - GtkTreeIter* -> TreeIter
51 * - GtkTreeModel* -> TreeModel
52 * - GtkTreePath* -> TreePath
53 * local aliases:
56 module gtk.TreeModelSort;
58 private import gtk.gtktypes;
60 private import lib.gtk;
62 private import glib.Str;
63 private import gtk.TreeModel;
64 private import gtk.TreePath;
65 private import gtk.TreeIter;
67 /**
68 * Description
69 * The GtkTreeModelSort is a model which implements the GtkTreeSortable
70 * interface. It does not hold any data itself, but rather is created with
71 * a child model and proxies its data. It has identical column types to
72 * this child model, and the changes in the child are propagated. The
73 * primary purpose of this model is to provide a way to sort a different
74 * model without modifying it. Note that the sort function used by
75 * GtkTreeModelSort is not guaranteed to be stable.
76 * The use of this is best demonstrated through an example. In the
77 * following sample code we create two GtkTreeView widgets each with a
78 * view of the same data. As the model is wrapped here by a
79 * GtkTreeModelSort, the two GtkTreeViews can each sort their
80 * view of the data without affecting the other. By contrast, if we
81 * simply put the same model in each widget, then sorting the first would
82 * sort the second.
83 * Example3.Using a GtkTreeModelSort
84 * {
85 * GtkTreeView *tree_view1;
86 * GtkTreeView *tree_view2;
87 * GtkTreeModel *sort_model1;
88 * GtkTreeModel *sort_model2;
89 * GtkTreeModel *child_model;
90 * /+* get the child model +/
91 * child_model = get_my_model();
92 * /+* Create the first tree +/
93 * sort_model1 = gtk_tree_model_sort_new_with_model (child_model);
94 * tree_view1 = gtk_tree_view_new_with_model (sort_model1);
95 * /+* Create the second tree +/
96 * sort_model2 = gtk_tree_model_sort_new_with_model (child_model);
97 * tree_view2 = gtk_tree_view_new_with_model (sort_model2);
98 * /+* Now we can sort the two models independently +/
99 * gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model1),
100 * COLUMN_1, GTK_SORT_ASCENDING);
101 * gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model2),
102 * COLUMN_1, GTK_SORT_DESCENDING);
104 * To demonstrate how to access the underlying child model from the sort
105 * model, the next example will be a callback for the GtkTreeSelection
106 * "changed" signal. In this callback, we get a string from COLUMN_1 of
107 * the model. We then modify the string, find the same selected row on the
108 * child model, and change the row there.
109 * Example4.Accessing the child model of in a selection changed callback
110 * void
111 * selection_changed (GtkTreeSelection *selection, gpointer data)
113 * GtkTreeModel *sort_model = NULL;
114 * GtkTreeModel *child_model;
115 * GtkTreeIter sort_iter;
116 * GtkTreeIter child_iter;
117 * char *some_data = NULL;
118 * char *modified_data;
119 * /+* Get the current selected row and the model. +/
120 * if (! gtk_tree_selection_get_selected (selection,
121 * sort_model,
122 * sort_iter))
123 * return;
124 * /+* Look up the current value on the selected row and get a new value
125 * * to change it to.
126 * +/
127 * gtk_tree_model_get (GTK_TREE_MODEL (sort_model), sort_iter,
128 * COLUMN_1, some_data,
129 * -1);
130 * modified_data = change_the_data (some_data);
131 * g_free (some_data);
132 * /+* Get an iterator on the child model, instead of the sort model. +/
133 * gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (sort_model),
134 * child_iter,
135 * sort_iter);
136 * /+* Get the child model and change the value of the row. In this
137 * * example, the child model is a GtkListStore. It could be any other
138 * * type of model, though.
139 * +/
140 * child_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model));
141 * gtk_list_store_set (GTK_LIST_STORE (child_model), child_iter,
142 * COLUMN_1, modified_data,
143 * -1);
144 * g_free (modified_data);
147 private import gobject.ObjectG;
148 public class TreeModelSort : ObjectG
151 /** the main Gtk struct */
152 protected GtkTreeModelSort* gtkTreeModelSort;
155 public GtkTreeModelSort* getTreeModelSortStruct()
157 return gtkTreeModelSort;
161 /** the main Gtk struct as a void* */
162 protected void* getStruct()
164 return cast(void*)gtkTreeModelSort;
168 * Sets our main struct and passes it to the parent class
170 public this (GtkTreeModelSort* gtkTreeModelSort)
172 super(cast(GObject*)gtkTreeModelSort);
173 this.gtkTreeModelSort = gtkTreeModelSort;
181 * Creates a new GtkTreeModel, with child_model as the child model.
182 * child_model:
183 * A GtkTreeModel
184 * Returns:
185 * A new GtkTreeModel.
187 public static TreeModel newWithModel(TreeModel childModel)
189 // GtkTreeModel* gtk_tree_model_sort_new_with_model (GtkTreeModel *child_model);
190 return new TreeModel( gtk_tree_model_sort_new_with_model((childModel is null) ? null : childModel.getTreeModelStruct()) );
194 * Returns the model the GtkTreeModelSort is sorting.
195 * tree_model:
196 * a GtkTreeModelSort
197 * Returns:
198 * the "child model" being sorted
200 public TreeModel getModel()
202 // GtkTreeModel* gtk_tree_model_sort_get_model (GtkTreeModelSort *tree_model);
203 return new TreeModel( gtk_tree_model_sort_get_model(gtkTreeModelSort) );
207 * Converts child_path to a path relative to tree_model_sort. That is,
208 * child_path points to a path in the child model. The returned path will
209 * point to the same row in the sorted model. If child_path isn't a valid
210 * path on the child model, then NULL is returned.
211 * tree_model_sort:
212 * A GtkTreeModelSort
213 * child_path:
214 * A GtkTreePath to convert
215 * Returns:
216 * A newly allocated GtkTreePath, or NULL
218 public TreePath convertChildPathToPath(TreePath childPath)
220 // GtkTreePath* gtk_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_model_sort, GtkTreePath *child_path);
221 return new TreePath( gtk_tree_model_sort_convert_child_path_to_path(gtkTreeModelSort, (childPath is null) ? null : childPath.getTreePathStruct()) );
225 * Sets sort_iter to point to the row in tree_model_sort that corresponds to
226 * the row pointed at by child_iter.
227 * tree_model_sort:
228 * A GtkTreeModelSort
229 * sort_iter:
230 * An uninitialized GtkTreeIter.
231 * child_iter:
232 * A valid GtkTreeIter pointing to a row on the child model
234 public void convertChildIterToIter(TreeIter sortIter, TreeIter childIter)
236 // void gtk_tree_model_sort_convert_child_iter_to_iter (GtkTreeModelSort *tree_model_sort, GtkTreeIter *sort_iter, GtkTreeIter *child_iter);
237 gtk_tree_model_sort_convert_child_iter_to_iter(gtkTreeModelSort, (sortIter is null) ? null : sortIter.getTreeIterStruct(), (childIter is null) ? null : childIter.getTreeIterStruct());
241 * Converts sorted_path to a path on the child model of tree_model_sort.
242 * That is, sorted_path points to a location in tree_model_sort. The
243 * returned path will point to the same location in the model not being
244 * sorted. If sorted_path does not point to a location in the child model,
245 * NULL is returned.
246 * tree_model_sort:
247 * A GtkTreeModelSort
248 * sorted_path:
249 * A GtkTreePath to convert
250 * Returns:
251 * A newly allocated GtkTreePath, or NULL
253 public TreePath convertPathToChildPath(TreePath sortedPath)
255 // GtkTreePath* gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sort, GtkTreePath *sorted_path);
256 return new TreePath( gtk_tree_model_sort_convert_path_to_child_path(gtkTreeModelSort, (sortedPath is null) ? null : sortedPath.getTreePathStruct()) );
260 * Sets child_iter to point to the row pointed to by sorted_iter.
261 * tree_model_sort:
262 * A GtkTreeModelSort
263 * child_iter:
264 * An uninitialized GtkTreeIter
265 * sorted_iter:
266 * A valid GtkTreeIter pointing to a row on tree_model_sort.
268 public void convertIterToChildIter(TreeIter childIter, TreeIter sortedIter)
270 // void gtk_tree_model_sort_convert_iter_to_child_iter (GtkTreeModelSort *tree_model_sort, GtkTreeIter *child_iter, GtkTreeIter *sorted_iter);
271 gtk_tree_model_sort_convert_iter_to_child_iter(gtkTreeModelSort, (childIter is null) ? null : childIter.getTreeIterStruct(), (sortedIter is null) ? null : sortedIter.getTreeIterStruct());
275 * This resets the default sort function to be in the 'unsorted' state. That
276 * is, it is in the same order as the child model. It will re-sort the model
277 * to be in the same order as the child model only if the GtkTreeModelSort
278 * is in 'unsorted' state.
279 * tree_model_sort:
280 * A GtkTreeModelSort
282 public void resetDefaultSortFunc()
284 // void gtk_tree_model_sort_reset_default_sort_func (GtkTreeModelSort *tree_model_sort);
285 gtk_tree_model_sort_reset_default_sort_func(gtkTreeModelSort);
289 * This function should almost never be called. It clears the tree_model_sort
290 * of any cached iterators that haven't been reffed with
291 * gtk_tree_model_ref_node(). This might be useful if the child model being
292 * sorted is static (and doesn't change often) and there has been a lot of
293 * unreffed access to nodes. As a side effect of this function, all unreffed
294 * iters will be invalid.
295 * tree_model_sort:
296 * A GtkTreeModelSort
298 public void clearCache()
300 // void gtk_tree_model_sort_clear_cache (GtkTreeModelSort *tree_model_sort);
301 gtk_tree_model_sort_clear_cache(gtkTreeModelSort);
305 * Warning
306 * This function is slow. Only use it for debugging and/or testing purposes.
307 * Checks if the given iter is a valid iter for this GtkTreeModelSort.
308 * tree_model_sort:
309 * A GtkTreeModelSort.
310 * iter:
311 * A GtkTreeIter.
312 * Returns:
313 * TRUE if the iter is valid, FALSE if the iter is invalid.
314 * Since 2.2
315 * Property Details
316 * The "model" property
317 * "model" GtkTreeModel : Read / Write / Construct Only
318 * The model for the TreeModelSort to sort.
319 * See Also
320 * GtkTreeModel, GtkListStore, GtkTreeStore, GtkTreeSortable, GtkTreeModelFilter
322 public int iterIsValid(TreeIter iter)
324 // gboolean gtk_tree_model_sort_iter_is_valid (GtkTreeModelSort *tree_model_sort, GtkTreeIter *iter);
325 return gtk_tree_model_sort_iter_is_valid(gtkTreeModelSort, (iter is null) ? null : iter.getTreeIterStruct());