v0.2.1 c0399be

glistmodel.go RawHistoryFolder

1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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/gobject"
12	"github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// The virtual function table for #GListModel.
16type ListModelInterface struct {
17	_ structs.HostLayout
18
19	GIface uintptr
20
21	xGetItemType uintptr
22
23	xGetNItems uintptr
24
25	xGetItem uintptr
26}
27
28func (x *ListModelInterface) GoPointer() uintptr {
29	return uintptr(unsafe.Pointer(x))
30}
31
32// OverrideGetItemType sets the "get_item_type" callback function.
33// the virtual function pointer for g_list_model_get_item_type()
34func (x *ListModelInterface) OverrideGetItemType(cb func(ListModel) types.GType) {
35	if cb == nil {
36		x.xGetItemType = 0
37	} else {
38		x.xGetItemType = purego.NewCallback(func(ListVarp uintptr) types.GType {
39			return cb(&ListModelBase{Ptr: ListVarp})
40		})
41	}
42}
43
44// GetGetItemType gets the "get_item_type" callback function.
45// the virtual function pointer for g_list_model_get_item_type()
46func (x *ListModelInterface) GetGetItemType() func(ListModel) types.GType {
47	if x.xGetItemType == 0 {
48		return nil
49	}
50	var rawCallback func(ListVarp uintptr) types.GType
51	purego.RegisterFunc(&rawCallback, x.xGetItemType)
52	return func(ListVar ListModel) types.GType {
53		return rawCallback(ListVar.GoPointer())
54	}
55}
56
57// OverrideGetNItems sets the "get_n_items" callback function.
58// the virtual function pointer for g_list_model_get_n_items()
59func (x *ListModelInterface) OverrideGetNItems(cb func(ListModel) uint) {
60	if cb == nil {
61		x.xGetNItems = 0
62	} else {
63		x.xGetNItems = purego.NewCallback(func(ListVarp uintptr) uint {
64			return cb(&ListModelBase{Ptr: ListVarp})
65		})
66	}
67}
68
69// GetGetNItems gets the "get_n_items" callback function.
70// the virtual function pointer for g_list_model_get_n_items()
71func (x *ListModelInterface) GetGetNItems() func(ListModel) uint {
72	if x.xGetNItems == 0 {
73		return nil
74	}
75	var rawCallback func(ListVarp uintptr) uint
76	purego.RegisterFunc(&rawCallback, x.xGetNItems)
77	return func(ListVar ListModel) uint {
78		return rawCallback(ListVar.GoPointer())
79	}
80}
81
82// OverrideGetItem sets the "get_item" callback function.
83// the virtual function pointer for g_list_model_get_item()
84func (x *ListModelInterface) OverrideGetItem(cb func(ListModel, uint) *gobject.Object) {
85	if cb == nil {
86		x.xGetItem = 0
87	} else {
88		x.xGetItem = purego.NewCallback(func(ListVarp uintptr, PositionVarp uint) uintptr {
89			ret := cb(&ListModelBase{Ptr: ListVarp}, PositionVarp)
90			if ret == nil {
91				return 0
92			}
93			return ret.GoPointer()
94		})
95	}
96}
97
98// GetGetItem gets the "get_item" callback function.
99// the virtual function pointer for g_list_model_get_item()
100func (x *ListModelInterface) GetGetItem() func(ListModel, uint) *gobject.Object {
101	if x.xGetItem == 0 {
102		return nil
103	}
104	var rawCallback func(ListVarp uintptr, PositionVarp uint) uintptr
105	purego.RegisterFunc(&rawCallback, x.xGetItem)
106	return func(ListVar ListModel, PositionVar uint) *gobject.Object {
107		rawRet := rawCallback(ListVar.GoPointer(), PositionVar)
108		if rawRet == 0 {
109			return nil
110		}
111		ret := &gobject.Object{}
112		ret.Ptr = rawRet
113		return ret
114	}
115}
116
117// `GListModel` is an interface that represents a mutable list of
118// [class@GObject.Object]. Its main intention is as a model for various widgets
119// in user interfaces, such as list views, but it can also be used as a
120// convenient method of returning lists of data, with support for
121// updates.
122//
123// Each object in the list may also report changes in itself via some
124// mechanism (normally the [signal@GObject.Object::notify] signal).  Taken
125// together with the [signal@Gio.ListModel::items-changed] signal, this provides
126// for a list that can change its membership, and in which the members can
127// change their individual properties.
128//
129// A good example would be the list of visible wireless network access
130// points, where each access point can report dynamic properties such as
131// signal strength.
132//
133// It is important to note that the `GListModel` itself does not report
134// changes to the individual items.  It only reports changes to the list
135// membership.  If you want to observe changes to the objects themselves
136// then you need to connect signals to the objects that you are
137// interested in.
138//
139// All items in a `GListModel` are of (or derived from) the same type.
140// [method@Gio.ListModel.get_item_type] returns that type.  The type may be an
141// interface, in which case all objects in the list must implement it.
142//
143// The semantics are close to that of an array:
144// [method@Gio.ListModel.get_n_items] returns the number of items in the list
145// and [method@Gio.ListModel.get_item] returns an item at a (0-based) position.
146// In order to allow implementations to calculate the list length lazily,
147// you can also iterate over items: starting from 0, repeatedly call
148// [method@Gio.ListModel.get_item] until it returns `NULL`.
149//
150// An implementation may create objects lazily, but must take care to
151// return the same object for a given position until all references to
152// it are gone.
153//
154// On the other side, a consumer is expected only to hold references on
155// objects that are currently ‘user visible’, in order to facilitate the
156// maximum level of laziness in the implementation of the list and to
157// reduce the required number of signal connections at a given time.
158//
159// This interface is intended only to be used from a single thread.  The
160// thread in which it is appropriate to use it depends on the particular
161// implementation, but typically it will be from the thread that owns
162// the thread-default main context (see
163// [method@GLib.MainContext.push_thread_default]) in effect at the time that the
164// model was created.
165//
166// Over time, it has established itself as good practice for list model
167// implementations to provide properties `item-type` and `n-items` to
168// ease working with them. While it is not required, it is recommended
169// that implementations provide these two properties. They should return
170// the values of [method@Gio.ListModel.get_item_type] and
171// [method@Gio.ListModel.get_n_items] respectively and be defined as such:
172//
173// ```c
174// properties[PROP_ITEM_TYPE] =
175//
176//	g_param_spec_gtype ("item-type", NULL, NULL, G_TYPE_OBJECT,
177//	                    G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
178//
179// properties[PROP_N_ITEMS] =
180//
181//	g_param_spec_uint ("n-items", NULL, NULL, 0, G_MAXUINT, 0,
182//	                   G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
183//
184// ```
185type ListModel interface {
186	GoPointer() uintptr
187	SetGoPointer(uintptr)
188	GetItem(PositionVar uint) uintptr
189	GetItemType() types.GType
190	GetNItems() uint
191	GetObject(PositionVar uint) *gobject.Object
192	ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint)
193}
194
195var xListModelGLibType func() types.GType
196
197func ListModelGLibType() types.GType {
198	return xListModelGLibType()
199}
200
201type ListModelBase struct {
202	Ptr uintptr
203}
204
205func (x *ListModelBase) GoPointer() uintptr {
206	if x == nil {
207		return 0
208	}
209	return x.Ptr
210}
211
212func (x *ListModelBase) SetGoPointer(ptr uintptr) {
213	x.Ptr = ptr
214}
215
216// Get the item at @position.
217//
218// If @position is greater than the number of items in @list, %NULL is
219// returned.
220//
221// %NULL is never returned for an index that is smaller than the length
222// of the list.
223//
224// See also: g_list_model_get_n_items()
225func (x *ListModelBase) GetItem(PositionVar uint) uintptr {
226
227	cret := XGListModelGetItem(x.GoPointer(), PositionVar)
228	return cret
229}
230
231// Gets the type of the items in @list.
232//
233// All items returned from g_list_model_get_item() are of the type
234// returned by this function, or a subtype, or if the type is an
235// interface, they are an implementation of that interface.
236//
237// The item type of a #GListModel can not change during the life of the
238// model.
239func (x *ListModelBase) GetItemType() types.GType {
240
241	cret := XGListModelGetItemType(x.GoPointer())
242	return cret
243}
244
245// Gets the number of items in @list.
246//
247// Depending on the model implementation, calling this function may be
248// less efficient than iterating the list with increasing values for
249// @position until g_list_model_get_item() returns %NULL.
250func (x *ListModelBase) GetNItems() uint {
251
252	cret := XGListModelGetNItems(x.GoPointer())
253	return cret
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// This function is meant to be used by language bindings in place
265// of g_list_model_get_item().
266//
267// See also: g_list_model_get_n_items()
268func (x *ListModelBase) GetObject(PositionVar uint) *gobject.Object {
269	var cls *gobject.Object
270
271	cret := XGListModelGetObject(x.GoPointer(), PositionVar)
272
273	if cret == 0 {
274		return nil
275	}
276	cls = &gobject.Object{}
277	cls.Ptr = cret
278	return cls
279}
280
281// Emits the #GListModel::items-changed signal on @list.
282//
283// This function should only be called by classes implementing
284// #GListModel. It has to be called after the internal representation
285// of @list has been updated, because handlers connected to this signal
286// might query the new state of the list.
287//
288// Implementations must only make changes to the model (as visible to
289// its consumer) in places that will not cause problems for that
290// consumer.  For models that are driven directly by a write API (such
291// as #GListStore), changes can be reported in response to uses of that
292// API.  For models that represent remote data, changes should only be
293// made from a fresh mainloop dispatch.  It is particularly not
294// permitted to make changes in response to a call to the #GListModel
295// consumer API.
296//
297// Stated another way: in general, it is assumed that code making a
298// series of accesses to the model via the API, without returning to the
299// mainloop, and without calling other code, will continue to view the
300// same contents of the model.
301func (x *ListModelBase) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
302
303	XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
304
305}
306
307var XGListModelGetItem func(uintptr, uint) uintptr
308var XGListModelGetItemType func(uintptr) types.GType
309var XGListModelGetNItems func(uintptr) uint
310var XGListModelGetObject func(uintptr, uint) uintptr
311var XGListModelItemsChanged func(uintptr, uint, uint, uint)
312
313func init() {
314	core.SetPackageName("GIO", "gio-2.0")
315	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
316	var libs []uintptr
317	for _, libPath := range core.GetPaths("GIO") {
318		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
319		if err != nil {
320			panic(err)
321		}
322		libs = append(libs, lib)
323	}
324
325	core.PuregoSafeRegister(&xListModelGLibType, libs, "g_list_model_get_type")
326
327	core.PuregoSafeRegister(&XGListModelGetItem, libs, "g_list_model_get_item")
328	core.PuregoSafeRegister(&XGListModelGetItemType, libs, "g_list_model_get_item_type")
329	core.PuregoSafeRegister(&XGListModelGetNItems, libs, "g_list_model_get_n_items")
330	core.PuregoSafeRegister(&XGListModelGetObject, libs, "g_list_model_get_object")
331	core.PuregoSafeRegister(&XGListModelItemsChanged, libs, "g_list_model_items_changed")
332
333}

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