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 gio.ListStore; 26 27 private import gio.ListModelIF; 28 private import gio.ListModelT; 29 private import glib.ConstructionException; 30 private import gobject.ObjectG; 31 private import gtkc.gio; 32 public import gtkc.giotypes; 33 34 35 /** 36 * #GListStore is a simple implementation of #GListModel that stores all 37 * items in memory. 38 * 39 * It provides insertions, deletions, and lookups in logarithmic time 40 * with a fast path for the common case of iterating the list linearly. 41 */ 42 public class ListStore : ObjectG, ListModelIF 43 { 44 /** the main Gtk struct */ 45 protected GListStore* gListStore; 46 47 /** Get the main Gtk struct */ 48 public GListStore* getListStoreStruct() 49 { 50 return gListStore; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected override void* getStruct() 55 { 56 return cast(void*)gListStore; 57 } 58 59 protected override void setStruct(GObject* obj) 60 { 61 gListStore = cast(GListStore*)obj; 62 super.setStruct(obj); 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GListStore* gListStore, bool ownedRef = false) 69 { 70 this.gListStore = gListStore; 71 super(cast(GObject*)gListStore, ownedRef); 72 } 73 74 // add the ListModel capabilities 75 mixin ListModelT!(GListStore); 76 77 /** 78 */ 79 80 public static GType getType() 81 { 82 return g_list_store_get_type(); 83 } 84 85 /** 86 * Creates a new #GListStore with items of type @item_type. @item_type 87 * must be a subclass of #GObject. 88 * 89 * Params: 90 * itemType = the #GType of items in the list 91 * 92 * Return: a new #GListStore 93 * 94 * Since: 2.44 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(GType itemType) 99 { 100 auto p = g_list_store_new(itemType); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GListStore*) p, true); 108 } 109 110 /** 111 * Appends @item to @store. @item must be of type #GListStore:item-type. 112 * 113 * This function takes a ref on @item. 114 * 115 * Use g_list_store_splice() to append multiple items at the same time 116 * efficiently. 117 * 118 * Params: 119 * item = the new item 120 * 121 * Since: 2.44 122 */ 123 public void append(void* item) 124 { 125 g_list_store_append(gListStore, item); 126 } 127 128 /** 129 * Inserts @item into @store at @position. @item must be of type 130 * #GListStore:item-type or derived from it. @position must be smaller 131 * than the length of the list, or equal to it to append. 132 * 133 * This function takes a ref on @item. 134 * 135 * Use g_list_store_splice() to insert multiple items at the same time 136 * efficiently. 137 * 138 * Params: 139 * position = the position at which to insert the new item 140 * item = the new item 141 * 142 * Since: 2.44 143 */ 144 public void insert(uint position, void* item) 145 { 146 g_list_store_insert(gListStore, position, item); 147 } 148 149 /** 150 * Inserts @item into @store at a position to be determined by the 151 * @compare_func. 152 * 153 * The list must already be sorted before calling this function or the 154 * result is undefined. Usually you would approach this by only ever 155 * inserting items by way of this function. 156 * 157 * This function takes a ref on @item. 158 * 159 * Params: 160 * item = the new item 161 * compareFunc = pairwise comparison function for sorting 162 * userData = user data for @compare_func 163 * 164 * Return: the position at which @item was inserted 165 * 166 * Since: 2.44 167 */ 168 public uint insertSorted(void* item, GCompareDataFunc compareFunc, void* userData) 169 { 170 return g_list_store_insert_sorted(gListStore, item, compareFunc, userData); 171 } 172 173 /** 174 * Removes the item from @store that is at @position. @position must be 175 * smaller than the current length of the list. 176 * 177 * Use g_list_store_splice() to remove multiple items at the same time 178 * efficiently. 179 * 180 * Params: 181 * position = the position of the item that is to be removed 182 * 183 * Since: 2.44 184 */ 185 public void remove(uint position) 186 { 187 g_list_store_remove(gListStore, position); 188 } 189 190 /** 191 * Removes all items from @store. 192 * 193 * Since: 2.44 194 */ 195 public void removeAll() 196 { 197 g_list_store_remove_all(gListStore); 198 } 199 200 /** 201 * Changes @store by removing @n_removals items and adding @n_additions 202 * items to it. @additions must contain @n_additions items of type 203 * #GListStore:item-type. %NULL is not permitted. 204 * 205 * This function is more efficient than g_list_store_insert() and 206 * g_list_store_remove(), because it only emits 207 * #GListModel::items-changed once for the change. 208 * 209 * This function takes a ref on each item in @additions. 210 * 211 * The parameters @position and @n_removals must be correct (ie: 212 * @position + @n_removals must be less than or equal to the length of 213 * the list at the time this function is called). 214 * 215 * Params: 216 * position = the position at which to make the change 217 * nRemovals = the number of items to remove 218 * additions = the items to add 219 * nAdditions = the number of items to add 220 * 221 * Since: 2.44 222 */ 223 public void splice(uint position, uint nRemovals, void*[] additions) 224 { 225 g_list_store_splice(gListStore, position, nRemovals, additions.ptr, cast(uint)additions.length); 226 } 227 }