v0.2.1 c0399be

gseekable.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/glib"
12	"github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// Provides an interface for implementing seekable functionality on I/O Streams.
16type SeekableIface struct {
17	_ structs.HostLayout
18
19	GIface uintptr
20
21	xTell uintptr
22
23	xCanSeek uintptr
24
25	xSeek uintptr
26
27	xCanTruncate uintptr
28
29	xTruncateFn uintptr
30}
31
32func (x *SeekableIface) GoPointer() uintptr {
33	return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideTell sets the "tell" callback function.
37// Tells the current location within a stream.
38func (x *SeekableIface) OverrideTell(cb func(Seekable) int64) {
39	if cb == nil {
40		x.xTell = 0
41	} else {
42		x.xTell = purego.NewCallback(func(SeekableVarp uintptr) int64 {
43			return cb(&SeekableBase{Ptr: SeekableVarp})
44		})
45	}
46}
47
48// GetTell gets the "tell" callback function.
49// Tells the current location within a stream.
50func (x *SeekableIface) GetTell() func(Seekable) int64 {
51	if x.xTell == 0 {
52		return nil
53	}
54	var rawCallback func(SeekableVarp uintptr) int64
55	purego.RegisterFunc(&rawCallback, x.xTell)
56	return func(SeekableVar Seekable) int64 {
57		return rawCallback(SeekableVar.GoPointer())
58	}
59}
60
61// OverrideCanSeek sets the "can_seek" callback function.
62// Checks if seeking is supported by the stream.
63func (x *SeekableIface) OverrideCanSeek(cb func(Seekable) bool) {
64	if cb == nil {
65		x.xCanSeek = 0
66	} else {
67		x.xCanSeek = purego.NewCallback(func(SeekableVarp uintptr) bool {
68			return cb(&SeekableBase{Ptr: SeekableVarp})
69		})
70	}
71}
72
73// GetCanSeek gets the "can_seek" callback function.
74// Checks if seeking is supported by the stream.
75func (x *SeekableIface) GetCanSeek() func(Seekable) bool {
76	if x.xCanSeek == 0 {
77		return nil
78	}
79	var rawCallback func(SeekableVarp uintptr) bool
80	purego.RegisterFunc(&rawCallback, x.xCanSeek)
81	return func(SeekableVar Seekable) bool {
82		return rawCallback(SeekableVar.GoPointer())
83	}
84}
85
86// OverrideSeek sets the "seek" callback function.
87// Seeks to a location within a stream.
88func (x *SeekableIface) OverrideSeek(cb func(Seekable, int64, glib.SeekType, *Cancellable) bool) {
89	if cb == nil {
90		x.xSeek = 0
91	} else {
92		x.xSeek = purego.NewCallback(func(SeekableVarp uintptr, OffsetVarp int64, TypeVarp glib.SeekType, CancellableVarp uintptr) bool {
93			return cb(&SeekableBase{Ptr: SeekableVarp}, OffsetVarp, TypeVarp, CancellableNewFromInternalPtr(CancellableVarp))
94		})
95	}
96}
97
98// GetSeek gets the "seek" callback function.
99// Seeks to a location within a stream.
100func (x *SeekableIface) GetSeek() func(Seekable, int64, glib.SeekType, *Cancellable) bool {
101	if x.xSeek == 0 {
102		return nil
103	}
104	var rawCallback func(SeekableVarp uintptr, OffsetVarp int64, TypeVarp glib.SeekType, CancellableVarp uintptr) bool
105	purego.RegisterFunc(&rawCallback, x.xSeek)
106	return func(SeekableVar Seekable, OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) bool {
107		return rawCallback(SeekableVar.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer())
108	}
109}
110
111// OverrideCanTruncate sets the "can_truncate" callback function.
112// Checks if truncation is supported by the stream.
113func (x *SeekableIface) OverrideCanTruncate(cb func(Seekable) bool) {
114	if cb == nil {
115		x.xCanTruncate = 0
116	} else {
117		x.xCanTruncate = purego.NewCallback(func(SeekableVarp uintptr) bool {
118			return cb(&SeekableBase{Ptr: SeekableVarp})
119		})
120	}
121}
122
123// GetCanTruncate gets the "can_truncate" callback function.
124// Checks if truncation is supported by the stream.
125func (x *SeekableIface) GetCanTruncate() func(Seekable) bool {
126	if x.xCanTruncate == 0 {
127		return nil
128	}
129	var rawCallback func(SeekableVarp uintptr) bool
130	purego.RegisterFunc(&rawCallback, x.xCanTruncate)
131	return func(SeekableVar Seekable) bool {
132		return rawCallback(SeekableVar.GoPointer())
133	}
134}
135
136// OverrideTruncateFn sets the "truncate_fn" callback function.
137// Truncates a stream.
138func (x *SeekableIface) OverrideTruncateFn(cb func(Seekable, int64, *Cancellable) bool) {
139	if cb == nil {
140		x.xTruncateFn = 0
141	} else {
142		x.xTruncateFn = purego.NewCallback(func(SeekableVarp uintptr, OffsetVarp int64, CancellableVarp uintptr) bool {
143			return cb(&SeekableBase{Ptr: SeekableVarp}, OffsetVarp, CancellableNewFromInternalPtr(CancellableVarp))
144		})
145	}
146}
147
148// GetTruncateFn gets the "truncate_fn" callback function.
149// Truncates a stream.
150func (x *SeekableIface) GetTruncateFn() func(Seekable, int64, *Cancellable) bool {
151	if x.xTruncateFn == 0 {
152		return nil
153	}
154	var rawCallback func(SeekableVarp uintptr, OffsetVarp int64, CancellableVarp uintptr) bool
155	purego.RegisterFunc(&rawCallback, x.xTruncateFn)
156	return func(SeekableVar Seekable, OffsetVar int64, CancellableVar *Cancellable) bool {
157		return rawCallback(SeekableVar.GoPointer(), OffsetVar, CancellableVar.GoPointer())
158	}
159}
160
161// `GSeekable` is implemented by streams (implementations of
162// [class@Gio.InputStream] or [class@Gio.OutputStream]) that support seeking.
163//
164// Seekable streams largely fall into two categories: resizable and
165// fixed-size.
166//
167// `GSeekable` on fixed-sized streams is approximately the same as POSIX
168// [`lseek()`](man:lseek(2)) on a block device (for example: attempting to seek
169// past the end of the device is an error).  Fixed streams typically cannot be
170// truncated.
171//
172// `GSeekable` on resizable streams is approximately the same as POSIX
173// [`lseek()`](man:lseek(2)) on a normal file.  Seeking past the end and writing
174// data will usually cause the stream to resize by introducing zero bytes.
175type Seekable interface {
176	GoPointer() uintptr
177	SetGoPointer(uintptr)
178	CanSeek() bool
179	CanTruncate() bool
180	Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error)
181	Tell() int64
182	Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error)
183}
184
185var xSeekableGLibType func() types.GType
186
187func SeekableGLibType() types.GType {
188	return xSeekableGLibType()
189}
190
191type SeekableBase struct {
192	Ptr uintptr
193}
194
195func (x *SeekableBase) GoPointer() uintptr {
196	if x == nil {
197		return 0
198	}
199	return x.Ptr
200}
201
202func (x *SeekableBase) SetGoPointer(ptr uintptr) {
203	x.Ptr = ptr
204}
205
206// Tests if the stream supports the #GSeekableIface.
207func (x *SeekableBase) CanSeek() bool {
208
209	cret := XGSeekableCanSeek(x.GoPointer())
210	return cret
211}
212
213// Tests if the length of the stream can be adjusted with
214// g_seekable_truncate().
215func (x *SeekableBase) CanTruncate() bool {
216
217	cret := XGSeekableCanTruncate(x.GoPointer())
218	return cret
219}
220
221// Seeks in the stream by the given @offset, modified by @type.
222//
223// Attempting to seek past the end of the stream will have different
224// results depending on if the stream is fixed-sized or resizable.  If
225// the stream is resizable then seeking past the end and then writing
226// will result in zeros filling the empty space.  Seeking past the end
227// of a resizable stream and reading will result in EOF.  Seeking past
228// the end of a fixed-sized stream will fail.
229//
230// Any operation that would result in a negative offset will fail.
231//
232// If @cancellable is not %NULL, then the operation can be cancelled by
233// triggering the cancellable object from another thread. If the operation
234// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
235func (x *SeekableBase) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) {
236	var cerr *glib.Error
237
238	cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr)
239	if cerr == nil {
240		return cret, nil
241	}
242	return cret, cerr
243
244}
245
246// Tells the current position within the stream.
247func (x *SeekableBase) Tell() int64 {
248
249	cret := XGSeekableTell(x.GoPointer())
250	return cret
251}
252
253// Sets the length of the stream to @offset. If the stream was previously
254// larger than @offset, the extra data is discarded. If the stream was
255// previously shorter than @offset, it is extended with NUL ('\0') bytes.
256//
257// If @cancellable is not %NULL, then the operation can be cancelled by
258// triggering the cancellable object from another thread. If the operation
259// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
260// operation was partially finished when the operation was cancelled the
261// partial result will be returned, without an error.
262func (x *SeekableBase) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) {
263	var cerr *glib.Error
264
265	cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr)
266	if cerr == nil {
267		return cret, nil
268	}
269	return cret, cerr
270
271}
272
273var XGSeekableCanSeek func(uintptr) bool
274var XGSeekableCanTruncate func(uintptr) bool
275var XGSeekableSeek func(uintptr, int64, glib.SeekType, uintptr, **glib.Error) bool
276var XGSeekableTell func(uintptr) int64
277var XGSeekableTruncate func(uintptr, int64, uintptr, **glib.Error) bool
278
279func init() {
280	core.SetPackageName("GIO", "gio-2.0")
281	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
282	var libs []uintptr
283	for _, libPath := range core.GetPaths("GIO") {
284		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
285		if err != nil {
286			panic(err)
287		}
288		libs = append(libs, lib)
289	}
290
291	core.PuregoSafeRegister(&xSeekableGLibType, libs, "g_seekable_get_type")
292
293	core.PuregoSafeRegister(&XGSeekableCanSeek, libs, "g_seekable_can_seek")
294	core.PuregoSafeRegister(&XGSeekableCanTruncate, libs, "g_seekable_can_truncate")
295	core.PuregoSafeRegister(&XGSeekableSeek, libs, "g_seekable_seek")
296	core.PuregoSafeRegister(&XGSeekableTell, libs, "g_seekable_tell")
297	core.PuregoSafeRegister(&XGSeekableTruncate, libs, "g_seekable_truncate")
298
299}

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