v0.2.1 c0399be

gtksortlistmodel.go RawHistoryFolder

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 SortListModelClass struct {
17	_ structs.HostLayout
18
19	ParentClass gobject.ObjectClass
20}
21
22func (x *SortListModelClass) GoPointer() uintptr {
23	return uintptr(unsafe.Pointer(x))
24}
25
26// A list model that sorts the elements of another model.
27//
28// The elements are sorted according to a `GtkSorter`.
29//
30// The model is a stable sort. If two items compare equal according
31// to the sorter, the one that appears first in the original model will
32// also appear first after sorting.
33//
34// Note that if you change the sorter, the previous order will have no
35// influence on the new order. If you want that, consider using a
36// `GtkMultiSorter` and appending the previous sorter to it.
37//
38// The model can be set up to do incremental sorting, so that
39// sorting long lists doesn't block the UI. See
40// [method@Gtk.SortListModel.set_incremental] for details.
41//
42// `GtkSortListModel` is a generic model and because of that it
43// cannot take advantage of any external knowledge when sorting.
44// If you run into performance issues with `GtkSortListModel`,
45// it is strongly recommended that you write your own sorting list
46// model.
47//
48// `GtkSortListModel` allows sorting the items into sections. It
49// implements `GtkSectionModel` and when [property@Gtk.SortListModel:section-sorter]
50// is set, it will sort all items with that sorter and items comparing
51// equal with it will be put into the same section.
52// The [property@Gtk.SortListModel:sorter] will then be used to sort items
53// inside their sections.
54type SortListModel struct {
55	gobject.Object
56}
57
58var xSortListModelGLibType func() types.GType
59
60func SortListModelGLibType() types.GType {
61	return xSortListModelGLibType()
62}
63
64func SortListModelNewFromInternalPtr(ptr uintptr) *SortListModel {
65	cls := &SortListModel{}
66	cls.Ptr = ptr
67	return cls
68}
69
70var xNewSortListModel func(uintptr, uintptr) uintptr
71
72// Creates a new sort list model that uses the @sorter to sort @model.
73func NewSortListModel(ModelVar gio.ListModel, SorterVar *Sorter) *SortListModel {
74	var cls *SortListModel
75
76	cret := xNewSortListModel(ModelVar.GoPointer(), SorterVar.GoPointer())
77
78	if cret == 0 {
79		return nil
80	}
81	cls = &SortListModel{}
82	cls.Ptr = cret
83	return cls
84}
85
86var xSortListModelGetIncremental func(uintptr) bool
87
88// Returns whether incremental sorting is enabled.
89//
90// See [method@Gtk.SortListModel.set_incremental].
91func (x *SortListModel) GetIncremental() bool {
92
93	cret := xSortListModelGetIncremental(x.GoPointer())
94	return cret
95}
96
97var xSortListModelGetModel func(uintptr) uintptr
98
99// Gets the model currently sorted or %NULL if none.
100func (x *SortListModel) GetModel() *gio.ListModelBase {
101	var cls *gio.ListModelBase
102
103	cret := xSortListModelGetModel(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 xSortListModelGetPending func(uintptr) uint
115
116// Estimates progress of an ongoing sorting operation.
117//
118// The estimate is the number of items that would still need to be
119// sorted to finish the sorting operation if this was a linear
120// algorithm. So this number is not related to how many items are
121// already correctly sorted.
122//
123// If you want to estimate the progress, you can use code like this:
124// ```c
125// pending = gtk_sort_list_model_get_pending (self);
126// model = gtk_sort_list_model_get_model (self);
127// progress = 1.0 - pending / (double) MAX (1, g_list_model_get_n_items (model));
128// ```
129//
130// If no sort operation is ongoing - in particular when
131// [property@Gtk.SortListModel:incremental] is %FALSE - this
132// function returns 0.
133func (x *SortListModel) GetPending() uint {
134
135	cret := xSortListModelGetPending(x.GoPointer())
136	return cret
137}
138
139var xSortListModelGetSectionSorter func(uintptr) uintptr
140
141// Gets the section sorter that is used to sort items of @self into
142// sections.
143func (x *SortListModel) GetSectionSorter() *Sorter {
144	var cls *Sorter
145
146	cret := xSortListModelGetSectionSorter(x.GoPointer())
147
148	if cret == 0 {
149		return nil
150	}
151	gobject.IncreaseRef(cret)
152	cls = &Sorter{}
153	cls.Ptr = cret
154	return cls
155}
156
157var xSortListModelGetSorter func(uintptr) uintptr
158
159// Gets the sorter that is used to sort @self.
160func (x *SortListModel) GetSorter() *Sorter {
161	var cls *Sorter
162
163	cret := xSortListModelGetSorter(x.GoPointer())
164
165	if cret == 0 {
166		return nil
167	}
168	gobject.IncreaseRef(cret)
169	cls = &Sorter{}
170	cls.Ptr = cret
171	return cls
172}
173
174var xSortListModelSetIncremental func(uintptr, bool)
175
176// Sets the sort model to do an incremental sort.
177//
178// When incremental sorting is enabled, the `GtkSortListModel` will not do
179// a complete sort immediately, but will instead queue an idle handler that
180// incrementally sorts the items towards their correct position. This of
181// course means that items do not instantly appear in the right place. It
182// also means that the total sorting time is a lot slower.
183//
184// When your filter blocks the UI while sorting, you might consider
185// turning this on. Depending on your model and sorters, this may become
186// interesting around 10,000 to 100,000 items.
187//
188// By default, incremental sorting is disabled.
189//
190// See [method@Gtk.SortListModel.get_pending] for progress information
191// about an ongoing incremental sorting operation.
192func (x *SortListModel) SetIncremental(IncrementalVar bool) {
193
194	xSortListModelSetIncremental(x.GoPointer(), IncrementalVar)
195
196}
197
198var xSortListModelSetModel func(uintptr, uintptr)
199
200// Sets the model to be sorted.
201//
202// The @model's item type must conform to the item type of @self.
203func (x *SortListModel) SetModel(ModelVar gio.ListModel) {
204
205	xSortListModelSetModel(x.GoPointer(), ModelVar.GoPointer())
206
207}
208
209var xSortListModelSetSectionSorter func(uintptr, uintptr)
210
211// Sets a new section sorter on @self.
212func (x *SortListModel) SetSectionSorter(SorterVar *Sorter) {
213
214	xSortListModelSetSectionSorter(x.GoPointer(), SorterVar.GoPointer())
215
216}
217
218var xSortListModelSetSorter func(uintptr, uintptr)
219
220// Sets a new sorter on @self.
221func (x *SortListModel) SetSorter(SorterVar *Sorter) {
222
223	xSortListModelSetSorter(x.GoPointer(), SorterVar.GoPointer())
224
225}
226
227func (c *SortListModel) GoPointer() uintptr {
228	if c == nil {
229		return 0
230	}
231	return c.Ptr
232}
233
234func (c *SortListModel) SetGoPointer(ptr uintptr) {
235	c.Ptr = ptr
236}
237
238// SetPropertyIncremental sets the "incremental" property.
239// If the model should sort items incrementally.
240func (x *SortListModel) SetPropertyIncremental(value bool) {
241	var v gobject.Value
242	v.Init(gobject.TypeBooleanVal)
243	v.SetBoolean(value)
244	x.SetProperty("incremental", &v)
245}
246
247// GetPropertyIncremental gets the "incremental" property.
248// If the model should sort items incrementally.
249func (x *SortListModel) GetPropertyIncremental() bool {
250	var v gobject.Value
251	x.GetProperty("incremental", &v)
252	return v.GetBoolean()
253}
254
255// GetPropertyNItems gets the "n-items" property.
256// The number of items. See [method@Gio.ListModel.get_n_items].
257func (x *SortListModel) GetPropertyNItems() uint {
258	var v gobject.Value
259	x.GetProperty("n-items", &v)
260	return v.GetUint()
261}
262
263// GetPropertyPending gets the "pending" property.
264// Estimate of unsorted items remaining.
265func (x *SortListModel) GetPropertyPending() uint {
266	var v gobject.Value
267	x.GetProperty("pending", &v)
268	return v.GetUint()
269}
270
271// Get the item at @position.
272//
273// If @position is greater than the number of items in @list, %NULL is
274// returned.
275//
276// %NULL is never returned for an index that is smaller than the length
277// of the list.
278//
279// See also: g_list_model_get_n_items()
280func (x *SortListModel) GetItem(PositionVar uint) uintptr {
281
282	cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
283	return cret
284}
285
286// Gets the type of the items in @list.
287//
288// All items returned from g_list_model_get_item() are of the type
289// returned by this function, or a subtype, or if the type is an
290// interface, they are an implementation of that interface.
291//
292// The item type of a #GListModel can not change during the life of the
293// model.
294func (x *SortListModel) GetItemType() types.GType {
295
296	cret := gio.XGListModelGetItemType(x.GoPointer())
297	return cret
298}
299
300// Gets the number of items in @list.
301//
302// Depending on the model implementation, calling this function may be
303// less efficient than iterating the list with increasing values for
304// @position until g_list_model_get_item() returns %NULL.
305func (x *SortListModel) GetNItems() uint {
306
307	cret := gio.XGListModelGetNItems(x.GoPointer())
308	return cret
309}
310
311// Get the item at @position.
312//
313// If @position is greater than the number of items in @list, %NULL is
314// returned.
315//
316// %NULL is never returned for an index that is smaller than the length
317// of the list.
318//
319// This function is meant to be used by language bindings in place
320// of g_list_model_get_item().
321//
322// See also: g_list_model_get_n_items()
323func (x *SortListModel) GetObject(PositionVar uint) *gobject.Object {
324	var cls *gobject.Object
325
326	cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
327
328	if cret == 0 {
329		return nil
330	}
331	cls = &gobject.Object{}
332	cls.Ptr = cret
333	return cls
334}
335
336// Emits the #GListModel::items-changed signal on @list.
337//
338// This function should only be called by classes implementing
339// #GListModel. It has to be called after the internal representation
340// of @list has been updated, because handlers connected to this signal
341// might query the new state of the list.
342//
343// Implementations must only make changes to the model (as visible to
344// its consumer) in places that will not cause problems for that
345// consumer.  For models that are driven directly by a write API (such
346// as #GListStore), changes can be reported in response to uses of that
347// API.  For models that represent remote data, changes should only be
348// made from a fresh mainloop dispatch.  It is particularly not
349// permitted to make changes in response to a call to the #GListModel
350// consumer API.
351//
352// Stated another way: in general, it is assumed that code making a
353// series of accesses to the model via the API, without returning to the
354// mainloop, and without calling other code, will continue to view the
355// same contents of the model.
356func (x *SortListModel) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
357
358	gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
359
360}
361
362// Query the section that covers the given position. The number of
363// items in the section can be computed by `out_end - out_start`.
364//
365// If the position is larger than the number of items, a single
366// range from n_items to G_MAXUINT will be returned.
367func (x *SortListModel) GetSection(PositionVar uint, OutStartVar *uint, OutEndVar *uint) {
368
369	XGtkSectionModelGetSection(x.GoPointer(), PositionVar, OutStartVar, OutEndVar)
370
371}
372
373// This function emits the [signal@Gtk.SectionModel::sections-changed]
374// signal to notify about changes to sections.
375//
376// It must cover all positions that used to be a section start or that
377// are now a section start. It does not have to cover all positions for
378// which the section has changed.
379//
380// The [signal@Gio.ListModel::items-changed] implies the effect of the
381// [signal@Gtk.SectionModel::sections-changed] signal for all the items
382// it covers.
383//
384// It is recommended that when changes to the items cause section changes
385// in a larger range, that the larger range is included in the emission
386// of the [signal@Gio.ListModel::items-changed] instead of emitting
387// two signals.
388func (x *SortListModel) SectionsChanged(PositionVar uint, NItemsVar uint) {
389
390	XGtkSectionModelSectionsChanged(x.GoPointer(), PositionVar, NItemsVar)
391
392}
393
394func init() {
395	core.SetPackageName("GTK", "gtk4")
396	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
397	var libs []uintptr
398	for _, libPath := range core.GetPaths("GTK") {
399		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
400		if err != nil {
401			panic(err)
402		}
403		libs = append(libs, lib)
404	}
405
406	core.PuregoSafeRegister(&xSortListModelGLibType, libs, "gtk_sort_list_model_get_type")
407
408	core.PuregoSafeRegister(&xNewSortListModel, libs, "gtk_sort_list_model_new")
409
410	core.PuregoSafeRegister(&xSortListModelGetIncremental, libs, "gtk_sort_list_model_get_incremental")
411	core.PuregoSafeRegister(&xSortListModelGetModel, libs, "gtk_sort_list_model_get_model")
412	core.PuregoSafeRegister(&xSortListModelGetPending, libs, "gtk_sort_list_model_get_pending")
413	core.PuregoSafeRegister(&xSortListModelGetSectionSorter, libs, "gtk_sort_list_model_get_section_sorter")
414	core.PuregoSafeRegister(&xSortListModelGetSorter, libs, "gtk_sort_list_model_get_sorter")
415	core.PuregoSafeRegister(&xSortListModelSetIncremental, libs, "gtk_sort_list_model_set_incremental")
416	core.PuregoSafeRegister(&xSortListModelSetModel, libs, "gtk_sort_list_model_set_model")
417	core.PuregoSafeRegister(&xSortListModelSetSectionSorter, libs, "gtk_sort_list_model_set_section_sorter")
418	core.PuregoSafeRegister(&xSortListModelSetSorter, libs, "gtk_sort_list_model_set_sorter")
419
420}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close