v0.2.1 c0399be

gtksingleselection.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 SingleSelectionClass struct {
17	_ structs.HostLayout
18
19	ParentClass gobject.ObjectClass
20}
21
22func (x *SingleSelectionClass) GoPointer() uintptr {
23	return uintptr(unsafe.Pointer(x))
24}
25
26// A selection model that allows selecting a single item.
27//
28// Note that the selection is *persistent* -- if the selected item is removed
29// and re-added in the same [signal@Gio.ListModel::items-changed] emission, it
30// stays selected. In particular, this means that changing the sort order of an
31// underlying sort model will preserve the selection.
32type SingleSelection struct {
33	gobject.Object
34}
35
36var xSingleSelectionGLibType func() types.GType
37
38func SingleSelectionGLibType() types.GType {
39	return xSingleSelectionGLibType()
40}
41
42func SingleSelectionNewFromInternalPtr(ptr uintptr) *SingleSelection {
43	cls := &SingleSelection{}
44	cls.Ptr = ptr
45	return cls
46}
47
48var xNewSingleSelection func(uintptr) uintptr
49
50// Creates a new selection to handle @model.
51func NewSingleSelection(ModelVar gio.ListModel) *SingleSelection {
52	var cls *SingleSelection
53
54	cret := xNewSingleSelection(ModelVar.GoPointer())
55
56	if cret == 0 {
57		return nil
58	}
59	cls = &SingleSelection{}
60	cls.Ptr = cret
61	return cls
62}
63
64var xSingleSelectionGetAutoselect func(uintptr) bool
65
66// Checks if autoselect has been enabled or disabled via
67// gtk_single_selection_set_autoselect().
68func (x *SingleSelection) GetAutoselect() bool {
69
70	cret := xSingleSelectionGetAutoselect(x.GoPointer())
71	return cret
72}
73
74var xSingleSelectionGetCanUnselect func(uintptr) bool
75
76// If %TRUE, gtk_selection_model_unselect_item() is supported and allows
77// unselecting the selected item.
78func (x *SingleSelection) GetCanUnselect() bool {
79
80	cret := xSingleSelectionGetCanUnselect(x.GoPointer())
81	return cret
82}
83
84var xSingleSelectionGetModel func(uintptr) uintptr
85
86// Gets the model that @self is wrapping.
87func (x *SingleSelection) GetModel() *gio.ListModelBase {
88	var cls *gio.ListModelBase
89
90	cret := xSingleSelectionGetModel(x.GoPointer())
91
92	if cret == 0 {
93		return nil
94	}
95	gobject.IncreaseRef(cret)
96	cls = &gio.ListModelBase{}
97	cls.Ptr = cret
98	return cls
99}
100
101var xSingleSelectionGetSelected func(uintptr) uint
102
103// Gets the position of the selected item.
104//
105// If no item is selected, %GTK_INVALID_LIST_POSITION is returned.
106func (x *SingleSelection) GetSelected() uint {
107
108	cret := xSingleSelectionGetSelected(x.GoPointer())
109	return cret
110}
111
112var xSingleSelectionGetSelectedItem func(uintptr) uintptr
113
114// Gets the selected item.
115//
116// If no item is selected, %NULL is returned.
117func (x *SingleSelection) GetSelectedItem() *gobject.Object {
118	var cls *gobject.Object
119
120	cret := xSingleSelectionGetSelectedItem(x.GoPointer())
121
122	if cret == 0 {
123		return nil
124	}
125	gobject.IncreaseRef(cret)
126	cls = &gobject.Object{}
127	cls.Ptr = cret
128	return cls
129}
130
131var xSingleSelectionSetAutoselect func(uintptr, bool)
132
133// Enables or disables autoselect.
134//
135// If @autoselect is %TRUE, @self will enforce that an item is always
136// selected. It will select a new item when the currently selected
137// item is deleted and it will disallow unselecting the current item.
138func (x *SingleSelection) SetAutoselect(AutoselectVar bool) {
139
140	xSingleSelectionSetAutoselect(x.GoPointer(), AutoselectVar)
141
142}
143
144var xSingleSelectionSetCanUnselect func(uintptr, bool)
145
146// If %TRUE, unselecting the current item via
147// gtk_selection_model_unselect_item() is supported.
148//
149// Note that setting [property@Gtk.SingleSelection:autoselect] will
150// cause unselecting to not work, so it practically makes no sense
151// to set both at the same time.
152func (x *SingleSelection) SetCanUnselect(CanUnselectVar bool) {
153
154	xSingleSelectionSetCanUnselect(x.GoPointer(), CanUnselectVar)
155
156}
157
158var xSingleSelectionSetModel func(uintptr, uintptr)
159
160// Sets the model that @self should wrap.
161//
162// If @model is %NULL, @self will be empty.
163func (x *SingleSelection) SetModel(ModelVar gio.ListModel) {
164
165	xSingleSelectionSetModel(x.GoPointer(), ModelVar.GoPointer())
166
167}
168
169var xSingleSelectionSetSelected func(uintptr, uint)
170
171// Selects the item at the given position.
172//
173// If the list does not have an item at @position or
174// %GTK_INVALID_LIST_POSITION is given, the behavior depends on the
175// value of the [property@Gtk.SingleSelection:autoselect] property:
176// If it is set, no change will occur and the old item will stay
177// selected. If it is unset, the selection will be unset and no item
178// will be selected. This also applies if [property@Gtk.SingleSelection:can-unselect]
179// is set to %FALSE.
180func (x *SingleSelection) SetSelected(PositionVar uint) {
181
182	xSingleSelectionSetSelected(x.GoPointer(), PositionVar)
183
184}
185
186func (c *SingleSelection) GoPointer() uintptr {
187	if c == nil {
188		return 0
189	}
190	return c.Ptr
191}
192
193func (c *SingleSelection) SetGoPointer(ptr uintptr) {
194	c.Ptr = ptr
195}
196
197// SetPropertyAutoselect sets the "autoselect" property.
198// If the selection will always select an item.
199func (x *SingleSelection) SetPropertyAutoselect(value bool) {
200	var v gobject.Value
201	v.Init(gobject.TypeBooleanVal)
202	v.SetBoolean(value)
203	x.SetProperty("autoselect", &v)
204}
205
206// GetPropertyAutoselect gets the "autoselect" property.
207// If the selection will always select an item.
208func (x *SingleSelection) GetPropertyAutoselect() bool {
209	var v gobject.Value
210	x.GetProperty("autoselect", &v)
211	return v.GetBoolean()
212}
213
214// SetPropertyCanUnselect sets the "can-unselect" property.
215// If unselecting the selected item is allowed.
216func (x *SingleSelection) SetPropertyCanUnselect(value bool) {
217	var v gobject.Value
218	v.Init(gobject.TypeBooleanVal)
219	v.SetBoolean(value)
220	x.SetProperty("can-unselect", &v)
221}
222
223// GetPropertyCanUnselect gets the "can-unselect" property.
224// If unselecting the selected item is allowed.
225func (x *SingleSelection) GetPropertyCanUnselect() bool {
226	var v gobject.Value
227	x.GetProperty("can-unselect", &v)
228	return v.GetBoolean()
229}
230
231// GetPropertyNItems gets the "n-items" property.
232// The number of items. See [method@Gio.ListModel.get_n_items].
233func (x *SingleSelection) GetPropertyNItems() uint {
234	var v gobject.Value
235	x.GetProperty("n-items", &v)
236	return v.GetUint()
237}
238
239// SetPropertySelected sets the "selected" property.
240// Position of the selected item.
241func (x *SingleSelection) SetPropertySelected(value uint) {
242	var v gobject.Value
243	v.Init(gobject.TypeUintVal)
244	v.SetUint(value)
245	x.SetProperty("selected", &v)
246}
247
248// GetPropertySelected gets the "selected" property.
249// Position of the selected item.
250func (x *SingleSelection) GetPropertySelected() uint {
251	var v gobject.Value
252	x.GetProperty("selected", &v)
253	return v.GetUint()
254}
255
256// Get the item at @position.
257//
258// If @position is greater than the number of items in @list, %NULL is
259// returned.
260//
261// %NULL is never returned for an index that is smaller than the length
262// of the list.
263//
264// See also: g_list_model_get_n_items()
265func (x *SingleSelection) GetItem(PositionVar uint) uintptr {
266
267	cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
268	return cret
269}
270
271// Gets the type of the items in @list.
272//
273// All items returned from g_list_model_get_item() are of the type
274// returned by this function, or a subtype, or if the type is an
275// interface, they are an implementation of that interface.
276//
277// The item type of a #GListModel can not change during the life of the
278// model.
279func (x *SingleSelection) GetItemType() types.GType {
280
281	cret := gio.XGListModelGetItemType(x.GoPointer())
282	return cret
283}
284
285// Gets the number of items in @list.
286//
287// Depending on the model implementation, calling this function may be
288// less efficient than iterating the list with increasing values for
289// @position until g_list_model_get_item() returns %NULL.
290func (x *SingleSelection) GetNItems() uint {
291
292	cret := gio.XGListModelGetNItems(x.GoPointer())
293	return cret
294}
295
296// Get the item at @position.
297//
298// If @position is greater than the number of items in @list, %NULL is
299// returned.
300//
301// %NULL is never returned for an index that is smaller than the length
302// of the list.
303//
304// This function is meant to be used by language bindings in place
305// of g_list_model_get_item().
306//
307// See also: g_list_model_get_n_items()
308func (x *SingleSelection) GetObject(PositionVar uint) *gobject.Object {
309	var cls *gobject.Object
310
311	cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
312
313	if cret == 0 {
314		return nil
315	}
316	cls = &gobject.Object{}
317	cls.Ptr = cret
318	return cls
319}
320
321// Emits the #GListModel::items-changed signal on @list.
322//
323// This function should only be called by classes implementing
324// #GListModel. It has to be called after the internal representation
325// of @list has been updated, because handlers connected to this signal
326// might query the new state of the list.
327//
328// Implementations must only make changes to the model (as visible to
329// its consumer) in places that will not cause problems for that
330// consumer.  For models that are driven directly by a write API (such
331// as #GListStore), changes can be reported in response to uses of that
332// API.  For models that represent remote data, changes should only be
333// made from a fresh mainloop dispatch.  It is particularly not
334// permitted to make changes in response to a call to the #GListModel
335// consumer API.
336//
337// Stated another way: in general, it is assumed that code making a
338// series of accesses to the model via the API, without returning to the
339// mainloop, and without calling other code, will continue to view the
340// same contents of the model.
341func (x *SingleSelection) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
342
343	gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
344
345}
346
347// Query the section that covers the given position. The number of
348// items in the section can be computed by `out_end - out_start`.
349//
350// If the position is larger than the number of items, a single
351// range from n_items to G_MAXUINT will be returned.
352func (x *SingleSelection) GetSection(PositionVar uint, OutStartVar *uint, OutEndVar *uint) {
353
354	XGtkSectionModelGetSection(x.GoPointer(), PositionVar, OutStartVar, OutEndVar)
355
356}
357
358// This function emits the [signal@Gtk.SectionModel::sections-changed]
359// signal to notify about changes to sections.
360//
361// It must cover all positions that used to be a section start or that
362// are now a section start. It does not have to cover all positions for
363// which the section has changed.
364//
365// The [signal@Gio.ListModel::items-changed] implies the effect of the
366// [signal@Gtk.SectionModel::sections-changed] signal for all the items
367// it covers.
368//
369// It is recommended that when changes to the items cause section changes
370// in a larger range, that the larger range is included in the emission
371// of the [signal@Gio.ListModel::items-changed] instead of emitting
372// two signals.
373func (x *SingleSelection) SectionsChanged(PositionVar uint, NItemsVar uint) {
374
375	XGtkSectionModelSectionsChanged(x.GoPointer(), PositionVar, NItemsVar)
376
377}
378
379// Gets the set containing all currently selected items in the model.
380//
381// This function may be slow, so if you are only interested in single item,
382// consider using [method@Gtk.SelectionModel.is_selected] or if you are only
383// interested in a few, consider [method@Gtk.SelectionModel.get_selection_in_range].
384func (x *SingleSelection) GetSelection() *Bitset {
385
386	cret := XGtkSelectionModelGetSelection(x.GoPointer())
387	return cret
388}
389
390// Gets the set of selected items in a range.
391//
392// This function is an optimization for
393// [method@Gtk.SelectionModel.get_selection] when you are only
394// interested in part of the model's selected state. A common use
395// case is in response to the [signal@Gtk.SelectionModel::selection-changed]
396// signal.
397func (x *SingleSelection) GetSelectionInRange(PositionVar uint, NItemsVar uint) *Bitset {
398
399	cret := XGtkSelectionModelGetSelectionInRange(x.GoPointer(), PositionVar, NItemsVar)
400	return cret
401}
402
403// Checks if the given item is selected.
404func (x *SingleSelection) IsSelected(PositionVar uint) bool {
405
406	cret := XGtkSelectionModelIsSelected(x.GoPointer(), PositionVar)
407	return cret
408}
409
410// Requests to select all items in the model.
411func (x *SingleSelection) SelectAll() bool {
412
413	cret := XGtkSelectionModelSelectAll(x.GoPointer())
414	return cret
415}
416
417// Requests to select an item in the model.
418func (x *SingleSelection) SelectItem(PositionVar uint, UnselectRestVar bool) bool {
419
420	cret := XGtkSelectionModelSelectItem(x.GoPointer(), PositionVar, UnselectRestVar)
421	return cret
422}
423
424// Requests to select a range of items in the model.
425func (x *SingleSelection) SelectRange(PositionVar uint, NItemsVar uint, UnselectRestVar bool) bool {
426
427	cret := XGtkSelectionModelSelectRange(x.GoPointer(), PositionVar, NItemsVar, UnselectRestVar)
428	return cret
429}
430
431// Helper function for implementations of `GtkSelectionModel`.
432//
433// Call this when the selection changes to emit the
434// [signal@Gtk.SelectionModel::selection-changed] signal.
435func (x *SingleSelection) SelectionChanged(PositionVar uint, NItemsVar uint) {
436
437	XGtkSelectionModelSelectionChanged(x.GoPointer(), PositionVar, NItemsVar)
438
439}
440
441// Make selection changes.
442//
443// This is the most advanced selection updating method that allows
444// the most fine-grained control over selection changes. If you can,
445// you should try the simpler versions, as implementations are more
446// likely to implement support for those.
447//
448// Requests that the selection state of all positions set in @mask
449// be updated to the respective value in the @selected bitmask.
450//
451// In pseudocode, it would look something like this:
452//
453// ```c
454// for (i = 0; i < n_items; i++)
455//
456//	{
457//	  // don't change values not in the mask
458//	  if (!gtk_bitset_contains (mask, i))
459//	    continue;
460//
461//	  if (gtk_bitset_contains (selected, i))
462//	    select_item (i);
463//	  else
464//	    unselect_item (i);
465//	}
466//
467// gtk_selection_model_selection_changed (model,
468//
469//	first_changed_item,
470//	n_changed_items);
471//
472// ```
473//
474// @mask and @selected must not be modified. They may refer to the
475// same bitset, which would mean that every item in the set should
476// be selected.
477func (x *SingleSelection) SetSelection(SelectedVar *Bitset, MaskVar *Bitset) bool {
478
479	cret := XGtkSelectionModelSetSelection(x.GoPointer(), SelectedVar, MaskVar)
480	return cret
481}
482
483// Requests to unselect all items in the model.
484func (x *SingleSelection) UnselectAll() bool {
485
486	cret := XGtkSelectionModelUnselectAll(x.GoPointer())
487	return cret
488}
489
490// Requests to unselect an item in the model.
491func (x *SingleSelection) UnselectItem(PositionVar uint) bool {
492
493	cret := XGtkSelectionModelUnselectItem(x.GoPointer(), PositionVar)
494	return cret
495}
496
497// Requests to unselect a range of items in the model.
498func (x *SingleSelection) UnselectRange(PositionVar uint, NItemsVar uint) bool {
499
500	cret := XGtkSelectionModelUnselectRange(x.GoPointer(), PositionVar, NItemsVar)
501	return cret
502}
503
504func init() {
505	core.SetPackageName("GTK", "gtk4")
506	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
507	var libs []uintptr
508	for _, libPath := range core.GetPaths("GTK") {
509		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
510		if err != nil {
511			panic(err)
512		}
513		libs = append(libs, lib)
514	}
515
516	core.PuregoSafeRegister(&xSingleSelectionGLibType, libs, "gtk_single_selection_get_type")
517
518	core.PuregoSafeRegister(&xNewSingleSelection, libs, "gtk_single_selection_new")
519
520	core.PuregoSafeRegister(&xSingleSelectionGetAutoselect, libs, "gtk_single_selection_get_autoselect")
521	core.PuregoSafeRegister(&xSingleSelectionGetCanUnselect, libs, "gtk_single_selection_get_can_unselect")
522	core.PuregoSafeRegister(&xSingleSelectionGetModel, libs, "gtk_single_selection_get_model")
523	core.PuregoSafeRegister(&xSingleSelectionGetSelected, libs, "gtk_single_selection_get_selected")
524	core.PuregoSafeRegister(&xSingleSelectionGetSelectedItem, libs, "gtk_single_selection_get_selected_item")
525	core.PuregoSafeRegister(&xSingleSelectionSetAutoselect, libs, "gtk_single_selection_set_autoselect")
526	core.PuregoSafeRegister(&xSingleSelectionSetCanUnselect, libs, "gtk_single_selection_set_can_unselect")
527	core.PuregoSafeRegister(&xSingleSelectionSetModel, libs, "gtk_single_selection_set_model")
528	core.PuregoSafeRegister(&xSingleSelectionSetSelected, libs, "gtk_single_selection_set_selected")
529
530}

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