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.TreeListModel; 26 27 private import gio.ListModelIF; 28 private import gio.ListModelT; 29 private import glib.ConstructionException; 30 private import gobject.ObjectG; 31 private import gtk.TreeListRow; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 35 36 /** 37 * `GtkTreeListModel` is a list model that can create child models on demand. 38 */ 39 public class TreeListModel : ObjectG, ListModelIF 40 { 41 /** the main Gtk struct */ 42 protected GtkTreeListModel* gtkTreeListModel; 43 44 /** Get the main Gtk struct */ 45 public GtkTreeListModel* getTreeListModelStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return gtkTreeListModel; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gtkTreeListModel; 56 } 57 58 /** 59 * Sets our main struct and passes it to the parent class. 60 */ 61 public this (GtkTreeListModel* gtkTreeListModel, bool ownedRef = false) 62 { 63 this.gtkTreeListModel = gtkTreeListModel; 64 super(cast(GObject*)gtkTreeListModel, ownedRef); 65 } 66 67 // add the ListModel capabilities 68 mixin ListModelT!(GtkTreeListModel); 69 70 71 /** */ 72 public static GType getType() 73 { 74 return gtk_tree_list_model_get_type(); 75 } 76 77 /** 78 * Creates a new empty `GtkTreeListModel` displaying @root 79 * with all rows collapsed. 80 * 81 * Params: 82 * root = The `GListModel` to use as root 83 * passthrough = %TRUE to pass through items from the models 84 * autoexpand = %TRUE to set the autoexpand property and expand the @root model 85 * createFunc = Function to call to create the `GListModel` for the children 86 * of an item 87 * userData = Data to pass to @create_func 88 * userDestroy = Function to call to free @user_data 89 * 90 * Returns: a newly created `GtkTreeListModel`. 91 * 92 * Throws: ConstructionException GTK+ fails to create the object. 93 */ 94 public this(ListModelIF root, bool passthrough, bool autoexpand, GtkTreeListModelCreateModelFunc createFunc, void* userData, GDestroyNotify userDestroy) 95 { 96 auto __p = gtk_tree_list_model_new((root is null) ? null : root.getListModelStruct(), passthrough, autoexpand, createFunc, userData, userDestroy); 97 98 if(__p is null) 99 { 100 throw new ConstructionException("null returned by new"); 101 } 102 103 this(cast(GtkTreeListModel*) __p, true); 104 } 105 106 /** 107 * Gets whether the model is set to automatically expand new rows 108 * that get added. 109 * 110 * This can be either rows added by changes to the underlying 111 * models or via [method@Gtk.TreeListRow.set_expanded]. 112 * 113 * Returns: %TRUE if the model is set to autoexpand 114 */ 115 public bool getAutoexpand() 116 { 117 return gtk_tree_list_model_get_autoexpand(gtkTreeListModel) != 0; 118 } 119 120 /** 121 * Gets the row item corresponding to the child at index @position for 122 * @self's root model. 123 * 124 * If @position is greater than the number of children in the root model, 125 * %NULL is returned. 126 * 127 * Do not confuse this function with [method@Gtk.TreeListModel.get_row]. 128 * 129 * Params: 130 * position = position of the child to get 131 * 132 * Returns: the child in @position 133 */ 134 public TreeListRow getChildRow(uint position) 135 { 136 auto __p = gtk_tree_list_model_get_child_row(gtkTreeListModel, position); 137 138 if(__p is null) 139 { 140 return null; 141 } 142 143 return ObjectG.getDObject!(TreeListRow)(cast(GtkTreeListRow*) __p, true); 144 } 145 146 /** 147 * Gets the root model that @self was created with. 148 * 149 * Returns: the root model 150 */ 151 public ListModelIF getModel() 152 { 153 auto __p = gtk_tree_list_model_get_model(gtkTreeListModel); 154 155 if(__p is null) 156 { 157 return null; 158 } 159 160 return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p); 161 } 162 163 /** 164 * Gets whether the model is passing through original row items. 165 * 166 * If this function returns %FALSE, the `GListModel` functions for @self 167 * return custom `GtkTreeListRow` objects. You need to call 168 * [method@Gtk.TreeListRow.get_item] on these objects to get the original 169 * item. 170 * 171 * If %TRUE, the values of the child models are passed through in their 172 * original state. You then need to call [method@Gtk.TreeListModel.get_row] 173 * to get the custom `GtkTreeListRow`s. 174 * 175 * Returns: %TRUE if the model is passing through original row items 176 */ 177 public bool getPassthrough() 178 { 179 return gtk_tree_list_model_get_passthrough(gtkTreeListModel) != 0; 180 } 181 182 /** 183 * Gets the row object for the given row. 184 * 185 * If @position is greater than the number of items in @self, 186 * %NULL is returned. 187 * 188 * The row object can be used to expand and collapse rows as 189 * well as to inspect its position in the tree. See its 190 * documentation for details. 191 * 192 * This row object is persistent and will refer to the current 193 * item as long as the row is present in @self, independent of 194 * other rows being added or removed. 195 * 196 * If @self is set to not be passthrough, this function is 197 * equivalent to calling g_list_model_get_item(). 198 * 199 * Do not confuse this function with [method@Gtk.TreeListModel.get_child_row]. 200 * 201 * Params: 202 * position = the position of the row to fetch 203 * 204 * Returns: The row item 205 */ 206 public TreeListRow getRow(uint position) 207 { 208 auto __p = gtk_tree_list_model_get_row(gtkTreeListModel, position); 209 210 if(__p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(TreeListRow)(cast(GtkTreeListRow*) __p, true); 216 } 217 218 /** 219 * Sets whether the model should autoexpand. 220 * 221 * If set to %TRUE, the model will recursively expand all rows that 222 * get added to the model. This can be either rows added by changes 223 * to the underlying models or via [method@Gtk.TreeListRow.set_expanded]. 224 * 225 * Params: 226 * autoexpand = %TRUE to make the model autoexpand its rows 227 */ 228 public void setAutoexpand(bool autoexpand) 229 { 230 gtk_tree_list_model_set_autoexpand(gtkTreeListModel, autoexpand); 231 } 232 }