v0.2.2 9100209

gasyncinitable.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"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// Provides an interface for asynchronous initializing object such that
17// initialization may fail.
18type AsyncInitableIface struct {
19	_ structs.HostLayout
20
21	GIface uintptr
22
23	xInitAsync uintptr
24
25	xInitFinish uintptr
26}
27
28func (x *AsyncInitableIface) GoPointer() uintptr {
29	return uintptr(unsafe.Pointer(x))
30}
31
32// OverrideInitAsync sets the "init_async" callback function.
33// Starts initialization of the object.
34func (x *AsyncInitableIface) OverrideInitAsync(cb func(AsyncInitable, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
35	if cb == nil {
36		x.xInitAsync = 0
37	} else {
38		x.xInitAsync = purego.NewCallback(func(InitableVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
39			cb(&AsyncInitableBase{Ptr: InitableVarp}, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
40		})
41	}
42}
43
44// GetInitAsync gets the "init_async" callback function.
45// Starts initialization of the object.
46func (x *AsyncInitableIface) GetInitAsync() func(AsyncInitable, int, *Cancellable, *AsyncReadyCallback, uintptr) {
47	if x.xInitAsync == 0 {
48		return nil
49	}
50	var rawCallback func(InitableVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
51	purego.RegisterFunc(&rawCallback, x.xInitAsync)
52	return func(InitableVar AsyncInitable, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
53		rawCallback(InitableVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
54	}
55}
56
57// OverrideInitFinish sets the "init_finish" callback function.
58// Finishes initialization of the object.
59func (x *AsyncInitableIface) OverrideInitFinish(cb func(AsyncInitable, AsyncResult) bool) {
60	if cb == nil {
61		x.xInitFinish = 0
62	} else {
63		x.xInitFinish = purego.NewCallback(func(InitableVarp uintptr, ResVarp uintptr) bool {
64			return cb(&AsyncInitableBase{Ptr: InitableVarp}, &AsyncResultBase{Ptr: ResVarp})
65		})
66	}
67}
68
69// GetInitFinish gets the "init_finish" callback function.
70// Finishes initialization of the object.
71func (x *AsyncInitableIface) GetInitFinish() func(AsyncInitable, AsyncResult) bool {
72	if x.xInitFinish == 0 {
73		return nil
74	}
75	var rawCallback func(InitableVarp uintptr, ResVarp uintptr) bool
76	purego.RegisterFunc(&rawCallback, x.xInitFinish)
77	return func(InitableVar AsyncInitable, ResVar AsyncResult) bool {
78		return rawCallback(InitableVar.GoPointer(), ResVar.GoPointer())
79	}
80}
81
82// `GAsyncInitable` is an interface for asynchronously initializable objects.
83//
84// This is the asynchronous version of [iface@Gio.Initable]; it behaves the same
85// in all ways except that initialization is asynchronous. For more details
86// see the descriptions on `GInitable`.
87//
88// A class may implement both the `GInitable` and `GAsyncInitable` interfaces.
89//
90// Users of objects implementing this are not intended to use the interface
91// method directly; instead it will be used automatically in various ways.
92// For C applications you generally just call [func@Gio.AsyncInitable.new_async]
93// directly, or indirectly via a foo_thing_new_async() wrapper. This will call
94// [method@Gio.AsyncInitable.init_async] under the covers, calling back with `NULL`
95// and a set `GError` on failure.
96//
97// A typical implementation might look something like this:
98//
99// ```c
100//
101//	enum {
102//	   NOT_INITIALIZED,
103//	   INITIALIZING,
104//	   INITIALIZED
105//	};
106//
107// static void
108// _foo_ready_cb (Foo *self)
109//
110//	{
111//	  GList *l;
112//
113//	  self->priv->state = INITIALIZED;
114//
115//	  for (l = self->priv->init_results; l != NULL; l = l->next)
116//	    {
117//	      GTask *task = l->data;
118//
119//	      if (self->priv->success)
120//	        g_task_return_boolean (task, TRUE);
121//	      else
122//	        g_task_return_new_error (task, ...);
123//	      g_object_unref (task);
124//	    }
125//
126//	  g_list_free (self->priv->init_results);
127//	  self->priv->init_results = NULL;
128//	}
129//
130// static void
131// foo_init_async (GAsyncInitable       *initable,
132//
133//	int                   io_priority,
134//	GCancellable         *cancellable,
135//	GAsyncReadyCallback   callback,
136//	gpointer              user_data)
137//
138//	{
139//	  Foo *self = FOO (initable);
140//	  GTask *task;
141//
142//	  task = g_task_new (initable, cancellable, callback, user_data);
143//	  g_task_set_name (task, G_STRFUNC);
144//
145//	  switch (self->priv->state)
146//	    {
147//	      case NOT_INITIALIZED:
148//	        _foo_get_ready (self);
149//	        self->priv->init_results = g_list_append (self->priv->init_results,
150//	                                                  task);
151//	        self->priv->state = INITIALIZING;
152//	        break;
153//	      case INITIALIZING:
154//	        self->priv->init_results = g_list_append (self->priv->init_results,
155//	                                                  task);
156//	        break;
157//	      case INITIALIZED:
158//	        if (!self->priv->success)
159//	          g_task_return_new_error (task, ...);
160//	        else
161//	          g_task_return_boolean (task, TRUE);
162//	        g_object_unref (task);
163//	        break;
164//	    }
165//	}
166//
167// static gboolean
168// foo_init_finish (GAsyncInitable       *initable,
169//
170//	GAsyncResult         *result,
171//	GError              **error)
172//
173//	{
174//	  g_return_val_if_fail (g_task_is_valid (result, initable), FALSE);
175//
176//	  return g_task_propagate_boolean (G_TASK (result), error);
177//	}
178//
179// static void
180// foo_async_initable_iface_init (gpointer g_iface,
181//
182//	gpointer data)
183//
184//	{
185//	  GAsyncInitableIface *iface = g_iface;
186//
187//	  iface->init_async = foo_init_async;
188//	  iface->init_finish = foo_init_finish;
189//	}
190//
191// ```
192type AsyncInitable interface {
193	GoPointer() uintptr
194	SetGoPointer(uintptr)
195	InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr)
196	InitFinish(ResVar AsyncResult) (bool, error)
197	NewFinish(ResVar AsyncResult) (*gobject.Object, error)
198}
199
200var xAsyncInitableGLibType func() types.GType
201
202func AsyncInitableGLibType() types.GType {
203	return xAsyncInitableGLibType()
204}
205
206type AsyncInitableBase struct {
207	Ptr uintptr
208}
209
210func (x *AsyncInitableBase) GoPointer() uintptr {
211	if x == nil {
212		return 0
213	}
214	return x.Ptr
215}
216
217func (x *AsyncInitableBase) SetGoPointer(ptr uintptr) {
218	x.Ptr = ptr
219}
220
221// Starts asynchronous initialization of the object implementing the
222// interface. This must be done before any real use of the object after
223// initial construction. If the object also implements #GInitable you can
224// optionally call g_initable_init() instead.
225//
226// This method is intended for language bindings. If writing in C,
227// g_async_initable_new_async() should typically be used instead.
228//
229// When the initialization is finished, @callback will be called. You can
230// then call g_async_initable_init_finish() to get the result of the
231// initialization.
232//
233// Implementations may also support cancellation. If @cancellable is not
234// %NULL, then initialization can be cancelled by triggering the cancellable
235// object from another thread. If the operation was cancelled, the error
236// %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL, and
237// the object doesn't support cancellable initialization, the error
238// %G_IO_ERROR_NOT_SUPPORTED will be returned.
239//
240// As with #GInitable, if the object is not initialized, or initialization
241// returns with an error, then all operations on the object except
242// g_object_ref() and g_object_unref() are considered to be invalid, and
243// have undefined behaviour. They will often fail with g_critical() or
244// g_warning(), but this must not be relied on.
245//
246// Callers should not assume that a class which implements #GAsyncInitable can
247// be initialized multiple times; for more information, see g_initable_init().
248// If a class explicitly supports being initialized multiple times,
249// implementation requires yielding all subsequent calls to init_async() on the
250// results of the first call.
251//
252// For classes that also support the #GInitable interface, the default
253// implementation of this method will run the g_initable_init() function
254// in a thread, so if you want to support asynchronous initialization via
255// threads, just implement the #GAsyncInitable interface without overriding
256// any interface methods.
257func (x *AsyncInitableBase) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
258
259	XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
260
261}
262
263// Finishes asynchronous initialization and returns the result.
264// See g_async_initable_init_async().
265func (x *AsyncInitableBase) InitFinish(ResVar AsyncResult) (bool, error) {
266	var cerr *glib.Error
267
268	cret := XGAsyncInitableInitFinish(x.GoPointer(), ResVar.GoPointer(), &cerr)
269	if cerr == nil {
270		return cret, nil
271	}
272	return cret, cerr
273
274}
275
276// Finishes the async construction for the various g_async_initable_new
277// calls, returning the created object or %NULL on error.
278func (x *AsyncInitableBase) NewFinish(ResVar AsyncResult) (*gobject.Object, error) {
279	var cls *gobject.Object
280	var cerr *glib.Error
281
282	cret := XGAsyncInitableNewFinish(x.GoPointer(), ResVar.GoPointer(), &cerr)
283
284	if cret == 0 {
285		return nil, cerr
286	}
287	cls = &gobject.Object{}
288	cls.Ptr = cret
289	if cerr == nil {
290		return cls, nil
291	}
292	return cls, cerr
293
294}
295
296var XGAsyncInitableInitAsync func(uintptr, int, uintptr, uintptr, uintptr)
297var XGAsyncInitableInitFinish func(uintptr, uintptr, **glib.Error) bool
298var XGAsyncInitableNewFinish func(uintptr, uintptr, **glib.Error) uintptr
299
300var xAsyncInitableNewvAsync func(types.GType, uint, *gobject.Parameter, int, uintptr, uintptr, uintptr)
301
302// Helper function for constructing #GAsyncInitable object. This is
303// similar to g_object_newv() but also initializes the object asynchronously.
304//
305// When the initialization is finished, @callback will be called. You can
306// then call g_async_initable_new_finish() to get the new object and check
307// for any errors.
308func AsyncInitableNewvAsync(ObjectTypeVar types.GType, NParametersVar uint, ParametersVar *gobject.Parameter, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
309
310	var CallbackVarRef uintptr
311	if CallbackVar != nil {
312		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
313		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
314			CallbackVarRef = cbRefPtr
315		} else {
316			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
317				cbFn := *CallbackVar
318				cbFn(arg0, arg1, arg2)
319			}
320			CallbackVarRef = purego.NewCallback(fcb)
321			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
322		}
323	}
324
325	xAsyncInitableNewvAsync(ObjectTypeVar, NParametersVar, ParametersVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
326
327}
328
329func init() {
330	core.SetPackageName("GIO", "gio-2.0")
331	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
332	var libs []uintptr
333	for _, libPath := range core.GetPaths("GIO") {
334		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
335		if err != nil {
336			panic(err)
337		}
338		libs = append(libs, lib)
339	}
340
341	core.PuregoSafeRegister(&xAsyncInitableNewvAsync, libs, "g_async_initable_newv_async")
342
343	core.PuregoSafeRegister(&xAsyncInitableGLibType, libs, "g_async_initable_get_type")
344
345	core.PuregoSafeRegister(&XGAsyncInitableInitAsync, libs, "g_async_initable_init_async")
346	core.PuregoSafeRegister(&XGAsyncInitableInitFinish, libs, "g_async_initable_init_finish")
347	core.PuregoSafeRegister(&XGAsyncInitableNewFinish, libs, "g_async_initable_new_finish")
348
349}

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