Debian Codegraph @

gtk/gtkslicelistmodel.c

raw symbols SCIP
1 /*
2 * Copyright © 2018 Benjamin Otte
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <[email protected]>
18 */
19
20 #include "config.h"cxx . . $ `<file>/build/config.h`/
21
22 #include "gtkslicelistmodel.h"cxx . . $ `<file>/gtk/gtkslicelistmodel.h`/
23 #include "gtksectionmodelprivate.h"cxx . . $ `<file>/gtk/gtksectionmodelprivate.h`/
24
25 #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/
26
27 /**
28 * GtkSliceListModel:
29 *
30 * A list model that presents a slice of another model.
31 *
32 * This is useful when implementing paging by setting the size to the number
33 * of elements per page and updating the offset whenever a different page is
34 * opened.
35 *
36 * `GtkSliceListModel` passes through sections from the underlying model.
37 */
38
39 #define DEFAULT_SIZEcxx . . $ `gtk/gtkslicelistmodel.c:39:9`! 10
40
41 enumcxx . . $ $anonymous_type_7b40dd850355454a_0# {
42 PROP_0cxx . . $ PROP_0.,
43 PROP_ITEM_TYPEcxx . . $ PROP_ITEM_TYPE.,
44 PROP_MODELcxx . . $ PROP_MODEL.,
45 PROP_N_ITEMScxx . . $ PROP_N_ITEMS.,
46 PROP_OFFSETcxx . . $ PROP_OFFSET.,
47 PROP_SIZEcxx . . $ PROP_SIZE.,
48 NUM_PROPERTIEScxx . . $ NUM_PROPERTIES.
49 };
50
51 struct _GtkSliceListModelcxx . . $ _GtkSliceListModel#
52 {
53 GObjectcxx . . $ GObject# parent_instancecxx . . $ _GtkSliceListModel#parent_instance.;
54
55 GListModelcxx . . $ GListModel# *modelcxx . . $ _GtkSliceListModel#model.;
56 guintcxx . . $ guint# offsetcxx . . $ _GtkSliceListModel#offset.;
57 guintcxx . . $ guint# sizecxx . . $ _GtkSliceListModel#size.;
58 };
59
60 struct _GtkSliceListModelClasscxx . . $ _GtkSliceListModelClass#
61 {
62 GObjectClasscxx . . $ GObjectClass# parent_classcxx . . $ _GtkSliceListModelClass#parent_class.;
63 };
64
65 static GParamSpeccxx . . $ GParamSpec# *propertiescxx . . $ properties.[NUM_PROPERTIEScxx . . $ NUM_PROPERTIES.] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, };
66
67 static GTypecxx . . $ GType#
68 gtk_slice_list_model_get_item_typecxx . . $ gtk_slice_list_model_get_item_type(94bfa31565da8ed5). (GListModelcxx . . $ GListModel# *list)
69 {
70 return G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!;
71 }
72
73 static guintcxx . . $ guint#
74 gtk_slice_list_model_get_n_itemscxx . . $ gtk_slice_list_model_get_n_items(43b97f6a983b4be8). (GListModelcxx . . $ GListModel# *list)
75 {
76 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (list);
77 guintcxx . . $ guint# n_items;
78
79 if (self->modelcxx . . $ _GtkSliceListModel#model. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
80 return 0;
81
82 /* XXX: This can be done without calling g_list_model_get_n_items() on the parent model
83 * by checking if model.get_item(offset + size) != NULL */
84 n_items = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (self->modelcxx . . $ _GtkSliceListModel#model.);
85 if (n_items <= self->offsetcxx . . $ _GtkSliceListModel#offset.)
86 return 0;
87
88 n_items -= self->offsetcxx . . $ _GtkSliceListModel#offset.;
89 return MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (n_items, self->size);
90 }
91
92 static gpointercxx . . $ gpointer#
93 gtk_slice_list_model_get_itemcxx . . $ gtk_slice_list_model_get_item(9715a6516b430a30). (GListModelcxx . . $ GListModel# *list,
94 guintcxx . . $ guint# position)
95 {
96 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (list);
97
98 if (self->modelcxx . . $ _GtkSliceListModel#model. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
99 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
100
101 if (position >= self->sizecxx . . $ _GtkSliceListModel#size.)
102 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
103
104 return g_list_model_get_itemcxx . . $ g_list_model_get_item(9715a6516b430a30). (self->modelcxx . . $ _GtkSliceListModel#model., position + self->offsetcxx . . $ _GtkSliceListModel#offset.);
105 }
106
107 static void
108 gtk_slice_list_model_model_initcxx . . $ gtk_slice_list_model_model_init(41b235b28ecdc2f9). (GListModelInterfacecxx . . $ GListModelInterface# *iface)
109 {
110 iface->get_item_typecxx . . $ _GListModelInterface#get_item_type. = gtk_slice_list_model_get_item_typecxx . . $ gtk_slice_list_model_get_item_type(94bfa31565da8ed5).;
111 iface->get_n_itemscxx . . $ _GListModelInterface#get_n_items. = gtk_slice_list_model_get_n_itemscxx . . $ gtk_slice_list_model_get_n_items(43b97f6a983b4be8).;
112 iface->get_itemcxx . . $ _GListModelInterface#get_item. = gtk_slice_list_model_get_itemcxx . . $ gtk_slice_list_model_get_item(9715a6516b430a30).;
113 }
114
115 static void
116 gtk_slice_list_model_get_sectioncxx . . $ gtk_slice_list_model_get_section(cb2d549c16e2156c). (GtkSectionModelcxx . . $ GtkSectionModel# *model,
117 guintcxx . . $ guint# position,
118 guintcxx . . $ guint# *start,
119 guintcxx . . $ guint# *end)
120 {
121 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (model);
122 unsigned int n_items;
123
124 n_items = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
125 if (position >= n_items)
126 {
127 *start = n_items;
128 *end = G_MAXUINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:40:9`!;
129 }
130 else
131 {
132 gtk_list_model_get_sectioncxx . . $ gtk_list_model_get_section(5e24f727c5f81706). (self->modelcxx . . $ _GtkSliceListModel#model., position + self->offsetcxx . . $ _GtkSliceListModel#offset., start, end);
133
134 *start = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (*start, self->offset) - self->offsetcxx . . $ _GtkSliceListModel#offset.;
135 *end = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (*end - self->offset, n_items);
136 }
137 }
138
139 static void
140 gtk_slice_list_model_sections_changed_cbcxx . . $ gtk_slice_list_model_sections_changed_cb(cc438f04dc6e7a13). (GtkSectionModelcxx . . $ GtkSectionModel# *model,
141 unsigned int position,
142 unsigned int n_items,
143 gpointercxx . . $ gpointer# user_data)
144 {
145 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (user_data);
146 unsigned int start = position;
147 unsigned int end = position + n_items;
148 unsigned int size;
149
150 if (end <= self->offsetcxx . . $ _GtkSliceListModel#offset.)
151 return;
152
153 size = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
154
155 end = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (end - self->offset, size);
156
157 if (start <= self->offsetcxx . . $ _GtkSliceListModel#offset.)
158 start = 0;
159 else
160 start = start - self->offsetcxx . . $ _GtkSliceListModel#offset.;
161
162 if (start >= size)
163 return;
164
165 gtk_section_model_sections_changedcxx . . $ gtk_section_model_sections_changed(769754b59bafb6d0). (GTK_SECTION_MODELcxx . . $ GTK_SECTION_MODEL(f2def7259fc93597). (self), start, end - start);
166 }
167
168 static void
169 gtk_slice_list_model_section_model_initcxx . . $ gtk_slice_list_model_section_model_init(fb93d891eef27d66). (GtkSectionModelInterfacecxx . . $ GtkSectionModelInterface# *iface)
170 {
171 iface->get_sectioncxx . . $ _GtkSectionModelInterface#get_section. = gtk_slice_list_model_get_sectioncxx . . $ gtk_slice_list_model_get_section(cb2d549c16e2156c).;
172 }
173
174 G_DEFINE_TYPE_WITH_CODEcxx . . $ `<external>/9567554376676449156/gtype.h:1850:9`! (GtkSliceListModel, gtk_slice_list_model, G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!,
175 G_IMPLEMENT_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2115:9`! (G_TYPE_LIST_MODELcxx . . $ `<external>/10117917155607792737/glistmodel.h:36:9`!, gtk_slice_list_model_model_init)
176 G_IMPLEMENT_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2115:9`! (GTK_TYPE_SECTION_MODELcxx . . $ `gtk/gtksectionmodel.h:30:9`!, gtk_slice_list_model_section_model_init))
177
178
179 static void
180 gtk_slice_list_model_items_changed_cbcxx . . $ gtk_slice_list_model_items_changed_cb(ef6c3b80ab824207). (GListModelcxx . . $ GListModel# *model,
181 guintcxx . . $ guint# position,
182 guintcxx . . $ guint# removed,
183 guintcxx . . $ guint# added,
184 GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
185 {
186 if (position >= self->offsetcxx . . $ _GtkSliceListModel#offset. + self->sizecxx . . $ _GtkSliceListModel#size.)
187 return;
188
189 if (position < self->offsetcxx . . $ _GtkSliceListModel#offset.)
190 {
191 guintcxx . . $ guint# skip = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (removed, added);
192 skip = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (skip, self->offset - position);
193
194 position += skip;
195 removed -= skip;
196 added -= skip;
197 }
198
199 if (removed == added)
200 {
201 guintcxx . . $ guint# changed = removed;
202
203 if (changed == 0)
204 return;
205
206 g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (position >= self->offset);
207 position -= self->offsetcxx . . $ _GtkSliceListModel#offset.;
208 changed = MINcxx . . $ `<external>/12741050725406041920/gmacros.h:978:9`! (changed, self->size - position);
209
210 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), position, changed, changed);
211 }
212 else
213 {
214 guintcxx . . $ guint# n_after, n_before;
215 guintcxx . . $ guint# skip;
216
217 if (position > self->offsetcxx . . $ _GtkSliceListModel#offset.)
218 skip = position - self->offsetcxx . . $ _GtkSliceListModel#offset.;
219 else
220 skip = 0;
221
222 n_after = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (self->modelcxx . . $ _GtkSliceListModel#model.);
223 n_before = n_after - added + removed;
224 n_after = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (n_after, self->offset, self->offset + self->size) - self->offsetcxx . . $ _GtkSliceListModel#offset.;
225 n_before = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (n_before, self->offset, self->offset + self->size) - self->offsetcxx . . $ _GtkSliceListModel#offset.;
226
227 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), skip, n_before - skip, n_after - skip);
228 if (n_before != n_after)
229 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.]);
230 }
231 }
232
233 static void
234 gtk_slice_list_model_set_propertycxx . . $ gtk_slice_list_model_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object,
235 guintcxx . . $ guint# prop_id,
236 const GValuecxx . . $ GValue# *value,
237 GParamSpeccxx . . $ GParamSpec# *pspec)
238 {
239 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (object);
240
241 switch (prop_id)
242 {
243 case PROP_MODELcxx . . $ PROP_MODEL.:
244 gtk_slice_list_model_set_modelcxx . . $ gtk_slice_list_model_set_model(e102378275964259). (self, g_value_get_objectcxx . . $ g_value_get_object(e12dff36056c2cce). (value));
245 break;
246
247 case PROP_OFFSETcxx . . $ PROP_OFFSET.:
248 gtk_slice_list_model_set_offsetcxx . . $ gtk_slice_list_model_set_offset(9ed130d4afdc2fae). (self, g_value_get_uintcxx . . $ g_value_get_uint(1e175b1568bd83e1). (value));
249 break;
250
251 case PROP_SIZEcxx . . $ PROP_SIZE.:
252 gtk_slice_list_model_set_sizecxx . . $ gtk_slice_list_model_set_size(9ed130d4afdc2fae). (self, g_value_get_uintcxx . . $ g_value_get_uint(1e175b1568bd83e1). (value));
253 break;
254
255 default:
256 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec);
257 break;
258 }
259 }
260
261 static void
262 gtk_slice_list_model_get_propertycxx . . $ gtk_slice_list_model_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object,
263 guintcxx . . $ guint# prop_id,
264 GValuecxx . . $ GValue# *value,
265 GParamSpeccxx . . $ GParamSpec# *pspec)
266 {
267 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (object);
268
269 switch (prop_id)
270 {
271 case PROP_ITEM_TYPEcxx . . $ PROP_ITEM_TYPE.:
272 g_value_set_gtypecxx . . $ g_value_set_gtype(235192cae6c1f0e4). (value, gtk_slice_list_model_get_item_typecxx . . $ gtk_slice_list_model_get_item_type(94bfa31565da8ed5). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self)));
273 break;
274
275 case PROP_MODELcxx . . $ PROP_MODEL.:
276 g_value_set_objectcxx . . $ g_value_set_object(e945b84c1e9702f). (value, self->modelcxx . . $ _GtkSliceListModel#model.);
277 break;
278
279 case PROP_N_ITEMScxx . . $ PROP_N_ITEMS.:
280 g_value_set_uintcxx . . $ g_value_set_uint(f81c5c84daf56975). (value, gtk_slice_list_model_get_n_itemscxx . . $ gtk_slice_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self)));
281 break;
282
283 case PROP_OFFSETcxx . . $ PROP_OFFSET.:
284 g_value_set_uintcxx . . $ g_value_set_uint(f81c5c84daf56975). (value, self->offsetcxx . . $ _GtkSliceListModel#offset.);
285 break;
286
287 case PROP_SIZEcxx . . $ PROP_SIZE.:
288 g_value_set_uintcxx . . $ g_value_set_uint(f81c5c84daf56975). (value, self->sizecxx . . $ _GtkSliceListModel#size.);
289 break;
290
291 default:
292 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, prop_id, pspec);
293 break;
294 }
295 }
296
297 static void
298 gtk_slice_list_model_clear_modelcxx . . $ gtk_slice_list_model_clear_model(eb2c221607c9b350). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
299 {
300 if (self->modelcxx . . $ _GtkSliceListModel#model. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
301 return;
302
303 g_signal_handlers_disconnect_by_funccxx . . $ `<external>/15952772511652638895/gsignal.h:629:9`! (self->model, gtk_slice_list_model_sections_changed_cb, self);
304 g_signal_handlers_disconnect_by_funccxx . . $ `<external>/15952772511652638895/gsignal.h:629:9`! (self->model, gtk_slice_list_model_items_changed_cb, self);
305 g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->model);
306 }
307
308 static void
309 gtk_slice_list_model_disposecxx . . $ gtk_slice_list_model_dispose(6087475fa43034d3). (GObjectcxx . . $ GObject# *object)
310 {
311 GtkSliceListModelcxx . . $ GtkSliceListModel# *self = GTK_SLICE_LIST_MODELcxx . . $ GTK_SLICE_LIST_MODEL(116ac665e8a948b1). (object);
312
313 gtk_slice_list_model_clear_modelcxx . . $ gtk_slice_list_model_clear_model(eb2c221607c9b350). (self);
314
315 G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_slice_list_model_parent_class)->disposecxx . . $ _GObjectClass#dispose. (object);
316 };
317
318 static void
319 gtk_slice_list_model_class_initcxx . . $ gtk_slice_list_model_class_init(2a700b737ebcbacc). (GtkSliceListModelClasscxx . . $ GtkSliceListModelClass# *class)
320 {
321 GObjectClasscxx . . $ GObjectClass# *gobject_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (class);
322
323 gobject_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_slice_list_model_set_propertycxx . . $ gtk_slice_list_model_set_property(d7c4bb29f36c0dc4).;
324 gobject_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_slice_list_model_get_propertycxx . . $ gtk_slice_list_model_get_property(cee2c52f22407c66).;
325 gobject_class->disposecxx . . $ _GObjectClass#dispose. = gtk_slice_list_model_disposecxx . . $ gtk_slice_list_model_dispose(6087475fa43034d3).;
326
327 /**
328 * GtkSliceListModel:item-type:
329 *
330 * The type of items. See [[email protected]_item_type].
331 *
332 * Since: 4.8
333 **/
334 propertiescxx . . $ properties.[PROP_ITEM_TYPEcxx . . $ PROP_ITEM_TYPE.] =
335 g_param_spec_gtypecxx . . $ g_param_spec_gtype(faf99966f027a127). ("item-type", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
336 G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!,
337 G_PARAM_READABLEcxx . . $ G_PARAM_READABLE. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!);
338
339 /**
340 * GtkSliceListModel:model:
341 *
342 * Child model to take slice from.
343 */
344 propertiescxx . . $ properties.[PROP_MODELcxx . . $ PROP_MODEL.] =
345 g_param_spec_objectcxx . . $ g_param_spec_object(faf99966f027a127). ("model", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
346 G_TYPE_LIST_MODELcxx . . $ `<external>/10117917155607792737/glistmodel.h:36:9`!,
347 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.);
348
349 /**
350 * GtkSliceListModel:n-items:
351 *
352 * The number of items. See [[email protected]_n_items].
353 *
354 * Since: 4.8
355 **/
356 propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.] =
357 g_param_spec_uintcxx . . $ g_param_spec_uint(503a1013c8de17d5). ("n-items", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
358 0, G_MAXUINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:40:9`!, 0,
359 G_PARAM_READABLEcxx . . $ G_PARAM_READABLE. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!);
360
361 /**
362 * GtkSliceListModel:offset:
363 *
364 * Offset of slice.
365 */
366 propertiescxx . . $ properties.[PROP_OFFSETcxx . . $ PROP_OFFSET.] =
367 g_param_spec_uintcxx . . $ g_param_spec_uint(503a1013c8de17d5). ("offset", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
368 0, G_MAXUINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:40:9`!, 0,
369 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.);
370
371 /**
372 * GtkSliceListModel:size:
373 *
374 * Maximum size of slice.
375 */
376 propertiescxx . . $ properties.[PROP_SIZEcxx . . $ PROP_SIZE.] =
377 g_param_spec_uintcxx . . $ g_param_spec_uint(503a1013c8de17d5). ("size", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
378 0, G_MAXUINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:40:9`!, DEFAULT_SIZEcxx . . $ `gtk/gtkslicelistmodel.c:39:9`!,
379 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.);
380
381 g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (gobject_class, NUM_PROPERTIEScxx . . $ NUM_PROPERTIES., propertiescxx . . $ properties.);
382 }
383
384 static void
385 gtk_slice_list_model_initcxx . . $ gtk_slice_list_model_init(eb2c221607c9b350). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
386 {
387 self->sizecxx . . $ _GtkSliceListModel#size. = DEFAULT_SIZEcxx . . $ `gtk/gtkslicelistmodel.c:39:9`!;
388 }
389
390 /**
391 * gtk_slice_list_model_new:
392 * @model: (transfer full) (nullable): The model to use
393 * @offset: the offset of the slice
394 * @size: maximum size of the slice
395 *
396 * Creates a new slice model.
397 *
398 * It presents the slice from @offset to offset + @size
399 * of the given @model.
400 *
401 * Returns: A new `GtkSliceListModel`
402 */
403 GtkSliceListModelcxx . . $ GtkSliceListModel# *
404 gtk_slice_list_model_newcxx . . $ gtk_slice_list_model_new(dfa817357b726ad7). (GListModelcxx . . $ GListModel# *model,
405 guintcxx . . $ guint# offset,
406 guintcxx . . $ guint# size)
407 {
408 GtkSliceListModelcxx . . $ GtkSliceListModel# *self;
409
410 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (model == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || G_IS_LIST_MODEL (model), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
411
412 self = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_SLICE_LIST_MODELcxx . . $ `gtk/gtkslicelistmodel.h:33:9`!,
413 "model", model,
414 "offset", offset,
415 "size", size,
416 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
417
418 /* consume the reference */
419 g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&model);
420
421 return self;
422 }
423
424 /**
425 * gtk_slice_list_model_set_model:
426 * @self: a `GtkSliceListModel`
427 * @model: (nullable): The model to be sliced
428 *
429 * Sets the model to show a slice of.
430 *
431 * The model's item type must conform to @self's item type.
432 */
433 void
434 gtk_slice_list_model_set_modelcxx . . $ gtk_slice_list_model_set_model(e102378275964259). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self,
435 GListModelcxx . . $ GListModel# *model)
436 {
437 guintcxx . . $ guint# removed, added;
438
439 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_SLICE_LIST_MODEL (self));
440 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (model == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || G_IS_LIST_MODEL (model));
441
442 if (self->modelcxx . . $ _GtkSliceListModel#model. == model)
443 return;
444
445 removed = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
446 gtk_slice_list_model_clear_modelcxx . . $ gtk_slice_list_model_clear_model(eb2c221607c9b350). (self);
447
448 if (model)
449 {
450 self->modelcxx . . $ _GtkSliceListModel#model. = g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (model);
451 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (model, "items-changed", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_slice_list_model_items_changed_cb), self);
452 added = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
453
454 if (GTK_IS_SECTION_MODELcxx . . $ GTK_IS_SECTION_MODEL(dedf1e9b1c614a07). (model))
455 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (model, "sections-changed", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_slice_list_model_sections_changed_cb), self);
456 }
457 else
458 {
459 added = 0;
460 }
461
462 if (removed > 0 || added > 0)
463 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), 0, removed, added);
464 if (removed != added)
465 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.]);
466
467 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_MODELcxx . . $ PROP_MODEL.]);
468 }
469
470 /**
471 * gtk_slice_list_model_get_model:
472 * @self: a `GtkSliceListModel`
473 *
474 * Gets the model that is currently being used or %NULL if none.
475 *
476 * Returns: (nullable) (transfer none): The model in use
477 */
478 GListModelcxx . . $ GListModel# *
479 gtk_slice_list_model_get_modelcxx . . $ gtk_slice_list_model_get_model(943c61ba622df0cb). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
480 {
481 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_SLICE_LIST_MODEL (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
482
483 return self->modelcxx . . $ _GtkSliceListModel#model.;
484 }
485
486 /**
487 * gtk_slice_list_model_set_offset:
488 * @self: a `GtkSliceListModel`
489 * @offset: the new offset to use
490 *
491 * Sets the offset into the original model for this slice.
492 *
493 * If the offset is too large for the sliced model,
494 * @self will end up empty.
495 */
496 void
497 gtk_slice_list_model_set_offsetcxx . . $ gtk_slice_list_model_set_offset(9ed130d4afdc2fae). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self,
498 guintcxx . . $ guint# offset)
499 {
500 guintcxx . . $ guint# before, after;
501
502 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_SLICE_LIST_MODEL (self));
503
504 if (self->offsetcxx . . $ _GtkSliceListModel#offset. == offset)
505 return;
506
507 before = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
508
509 self->offsetcxx . . $ _GtkSliceListModel#offset. = offset;
510
511 after = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
512
513 if (before > 0 || after > 0)
514 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), 0, before, after);
515 if (before != after)
516 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.]);
517
518 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_OFFSETcxx . . $ PROP_OFFSET.]);
519 }
520
521 /**
522 * gtk_slice_list_model_get_offset:
523 * @self: a `GtkSliceListModel`
524 *
525 * Gets the offset set via gtk_slice_list_model_set_offset().
526 *
527 * Returns: The offset
528 */
529 guintcxx . . $ guint#
530 gtk_slice_list_model_get_offsetcxx . . $ gtk_slice_list_model_get_offset(482066d1dfb3ad93). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
531 {
532 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_SLICE_LIST_MODEL (self), 0);
533
534 return self->offsetcxx . . $ _GtkSliceListModel#offset.;
535 }
536
537 /**
538 * gtk_slice_list_model_set_size:
539 * @self: a `GtkSliceListModel`
540 * @size: the maximum size
541 *
542 * Sets the maximum size. @self will never have more items
543 * than @size.
544 *
545 * It can however have fewer items if the offset is too large
546 * or the model sliced from doesn't have enough items.
547 */
548 void
549 gtk_slice_list_model_set_sizecxx . . $ gtk_slice_list_model_set_size(9ed130d4afdc2fae). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self,
550 guintcxx . . $ guint# size)
551 {
552 guintcxx . . $ guint# before, after;
553
554 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_SLICE_LIST_MODEL (self));
555
556 if (self->sizecxx . . $ _GtkSliceListModel#size. == size)
557 return;
558
559 before = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
560
561 self->sizecxx . . $ _GtkSliceListModel#size. = size;
562
563 after = g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self));
564
565 if (before > after)
566 {
567 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), after, before - after, 0);
568 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.]);
569 }
570 else if (before < after)
571 {
572 g_list_model_items_changedcxx . . $ g_list_model_items_changed(2896dae0034144d8). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (self), before, 0, after - before);
573 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_N_ITEMScxx . . $ PROP_N_ITEMS.]);
574 }
575 /* else nothing */
576
577 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_SIZEcxx . . $ PROP_SIZE.]);
578 }
579
580 /**
581 * gtk_slice_list_model_get_size:
582 * @self: a `GtkSliceListModel`
583 *
584 * Gets the size set via gtk_slice_list_model_set_size().
585 *
586 * Returns: The size
587 */
588 guintcxx . . $ guint#
589 gtk_slice_list_model_get_sizecxx . . $ gtk_slice_list_model_get_size(482066d1dfb3ad93). (GtkSliceListModelcxx . . $ GtkSliceListModel# *self)
590 {
591 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_SLICE_LIST_MODEL (self), DEFAULT_SIZEcxx . . $ `gtk/gtkslicelistmodel.c:39:9`!);
592
593 return self->sizecxx . . $ _GtkSliceListModel#size.;
594 }