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.ListModelIF; 26 27 private import gobject.ObjectG; 28 private import gobject.Signals; 29 public import gtkc.gdktypes; 30 private import gtkc.gio; 31 public import gtkc.giotypes; 32 33 34 /** 35 * #GListModel is an interface that represents a mutable list of 36 * #GObjects. Its main intention is as a model for various widgets in 37 * user interfaces, such as list views, but it can also be used as a 38 * convenient method of returning lists of data, with support for 39 * updates. 40 * 41 * Each object in the list may also report changes in itself via some 42 * mechanism (normally the #GObject::notify signal). Taken together 43 * with the #GListModel::items-changed signal, this provides for a list 44 * that can change its membership, and in which the members can change 45 * their individual properties. 46 * 47 * A good example would be the list of visible wireless network access 48 * points, where each access point can report dynamic properties such as 49 * signal strength. 50 * 51 * It is important to note that the #GListModel itself does not report 52 * changes to the individual items. It only reports changes to the list 53 * membership. If you want to observe changes to the objects themselves 54 * then you need to connect signals to the objects that you are 55 * interested in. 56 * 57 * All items in a #GListModel are of (or derived from) the same type. 58 * g_list_model_get_item_type() returns that type. The type may be an 59 * interface, in which case all objects in the list must implement it. 60 * 61 * The semantics are close to that of an array: 62 * g_list_model_get_length() returns the number of items in the list and 63 * g_list_model_get_item() returns an item at a (0-based) position. In 64 * order to allow implementations to calculate the list length lazily, 65 * you can also iterate over items: starting from 0, repeatedly call 66 * g_list_model_get_item() until it returns %NULL. 67 * 68 * An implementation may create objects lazily, but must take care to 69 * return the same object for a given position until all references to 70 * it are gone. 71 * 72 * On the other side, a consumer is expected only to hold references on 73 * objects that are currently "user visible", in order to faciliate the 74 * maximum level of laziness in the implementation of the list and to 75 * reduce the required number of signal connections at a given time. 76 * 77 * This interface is intended only to be used from a single thread. The 78 * thread in which it is appropriate to use it depends on the particular 79 * implementation, but typically it will be from the thread that owns 80 * the [thread-default main context][g-main-context-push-thread-default] 81 * in effect at the time that the model was created. 82 */ 83 public interface ListModelIF{ 84 /** Get the main Gtk struct */ 85 public GListModel* getListModelStruct(); 86 87 /** the main Gtk struct as a void* */ 88 protected void* getStruct(); 89 90 /** 91 */ 92 93 /** 94 * Get the item at @position. If @position is greater than the number of 95 * items in @list, %NULL is returned. 96 * 97 * %NULL is never returned for an index that is smaller than the length 98 * of the list. See g_list_model_get_n_items(). 99 * 100 * Params: 101 * position = the position of the item to fetch 102 * 103 * Return: the item at @position. 104 * 105 * Since: 2.44 106 */ 107 public ObjectG getItem(uint position); 108 109 /** 110 * Gets the type of the items in @list. All items returned from 111 * g_list_model_get_type() are of that type or a subtype, or are an 112 * implementation of that interface. 113 * 114 * The item type of a #GListModel can not change during the life of the 115 * model. 116 * 117 * Return: the #GType of the items contained in @list. 118 * 119 * Since: 2.44 120 */ 121 public GType getItemType(); 122 123 /** 124 * Gets the number of items in @list. 125 * 126 * Depending on the model implementation, calling this function may be 127 * less efficient than iterating the list with increasing values for 128 * @position until g_list_model_get_item() returns %NULL. 129 * 130 * Return: the number of items in @list. 131 * 132 * Since: 2.44 133 */ 134 public uint getNItems(); 135 136 /** 137 * Get the item at @position. If @position is greater than the number of 138 * items in @list, %NULL is returned. 139 * 140 * %NULL is never returned for an index that is smaller than the length 141 * of the list. See g_list_model_get_n_items(). 142 * 143 * Params: 144 * position = the position of the item to fetch 145 * 146 * Return: the object at @position. 147 * 148 * Since: 2.44 149 */ 150 public ObjectG getObject(uint position); 151 152 /** 153 * Emits the #GListModel::items-changed signal on @list. 154 * 155 * This function should only be called by classes implementing 156 * #GListModel. It has to be called after the internal representation 157 * of @list has been updated, because handlers connected to this signal 158 * might query the new state of the list. 159 * 160 * Implementations must only make changes to the model (as visible to 161 * its consumer) in places that will not cause problems for that 162 * consumer. For models that are driven directly by a write API (such 163 * as #GListStore), changes can be reported in response to uses of that 164 * API. For models that represent remote data, changes should only be 165 * made from a fresh mainloop dispatch. It is particularly not 166 * permitted to make changes in response to a call to the #GListModel 167 * consumer API. 168 * 169 * Stated another way: in general, it is assumed that code making a 170 * series of accesses to the model via the API, without returning to the 171 * mainloop, and without calling other code, will continue to view the 172 * same contents of the model. 173 * 174 * Params: 175 * position = the position at which @list changed 176 * removed = the number of items removed 177 * added = the number of items added 178 * 179 * Since: 2.44 180 */ 181 public void itemsChanged(uint position, uint removed, uint added); 182 @property void delegate(uint, uint, uint, ListModelIF)[] onItemsChangedListeners(); 183 /** 184 * This signal is emitted whenever items were added or removed to 185 * @list. At @position, @removed items were removed and @added items 186 * were added in their place. 187 * 188 * Params: 189 * position = the position at which @list changed 190 * removed = the number of items removed 191 * added = the number of items added 192 * 193 * Since: 2.44 194 */ 195 void addOnItemsChanged(void delegate(uint, uint, uint, ListModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 196 197 }