1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gio"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type FilterListModelClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *FilterListModelClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// A list model that filters the elements of another model.
27//
28// It hides some elements from the underlying model according to
29// criteria given by a `GtkFilter`.
30//
31// The model can be set up to do incremental filtering, so that
32// filtering long lists doesn't block the UI. See
33// [method@Gtk.FilterListModel.set_incremental] for details.
34//
35// `GtkFilterListModel` passes through sections from the underlying model.
36type FilterListModel struct {
37 gobject.Object
38}
39
40var xFilterListModelGLibType func() types.GType
41
42func FilterListModelGLibType() types.GType {
43 return xFilterListModelGLibType()
44}
45
46func FilterListModelNewFromInternalPtr(ptr uintptr) *FilterListModel {
47 cls := &FilterListModel{}
48 cls.Ptr = ptr
49 return cls
50}
51
52var xNewFilterListModel func(uintptr, uintptr) uintptr
53
54// Creates a new `GtkFilterListModel` that will filter @model using the given
55// @filter.
56func NewFilterListModel(ModelVar gio.ListModel, FilterVar *Filter) *FilterListModel {
57 var cls *FilterListModel
58
59 cret := xNewFilterListModel(ModelVar.GoPointer(), FilterVar.GoPointer())
60
61 if cret == 0 {
62 return nil
63 }
64 cls = &FilterListModel{}
65 cls.Ptr = cret
66 return cls
67}
68
69var xFilterListModelGetFilter func(uintptr) uintptr
70
71// Gets the `GtkFilter` currently set on @self.
72func (x *FilterListModel) GetFilter() *Filter {
73 var cls *Filter
74
75 cret := xFilterListModelGetFilter(x.GoPointer())
76
77 if cret == 0 {
78 return nil
79 }
80 gobject.IncreaseRef(cret)
81 cls = &Filter{}
82 cls.Ptr = cret
83 return cls
84}
85
86var xFilterListModelGetIncremental func(uintptr) bool
87
88// Returns whether incremental filtering is enabled.
89//
90// See [method@Gtk.FilterListModel.set_incremental].
91func (x *FilterListModel) GetIncremental() bool {
92
93 cret := xFilterListModelGetIncremental(x.GoPointer())
94 return cret
95}
96
97var xFilterListModelGetModel func(uintptr) uintptr
98
99// Gets the model currently filtered or %NULL if none.
100func (x *FilterListModel) GetModel() *gio.ListModelBase {
101 var cls *gio.ListModelBase
102
103 cret := xFilterListModelGetModel(x.GoPointer())
104
105 if cret == 0 {
106 return nil
107 }
108 gobject.IncreaseRef(cret)
109 cls = &gio.ListModelBase{}
110 cls.Ptr = cret
111 return cls
112}
113
114var xFilterListModelGetPending func(uintptr) uint
115
116// Returns the number of items that have not been filtered yet.
117//
118// You can use this value to check if @self is busy filtering by
119// comparing the return value to 0 or you can compute the percentage
120// of the filter remaining by dividing the return value by the total
121// number of items in the underlying model:
122//
123// ```c
124// pending = gtk_filter_list_model_get_pending (self);
125// model = gtk_filter_list_model_get_model (self);
126// percentage = pending / (double) g_list_model_get_n_items (model);
127// ```
128//
129// If no filter operation is ongoing - in particular when
130// [property@Gtk.FilterListModel:incremental] is %FALSE - this
131// function returns 0.
132func (x *FilterListModel) GetPending() uint {
133
134 cret := xFilterListModelGetPending(x.GoPointer())
135 return cret
136}
137
138var xFilterListModelGetWatchItems func(uintptr) bool
139
140// Returns whether watching items is enabled.
141//
142// See [method@Gtk.FilterListModel.set_watch_items].
143func (x *FilterListModel) GetWatchItems() bool {
144
145 cret := xFilterListModelGetWatchItems(x.GoPointer())
146 return cret
147}
148
149var xFilterListModelSetFilter func(uintptr, uintptr)
150
151// Sets the filter used to filter items.
152func (x *FilterListModel) SetFilter(FilterVar *Filter) {
153
154 xFilterListModelSetFilter(x.GoPointer(), FilterVar.GoPointer())
155
156}
157
158var xFilterListModelSetIncremental func(uintptr, bool)
159
160// Sets the filter model to do an incremental sort.
161//
162// When incremental filtering is enabled, the `GtkFilterListModel` will not
163// run filters immediately, but will instead queue an idle handler that
164// incrementally filters the items and adds them to the list. This of course
165// means that items are not instantly added to the list, but only appear
166// incrementally.
167//
168// When your filter blocks the UI while filtering, you might consider
169// turning this on. Depending on your model and filters, this may become
170// interesting around 10,000 to 100,000 items.
171//
172// By default, incremental filtering is disabled.
173//
174// See [method@Gtk.FilterListModel.get_pending] for progress information
175// about an ongoing incremental filtering operation.
176func (x *FilterListModel) SetIncremental(IncrementalVar bool) {
177
178 xFilterListModelSetIncremental(x.GoPointer(), IncrementalVar)
179
180}
181
182var xFilterListModelSetModel func(uintptr, uintptr)
183
184// Sets the model to be filtered.
185//
186// Note that GTK makes no effort to ensure that @model conforms to
187// the item type of @self. It assumes that the caller knows what they
188// are doing and have set up an appropriate filter to ensure that item
189// types match.
190func (x *FilterListModel) SetModel(ModelVar gio.ListModel) {
191
192 xFilterListModelSetModel(x.GoPointer(), ModelVar.GoPointer())
193
194}
195
196var xFilterListModelSetWatchItems func(uintptr, bool)
197
198// Sets the filter model to monitor properties of its items.
199//
200// This allows implementations of [class@Gtk.Filter] that support expression
201// watching to react to property changes. This property has no effect if the
202// current filter doesn't support watching items.
203//
204// By default, watching items is disabled.
205func (x *FilterListModel) SetWatchItems(WatchItemsVar bool) {
206
207 xFilterListModelSetWatchItems(x.GoPointer(), WatchItemsVar)
208
209}
210
211func (c *FilterListModel) GoPointer() uintptr {
212 if c == nil {
213 return 0
214 }
215 return c.Ptr
216}
217
218func (c *FilterListModel) SetGoPointer(ptr uintptr) {
219 c.Ptr = ptr
220}
221
222// SetPropertyIncremental sets the "incremental" property.
223// If the model should filter items incrementally.
224func (x *FilterListModel) SetPropertyIncremental(value bool) {
225 var v gobject.Value
226 v.Init(gobject.TypeBooleanVal)
227 v.SetBoolean(value)
228 x.SetProperty("incremental", &v)
229}
230
231// GetPropertyIncremental gets the "incremental" property.
232// If the model should filter items incrementally.
233func (x *FilterListModel) GetPropertyIncremental() bool {
234 var v gobject.Value
235 x.GetProperty("incremental", &v)
236 return v.GetBoolean()
237}
238
239// GetPropertyNItems gets the "n-items" property.
240// The number of items. See [method@Gio.ListModel.get_n_items].
241func (x *FilterListModel) GetPropertyNItems() uint {
242 var v gobject.Value
243 x.GetProperty("n-items", &v)
244 return v.GetUint()
245}
246
247// GetPropertyPending gets the "pending" property.
248// Number of items not yet filtered.
249func (x *FilterListModel) GetPropertyPending() uint {
250 var v gobject.Value
251 x.GetProperty("pending", &v)
252 return v.GetUint()
253}
254
255// SetPropertyWatchItems sets the "watch-items" property.
256// Monitor the list items for changes. It may impact performance.
257func (x *FilterListModel) SetPropertyWatchItems(value bool) {
258 var v gobject.Value
259 v.Init(gobject.TypeBooleanVal)
260 v.SetBoolean(value)
261 x.SetProperty("watch-items", &v)
262}
263
264// GetPropertyWatchItems gets the "watch-items" property.
265// Monitor the list items for changes. It may impact performance.
266func (x *FilterListModel) GetPropertyWatchItems() bool {
267 var v gobject.Value
268 x.GetProperty("watch-items", &v)
269 return v.GetBoolean()
270}
271
272// Get the item at @position.
273//
274// If @position is greater than the number of items in @list, %NULL is
275// returned.
276//
277// %NULL is never returned for an index that is smaller than the length
278// of the list.
279//
280// See also: g_list_model_get_n_items()
281func (x *FilterListModel) GetItem(PositionVar uint) uintptr {
282
283 cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
284 return cret
285}
286
287// Gets the type of the items in @list.
288//
289// All items returned from g_list_model_get_item() are of the type
290// returned by this function, or a subtype, or if the type is an
291// interface, they are an implementation of that interface.
292//
293// The item type of a #GListModel can not change during the life of the
294// model.
295func (x *FilterListModel) GetItemType() types.GType {
296
297 cret := gio.XGListModelGetItemType(x.GoPointer())
298 return cret
299}
300
301// Gets the number of items in @list.
302//
303// Depending on the model implementation, calling this function may be
304// less efficient than iterating the list with increasing values for
305// @position until g_list_model_get_item() returns %NULL.
306func (x *FilterListModel) GetNItems() uint {
307
308 cret := gio.XGListModelGetNItems(x.GoPointer())
309 return cret
310}
311
312// Get the item at @position.
313//
314// If @position is greater than the number of items in @list, %NULL is
315// returned.
316//
317// %NULL is never returned for an index that is smaller than the length
318// of the list.
319//
320// This function is meant to be used by language bindings in place
321// of g_list_model_get_item().
322//
323// See also: g_list_model_get_n_items()
324func (x *FilterListModel) GetObject(PositionVar uint) *gobject.Object {
325 var cls *gobject.Object
326
327 cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
328
329 if cret == 0 {
330 return nil
331 }
332 cls = &gobject.Object{}
333 cls.Ptr = cret
334 return cls
335}
336
337// Emits the #GListModel::items-changed signal on @list.
338//
339// This function should only be called by classes implementing
340// #GListModel. It has to be called after the internal representation
341// of @list has been updated, because handlers connected to this signal
342// might query the new state of the list.
343//
344// Implementations must only make changes to the model (as visible to
345// its consumer) in places that will not cause problems for that
346// consumer. For models that are driven directly by a write API (such
347// as #GListStore), changes can be reported in response to uses of that
348// API. For models that represent remote data, changes should only be
349// made from a fresh mainloop dispatch. It is particularly not
350// permitted to make changes in response to a call to the #GListModel
351// consumer API.
352//
353// Stated another way: in general, it is assumed that code making a
354// series of accesses to the model via the API, without returning to the
355// mainloop, and without calling other code, will continue to view the
356// same contents of the model.
357func (x *FilterListModel) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
358
359 gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
360
361}
362
363// Query the section that covers the given position. The number of
364// items in the section can be computed by `out_end - out_start`.
365//
366// If the position is larger than the number of items, a single
367// range from n_items to G_MAXUINT will be returned.
368func (x *FilterListModel) GetSection(PositionVar uint, OutStartVar *uint, OutEndVar *uint) {
369
370 XGtkSectionModelGetSection(x.GoPointer(), PositionVar, OutStartVar, OutEndVar)
371
372}
373
374// This function emits the [signal@Gtk.SectionModel::sections-changed]
375// signal to notify about changes to sections.
376//
377// It must cover all positions that used to be a section start or that
378// are now a section start. It does not have to cover all positions for
379// which the section has changed.
380//
381// The [signal@Gio.ListModel::items-changed] implies the effect of the
382// [signal@Gtk.SectionModel::sections-changed] signal for all the items
383// it covers.
384//
385// It is recommended that when changes to the items cause section changes
386// in a larger range, that the larger range is included in the emission
387// of the [signal@Gio.ListModel::items-changed] instead of emitting
388// two signals.
389func (x *FilterListModel) SectionsChanged(PositionVar uint, NItemsVar uint) {
390
391 XGtkSectionModelSectionsChanged(x.GoPointer(), PositionVar, NItemsVar)
392
393}
394
395func init() {
396 core.SetPackageName("GTK", "gtk4")
397 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
398 var libs []uintptr
399 for _, libPath := range core.GetPaths("GTK") {
400 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
401 if err != nil {
402 panic(err)
403 }
404 libs = append(libs, lib)
405 }
406
407 core.PuregoSafeRegister(&xFilterListModelGLibType, libs, "gtk_filter_list_model_get_type")
408
409 core.PuregoSafeRegister(&xNewFilterListModel, libs, "gtk_filter_list_model_new")
410
411 core.PuregoSafeRegister(&xFilterListModelGetFilter, libs, "gtk_filter_list_model_get_filter")
412 core.PuregoSafeRegister(&xFilterListModelGetIncremental, libs, "gtk_filter_list_model_get_incremental")
413 core.PuregoSafeRegister(&xFilterListModelGetModel, libs, "gtk_filter_list_model_get_model")
414 core.PuregoSafeRegister(&xFilterListModelGetPending, libs, "gtk_filter_list_model_get_pending")
415 core.PuregoSafeRegister(&xFilterListModelGetWatchItems, libs, "gtk_filter_list_model_get_watch_items")
416 core.PuregoSafeRegister(&xFilterListModelSetFilter, libs, "gtk_filter_list_model_set_filter")
417 core.PuregoSafeRegister(&xFilterListModelSetIncremental, libs, "gtk_filter_list_model_set_incremental")
418 core.PuregoSafeRegister(&xFilterListModelSetModel, libs, "gtk_filter_list_model_set_model")
419 core.PuregoSafeRegister(&xFilterListModelSetWatchItems, libs, "gtk_filter_list_model_set_watch_items")
420
421}