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 = GtkTreeModelSort.html 27 * outPack = gtk 28 * outFile = TreeModelSort 29 * strct = GtkTreeModelSort 30 * realStrct= 31 * ctorStrct= 32 * clss = TreeModelSort 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - TreeModelIF 40 * - TreeDragSourceIF 41 * - TreeSortableIF 42 * prefixes: 43 * - gtk_tree_model_sort_ 44 * - gtk_ 45 * omit structs: 46 * omit prefixes: 47 * omit code: 48 * omit signals: 49 * imports: 50 * - glib.Str 51 * - gtk.TreeModel 52 * - gtk.TreeModelIF 53 * - gtk.TreePath 54 * - gtk.TreeIter 55 * - gtk.TreeModelT 56 * - gtk.TreeDragSourceT 57 * - gtk.TreeDragSourceIF 58 * - gtk.TreeSortableT 59 * - gtk.TreeSortableIF 60 * structWrap: 61 * - GtkTreeIter* -> TreeIter 62 * - GtkTreeModel* -> TreeModelIF 63 * - GtkTreePath* -> TreePath 64 * module aliases: 65 * local aliases: 66 * overrides: 67 */ 68 69 module gtk.TreeModelSort; 70 71 public import gtkc.gtktypes; 72 73 private import gtkc.gtk; 74 private import glib.ConstructionException; 75 private import gobject.ObjectG; 76 77 78 private import glib.Str; 79 private import gtk.TreeModel; 80 private import gtk.TreeModelIF; 81 private import gtk.TreePath; 82 private import gtk.TreeIter; 83 private import gtk.TreeModelT; 84 private import gtk.TreeDragSourceT; 85 private import gtk.TreeDragSourceIF; 86 private import gtk.TreeSortableT; 87 private import gtk.TreeSortableIF; 88 89 90 91 private import gobject.ObjectG; 92 93 /** 94 * Description 95 * The GtkTreeModelSort is a model which implements the GtkTreeSortable 96 * interface. It does not hold any data itself, but rather is created with 97 * a child model and proxies its data. It has identical column types to 98 * this child model, and the changes in the child are propagated. The 99 * primary purpose of this model is to provide a way to sort a different 100 * model without modifying it. Note that the sort function used by 101 * GtkTreeModelSort is not guaranteed to be stable. 102 * The use of this is best demonstrated through an example. In the 103 * following sample code we create two GtkTreeView widgets each with a 104 * view of the same data. As the model is wrapped here by a 105 * GtkTreeModelSort, the two GtkTreeViews can each sort their 106 * view of the data without affecting the other. By contrast, if we 107 * simply put the same model in each widget, then sorting the first would 108 * sort the second. 109 * $(DDOC_COMMENT example) 110 * To demonstrate how to access the underlying child model from the sort 111 * model, the next example will be a callback for the GtkTreeSelection 112 * "changed" signal. In this callback, we get a string from COLUMN_1 of 113 * the model. We then modify the string, find the same selected row on the 114 * child model, and change the row there. 115 * $(DDOC_COMMENT example) 116 */ 117 public class TreeModelSort : ObjectG, TreeModelIF, TreeDragSourceIF, TreeSortableIF 118 { 119 120 /** the main Gtk struct */ 121 protected GtkTreeModelSort* gtkTreeModelSort; 122 123 124 public GtkTreeModelSort* getTreeModelSortStruct() 125 { 126 return gtkTreeModelSort; 127 } 128 129 130 /** the main Gtk struct as a void* */ 131 protected override void* getStruct() 132 { 133 return cast(void*)gtkTreeModelSort; 134 } 135 136 /** 137 * Sets our main struct and passes it to the parent class 138 */ 139 public this (GtkTreeModelSort* gtkTreeModelSort) 140 { 141 super(cast(GObject*)gtkTreeModelSort); 142 this.gtkTreeModelSort = gtkTreeModelSort; 143 } 144 145 protected override void setStruct(GObject* obj) 146 { 147 super.setStruct(obj); 148 gtkTreeModelSort = cast(GtkTreeModelSort*)obj; 149 } 150 151 // add the TreeModel capabilities 152 mixin TreeModelT!(GtkTreeModelSort); 153 154 // add the TreeDragSource capabilities 155 mixin TreeDragSourceT!(GtkTreeModelSort); 156 157 // add the TreeSortable capabilities 158 mixin TreeSortableT!(GtkTreeModelSort); 159 160 /** 161 */ 162 163 /** 164 * Creates a new GtkTreeModel, with child_model as the child model. 165 * Params: 166 * childModel = A GtkTreeModel 167 * Returns: A new GtkTreeModel. [transfer full] 168 */ 169 public static TreeModelIF newWithModel(TreeModelIF childModel) 170 { 171 // GtkTreeModel * gtk_tree_model_sort_new_with_model (GtkTreeModel *child_model); 172 auto p = gtk_tree_model_sort_new_with_model((childModel is null) ? null : childModel.getTreeModelTStruct()); 173 174 if(p is null) 175 { 176 return null; 177 } 178 179 return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p); 180 } 181 182 /** 183 * Returns the model the GtkTreeModelSort is sorting. 184 * Returns: the "child model" being sorted. [transfer none] 185 */ 186 public TreeModelIF getModel() 187 { 188 // GtkTreeModel * gtk_tree_model_sort_get_model (GtkTreeModelSort *tree_model); 189 auto p = gtk_tree_model_sort_get_model(gtkTreeModelSort); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p); 197 } 198 199 /** 200 * Converts child_path to a path relative to tree_model_sort. That is, 201 * child_path points to a path in the child model. The returned path will 202 * point to the same row in the sorted model. If child_path isn't a valid 203 * path on the child model, then NULL is returned. 204 * Params: 205 * childPath = A GtkTreePath to convert 206 * Returns: A newly allocated GtkTreePath, or NULL 207 */ 208 public TreePath convertChildPathToPath(TreePath childPath) 209 { 210 // GtkTreePath * gtk_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_model_sort, GtkTreePath *child_path); 211 auto p = gtk_tree_model_sort_convert_child_path_to_path(gtkTreeModelSort, (childPath is null) ? null : childPath.getTreePathStruct()); 212 213 if(p is null) 214 { 215 return null; 216 } 217 218 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p); 219 } 220 221 /** 222 * Sets sort_iter to point to the row in tree_model_sort that corresponds to 223 * the row pointed at by child_iter. If sort_iter was not set, FALSE 224 * is returned. Note: a boolean is only returned since 2.14. 225 * Params: 226 * sortIter = An uninitialized GtkTreeIter. [out] 227 * childIter = A valid GtkTreeIter pointing to a row on the child model 228 * Returns: TRUE, if sort_iter was set, i.e. if sort_iter is a valid iterator pointer to a visible row in the child model. 229 */ 230 public int convertChildIterToIter(TreeIter sortIter, TreeIter childIter) 231 { 232 // gboolean gtk_tree_model_sort_convert_child_iter_to_iter (GtkTreeModelSort *tree_model_sort, GtkTreeIter *sort_iter, GtkTreeIter *child_iter); 233 return gtk_tree_model_sort_convert_child_iter_to_iter(gtkTreeModelSort, (sortIter is null) ? null : sortIter.getTreeIterStruct(), (childIter is null) ? null : childIter.getTreeIterStruct()); 234 } 235 236 /** 237 * Converts sorted_path to a path on the child model of tree_model_sort. 238 * That is, sorted_path points to a location in tree_model_sort. The 239 * returned path will point to the same location in the model not being 240 * sorted. If sorted_path does not point to a location in the child model, 241 * NULL is returned. 242 * Params: 243 * sortedPath = A GtkTreePath to convert 244 * Returns: A newly allocated GtkTreePath, or NULL 245 */ 246 public TreePath convertPathToChildPath(TreePath sortedPath) 247 { 248 // GtkTreePath * gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sort, GtkTreePath *sorted_path); 249 auto p = gtk_tree_model_sort_convert_path_to_child_path(gtkTreeModelSort, (sortedPath is null) ? null : sortedPath.getTreePathStruct()); 250 251 if(p is null) 252 { 253 return null; 254 } 255 256 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p); 257 } 258 259 /** 260 * Sets child_iter to point to the row pointed to by sorted_iter. 261 * Params: 262 * childIter = An uninitialized GtkTreeIter. [out] 263 * sortedIter = A valid GtkTreeIter pointing to a row on tree_model_sort. 264 */ 265 public void convertIterToChildIter(TreeIter childIter, TreeIter sortedIter) 266 { 267 // void gtk_tree_model_sort_convert_iter_to_child_iter (GtkTreeModelSort *tree_model_sort, GtkTreeIter *child_iter, GtkTreeIter *sorted_iter); 268 gtk_tree_model_sort_convert_iter_to_child_iter(gtkTreeModelSort, (childIter is null) ? null : childIter.getTreeIterStruct(), (sortedIter is null) ? null : sortedIter.getTreeIterStruct()); 269 } 270 271 /** 272 * This resets the default sort function to be in the 'unsorted' state. That 273 * is, it is in the same order as the child model. It will re-sort the model 274 * to be in the same order as the child model only if the GtkTreeModelSort 275 * is in 'unsorted' state. 276 */ 277 public void resetDefaultSortFunc() 278 { 279 // void gtk_tree_model_sort_reset_default_sort_func (GtkTreeModelSort *tree_model_sort); 280 gtk_tree_model_sort_reset_default_sort_func(gtkTreeModelSort); 281 } 282 283 /** 284 * This function should almost never be called. It clears the tree_model_sort 285 * of any cached iterators that haven't been reffed with 286 * gtk_tree_model_ref_node(). This might be useful if the child model being 287 * sorted is static (and doesn't change often) and there has been a lot of 288 * unreffed access to nodes. As a side effect of this function, all unreffed 289 * iters will be invalid. 290 */ 291 public void clearCache() 292 { 293 // void gtk_tree_model_sort_clear_cache (GtkTreeModelSort *tree_model_sort); 294 gtk_tree_model_sort_clear_cache(gtkTreeModelSort); 295 } 296 297 /** 298 * Warning 299 * This function is slow. Only use it for debugging and/or testing purposes. 300 * Checks if the given iter is a valid iter for this GtkTreeModelSort. 301 * Since 2.2 302 * Params: 303 * iter = A GtkTreeIter. 304 * Returns: TRUE if the iter is valid, FALSE if the iter is invalid. 305 */ 306 public int iterIsValid(TreeIter iter) 307 { 308 // gboolean gtk_tree_model_sort_iter_is_valid (GtkTreeModelSort *tree_model_sort, GtkTreeIter *iter); 309 return gtk_tree_model_sort_iter_is_valid(gtkTreeModelSort, (iter is null) ? null : iter.getTreeIterStruct()); 310 } 311 }