source: appstream-generator/build/girepo/gio/ListStore.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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