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 SelectionFilterModelClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *SelectionFilterModelClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// A list model that presents the selection from a `GtkSelectionModel`.
27type SelectionFilterModel struct {
28 gobject.Object
29}
30
31var xSelectionFilterModelGLibType func() types.GType
32
33func SelectionFilterModelGLibType() types.GType {
34 return xSelectionFilterModelGLibType()
35}
36
37func SelectionFilterModelNewFromInternalPtr(ptr uintptr) *SelectionFilterModel {
38 cls := &SelectionFilterModel{}
39 cls.Ptr = ptr
40 return cls
41}
42
43var xNewSelectionFilterModel func(uintptr) uintptr
44
45// Creates a new `GtkSelectionFilterModel` that will include the
46// selected items from the underlying selection model.
47func NewSelectionFilterModel(ModelVar SelectionModel) *SelectionFilterModel {
48 var cls *SelectionFilterModel
49
50 cret := xNewSelectionFilterModel(ModelVar.GoPointer())
51
52 if cret == 0 {
53 return nil
54 }
55 cls = &SelectionFilterModel{}
56 cls.Ptr = cret
57 return cls
58}
59
60var xSelectionFilterModelGetModel func(uintptr) uintptr
61
62// Gets the model currently filtered or %NULL if none.
63func (x *SelectionFilterModel) GetModel() *SelectionModelBase {
64 var cls *SelectionModelBase
65
66 cret := xSelectionFilterModelGetModel(x.GoPointer())
67
68 if cret == 0 {
69 return nil
70 }
71 gobject.IncreaseRef(cret)
72 cls = &SelectionModelBase{}
73 cls.Ptr = cret
74 return cls
75}
76
77var xSelectionFilterModelSetModel func(uintptr, uintptr)
78
79// Sets the model to be filtered.
80//
81// Note that GTK makes no effort to ensure that @model conforms to
82// the item type of @self. It assumes that the caller knows what they
83// are doing and have set up an appropriate filter to ensure that item
84// types match.
85func (x *SelectionFilterModel) SetModel(ModelVar SelectionModel) {
86
87 xSelectionFilterModelSetModel(x.GoPointer(), ModelVar.GoPointer())
88
89}
90
91func (c *SelectionFilterModel) GoPointer() uintptr {
92 if c == nil {
93 return 0
94 }
95 return c.Ptr
96}
97
98func (c *SelectionFilterModel) SetGoPointer(ptr uintptr) {
99 c.Ptr = ptr
100}
101
102// GetPropertyNItems gets the "n-items" property.
103// The number of items. See [method@Gio.ListModel.get_n_items].
104func (x *SelectionFilterModel) GetPropertyNItems() uint {
105 var v gobject.Value
106 x.GetProperty("n-items", &v)
107 return v.GetUint()
108}
109
110// Get the item at @position.
111//
112// If @position is greater than the number of items in @list, %NULL is
113// returned.
114//
115// %NULL is never returned for an index that is smaller than the length
116// of the list.
117//
118// See also: g_list_model_get_n_items()
119func (x *SelectionFilterModel) GetItem(PositionVar uint) uintptr {
120
121 cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
122 return cret
123}
124
125// Gets the type of the items in @list.
126//
127// All items returned from g_list_model_get_item() are of the type
128// returned by this function, or a subtype, or if the type is an
129// interface, they are an implementation of that interface.
130//
131// The item type of a #GListModel can not change during the life of the
132// model.
133func (x *SelectionFilterModel) GetItemType() types.GType {
134
135 cret := gio.XGListModelGetItemType(x.GoPointer())
136 return cret
137}
138
139// Gets the number of items in @list.
140//
141// Depending on the model implementation, calling this function may be
142// less efficient than iterating the list with increasing values for
143// @position until g_list_model_get_item() returns %NULL.
144func (x *SelectionFilterModel) GetNItems() uint {
145
146 cret := gio.XGListModelGetNItems(x.GoPointer())
147 return cret
148}
149
150// Get the item at @position.
151//
152// If @position is greater than the number of items in @list, %NULL is
153// returned.
154//
155// %NULL is never returned for an index that is smaller than the length
156// of the list.
157//
158// This function is meant to be used by language bindings in place
159// of g_list_model_get_item().
160//
161// See also: g_list_model_get_n_items()
162func (x *SelectionFilterModel) GetObject(PositionVar uint) *gobject.Object {
163 var cls *gobject.Object
164
165 cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
166
167 if cret == 0 {
168 return nil
169 }
170 cls = &gobject.Object{}
171 cls.Ptr = cret
172 return cls
173}
174
175// Emits the #GListModel::items-changed signal on @list.
176//
177// This function should only be called by classes implementing
178// #GListModel. It has to be called after the internal representation
179// of @list has been updated, because handlers connected to this signal
180// might query the new state of the list.
181//
182// Implementations must only make changes to the model (as visible to
183// its consumer) in places that will not cause problems for that
184// consumer. For models that are driven directly by a write API (such
185// as #GListStore), changes can be reported in response to uses of that
186// API. For models that represent remote data, changes should only be
187// made from a fresh mainloop dispatch. It is particularly not
188// permitted to make changes in response to a call to the #GListModel
189// consumer API.
190//
191// Stated another way: in general, it is assumed that code making a
192// series of accesses to the model via the API, without returning to the
193// mainloop, and without calling other code, will continue to view the
194// same contents of the model.
195func (x *SelectionFilterModel) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
196
197 gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
198
199}
200
201func init() {
202 core.SetPackageName("GTK", "gtk4")
203 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
204 var libs []uintptr
205 for _, libPath := range core.GetPaths("GTK") {
206 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
207 if err != nil {
208 panic(err)
209 }
210 libs = append(libs, lib)
211 }
212
213 core.PuregoSafeRegister(&xSelectionFilterModelGLibType, libs, "gtk_selection_filter_model_get_type")
214
215 core.PuregoSafeRegister(&xNewSelectionFilterModel, libs, "gtk_selection_filter_model_new")
216
217 core.PuregoSafeRegister(&xSelectionFilterModelGetModel, libs, "gtk_selection_filter_model_get_model")
218 core.PuregoSafeRegister(&xSelectionFilterModelSetModel, libs, "gtk_selection_filter_model_set_model")
219
220}