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 FlattenListModelClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *FlattenListModelClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// A list model that concatenates other list models.
27//
28// `GtkFlattenListModel` takes a list model containing list models, and flattens
29// it into a single model. Each list model becomes a section in the single model.
30type FlattenListModel struct {
31 gobject.Object
32}
33
34var xFlattenListModelGLibType func() types.GType
35
36func FlattenListModelGLibType() types.GType {
37 return xFlattenListModelGLibType()
38}
39
40func FlattenListModelNewFromInternalPtr(ptr uintptr) *FlattenListModel {
41 cls := &FlattenListModel{}
42 cls.Ptr = ptr
43 return cls
44}
45
46var xNewFlattenListModel func(uintptr) uintptr
47
48// Creates a new `GtkFlattenListModel` that flattens @list.
49func NewFlattenListModel(ModelVar gio.ListModel) *FlattenListModel {
50 var cls *FlattenListModel
51
52 cret := xNewFlattenListModel(ModelVar.GoPointer())
53
54 if cret == 0 {
55 return nil
56 }
57 cls = &FlattenListModel{}
58 cls.Ptr = cret
59 return cls
60}
61
62var xFlattenListModelGetModel func(uintptr) uintptr
63
64// Gets the model set via gtk_flatten_list_model_set_model().
65func (x *FlattenListModel) GetModel() *gio.ListModelBase {
66 var cls *gio.ListModelBase
67
68 cret := xFlattenListModelGetModel(x.GoPointer())
69
70 if cret == 0 {
71 return nil
72 }
73 gobject.IncreaseRef(cret)
74 cls = &gio.ListModelBase{}
75 cls.Ptr = cret
76 return cls
77}
78
79var xFlattenListModelGetModelForItem func(uintptr, uint) uintptr
80
81// Returns the model containing the item at the given position.
82func (x *FlattenListModel) GetModelForItem(PositionVar uint) *gio.ListModelBase {
83 var cls *gio.ListModelBase
84
85 cret := xFlattenListModelGetModelForItem(x.GoPointer(), PositionVar)
86
87 if cret == 0 {
88 return nil
89 }
90 gobject.IncreaseRef(cret)
91 cls = &gio.ListModelBase{}
92 cls.Ptr = cret
93 return cls
94}
95
96var xFlattenListModelSetModel func(uintptr, uintptr)
97
98// Sets a new model to be flattened.
99func (x *FlattenListModel) SetModel(ModelVar gio.ListModel) {
100
101 xFlattenListModelSetModel(x.GoPointer(), ModelVar.GoPointer())
102
103}
104
105func (c *FlattenListModel) GoPointer() uintptr {
106 if c == nil {
107 return 0
108 }
109 return c.Ptr
110}
111
112func (c *FlattenListModel) SetGoPointer(ptr uintptr) {
113 c.Ptr = ptr
114}
115
116// GetPropertyNItems gets the "n-items" property.
117// The number of items. See [method@Gio.ListModel.get_n_items].
118func (x *FlattenListModel) GetPropertyNItems() uint {
119 var v gobject.Value
120 x.GetProperty("n-items", &v)
121 return v.GetUint()
122}
123
124// Get the item at @position.
125//
126// If @position is greater than the number of items in @list, %NULL is
127// returned.
128//
129// %NULL is never returned for an index that is smaller than the length
130// of the list.
131//
132// See also: g_list_model_get_n_items()
133func (x *FlattenListModel) GetItem(PositionVar uint) uintptr {
134
135 cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
136 return cret
137}
138
139// Gets the type of the items in @list.
140//
141// All items returned from g_list_model_get_item() are of the type
142// returned by this function, or a subtype, or if the type is an
143// interface, they are an implementation of that interface.
144//
145// The item type of a #GListModel can not change during the life of the
146// model.
147func (x *FlattenListModel) GetItemType() types.GType {
148
149 cret := gio.XGListModelGetItemType(x.GoPointer())
150 return cret
151}
152
153// Gets the number of items in @list.
154//
155// Depending on the model implementation, calling this function may be
156// less efficient than iterating the list with increasing values for
157// @position until g_list_model_get_item() returns %NULL.
158func (x *FlattenListModel) GetNItems() uint {
159
160 cret := gio.XGListModelGetNItems(x.GoPointer())
161 return cret
162}
163
164// Get the item at @position.
165//
166// If @position is greater than the number of items in @list, %NULL is
167// returned.
168//
169// %NULL is never returned for an index that is smaller than the length
170// of the list.
171//
172// This function is meant to be used by language bindings in place
173// of g_list_model_get_item().
174//
175// See also: g_list_model_get_n_items()
176func (x *FlattenListModel) GetObject(PositionVar uint) *gobject.Object {
177 var cls *gobject.Object
178
179 cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
180
181 if cret == 0 {
182 return nil
183 }
184 cls = &gobject.Object{}
185 cls.Ptr = cret
186 return cls
187}
188
189// Emits the #GListModel::items-changed signal on @list.
190//
191// This function should only be called by classes implementing
192// #GListModel. It has to be called after the internal representation
193// of @list has been updated, because handlers connected to this signal
194// might query the new state of the list.
195//
196// Implementations must only make changes to the model (as visible to
197// its consumer) in places that will not cause problems for that
198// consumer. For models that are driven directly by a write API (such
199// as #GListStore), changes can be reported in response to uses of that
200// API. For models that represent remote data, changes should only be
201// made from a fresh mainloop dispatch. It is particularly not
202// permitted to make changes in response to a call to the #GListModel
203// consumer API.
204//
205// Stated another way: in general, it is assumed that code making a
206// series of accesses to the model via the API, without returning to the
207// mainloop, and without calling other code, will continue to view the
208// same contents of the model.
209func (x *FlattenListModel) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
210
211 gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
212
213}
214
215// Query the section that covers the given position. The number of
216// items in the section can be computed by `out_end - out_start`.
217//
218// If the position is larger than the number of items, a single
219// range from n_items to G_MAXUINT will be returned.
220func (x *FlattenListModel) GetSection(PositionVar uint, OutStartVar *uint, OutEndVar *uint) {
221
222 XGtkSectionModelGetSection(x.GoPointer(), PositionVar, OutStartVar, OutEndVar)
223
224}
225
226// This function emits the [signal@Gtk.SectionModel::sections-changed]
227// signal to notify about changes to sections.
228//
229// It must cover all positions that used to be a section start or that
230// are now a section start. It does not have to cover all positions for
231// which the section has changed.
232//
233// The [signal@Gio.ListModel::items-changed] implies the effect of the
234// [signal@Gtk.SectionModel::sections-changed] signal for all the items
235// it covers.
236//
237// It is recommended that when changes to the items cause section changes
238// in a larger range, that the larger range is included in the emission
239// of the [signal@Gio.ListModel::items-changed] instead of emitting
240// two signals.
241func (x *FlattenListModel) SectionsChanged(PositionVar uint, NItemsVar uint) {
242
243 XGtkSectionModelSectionsChanged(x.GoPointer(), PositionVar, NItemsVar)
244
245}
246
247func init() {
248 core.SetPackageName("GTK", "gtk4")
249 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
250 var libs []uintptr
251 for _, libPath := range core.GetPaths("GTK") {
252 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
253 if err != nil {
254 panic(err)
255 }
256 libs = append(libs, lib)
257 }
258
259 core.PuregoSafeRegister(&xFlattenListModelGLibType, libs, "gtk_flatten_list_model_get_type")
260
261 core.PuregoSafeRegister(&xNewFlattenListModel, libs, "gtk_flatten_list_model_new")
262
263 core.PuregoSafeRegister(&xFlattenListModelGetModel, libs, "gtk_flatten_list_model_get_model")
264 core.PuregoSafeRegister(&xFlattenListModelGetModelForItem, libs, "gtk_flatten_list_model_get_model_for_item")
265 core.PuregoSafeRegister(&xFlattenListModelSetModel, libs, "gtk_flatten_list_model_set_model")
266
267}