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
16type SimpleAsyncResultClass struct {
17 _ structs.HostLayout
18}
19
20func (x *SimpleAsyncResultClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24var xSimpleAsyncReportErrorInIdle func(uintptr, uintptr, uintptr, glib.Quark, int, string, ...interface{})
25
26// Reports an error in an asynchronous function in an idle function by
27// directly setting the contents of the #GAsyncResult with the given error
28// information.
29func SimpleAsyncReportErrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) {
30
31 var CallbackVarRef uintptr
32 if CallbackVar != nil {
33 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
34 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
35 CallbackVarRef = cbRefPtr
36 } else {
37 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
38 cbFn := *CallbackVar
39 cbFn(arg0, arg1, arg2)
40 }
41 CallbackVarRef = purego.NewCallback(fcb)
42 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
43 }
44 }
45
46 xSimpleAsyncReportErrorInIdle(ObjectVar.GoPointer(), CallbackVarRef, UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...)
47
48}
49
50var xSimpleAsyncReportGerrorInIdle func(uintptr, uintptr, uintptr, *glib.Error)
51
52// Reports an error in an idle function. Similar to
53// g_simple_async_report_error_in_idle(), but takes a #GError rather
54// than building a new one.
55func SimpleAsyncReportGerrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) {
56
57 var CallbackVarRef uintptr
58 if CallbackVar != nil {
59 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
60 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
61 CallbackVarRef = cbRefPtr
62 } else {
63 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
64 cbFn := *CallbackVar
65 cbFn(arg0, arg1, arg2)
66 }
67 CallbackVarRef = purego.NewCallback(fcb)
68 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
69 }
70 }
71
72 xSimpleAsyncReportGerrorInIdle(ObjectVar.GoPointer(), CallbackVarRef, UserDataVar, ErrorVar)
73
74}
75
76var xSimpleAsyncReportTakeGerrorInIdle func(uintptr, uintptr, uintptr, *glib.Error)
77
78// Reports an error in an idle function. Similar to
79// g_simple_async_report_gerror_in_idle(), but takes over the caller's
80// ownership of @error, so the caller does not have to free it any more.
81func SimpleAsyncReportTakeGerrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) {
82
83 var CallbackVarRef uintptr
84 if CallbackVar != nil {
85 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
86 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
87 CallbackVarRef = cbRefPtr
88 } else {
89 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
90 cbFn := *CallbackVar
91 cbFn(arg0, arg1, arg2)
92 }
93 CallbackVarRef = purego.NewCallback(fcb)
94 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
95 }
96 }
97
98 xSimpleAsyncReportTakeGerrorInIdle(ObjectVar.GoPointer(), CallbackVarRef, UserDataVar, ErrorVar)
99
100}
101
102// As of GLib 2.46, `GSimpleAsyncResult` is deprecated in favor of
103// [class@Gio.Task], which provides a simpler API.
104//
105// `GSimpleAsyncResult` implements [iface@Gio.AsyncResult].
106//
107// `GSimpleAsyncResult` handles [type@Gio.AsyncReadyCallback]s, error
108// reporting, operation cancellation and the final state of an operation,
109// completely transparent to the application. Results can be returned
110// as a pointer e.g. for functions that return data that is collected
111// asynchronously, a boolean value for checking the success or failure
112// of an operation, or a `gssize` for operations which return the number
113// of bytes modified by the operation; all of the simple return cases
114// are covered.
115//
116// Most of the time, an application will not need to know of the details
117// of this API; it is handled transparently, and any necessary operations
118// are handled by [iface@Gio.AsyncResult]’s interface. However, if implementing
119// a new GIO module, for writing language bindings, or for complex
120// applications that need better control of how asynchronous operations
121// are completed, it is important to understand this functionality.
122//
123// `GSimpleAsyncResult`s are tagged with the calling function to ensure
124// that asynchronous functions and their finishing functions are used
125// together correctly.
126//
127// To create a new `GSimpleAsyncResult`, call [ctor@Gio.SimpleAsyncResult.new].
128// If the result needs to be created for a `GError`, use
129// [ctor@Gio.SimpleAsyncResult.new_from_error] or
130// [ctor@Gio.SimpleAsyncResult.new_take_error]. If a `GError` is not available
131// (e.g. the asynchronous operation doesn’t take a `GError` argument),
132// but the result still needs to be created for an error condition, use
133// [ctor@Gio.SimpleAsyncResult.new_error] (or
134// [method@Gio.SimpleAsyncResult.set_error_va] if your application or binding
135// requires passing a variable argument list directly), and the error can then
136// be propagated through the use of
137// [method@Gio.SimpleAsyncResult.propagate_error].
138//
139// An asynchronous operation can be made to ignore a cancellation event by
140// calling [method@Gio.SimpleAsyncResult.set_handle_cancellation] with a
141// `GSimpleAsyncResult` for the operation and `FALSE`. This is useful for
142// operations that are dangerous to cancel, such as close (which would
143// cause a leak if cancelled before being run).
144//
145// `GSimpleAsyncResult` can integrate into GLib’s event loop,
146// [type@GLib.MainLoop], or it can use [type@GLib.Thread]s.
147// [method@Gio.SimpleAsyncResult.complete] will finish an I/O task directly
148// from the point where it is called.
149// [method@Gio.SimpleAsyncResult.complete_in_idle] will finish it from an idle
150// handler in the thread-default main context (see
151// [method@GLib.MainContext.push_thread_default]) where the `GSimpleAsyncResult`
152// was created. [method@Gio.SimpleAsyncResult.run_in_thread] will run the job in
153// a separate thread and then use
154// [method@Gio.SimpleAsyncResult.complete_in_idle] to deliver the result.
155//
156// To set the results of an asynchronous function,
157// [method@Gio.SimpleAsyncResult.set_op_res_gpointer],
158// [method@Gio.SimpleAsyncResult.set_op_res_gboolean], and
159// [method@Gio.SimpleAsyncResult.set_op_res_gssize]
160// are provided, setting the operation's result to a `gpointer`, `gboolean`, or
161// `gssize`, respectively.
162//
163// Likewise, to get the result of an asynchronous function,
164// [method@Gio.SimpleAsyncResult.get_op_res_gpointer],
165// [method@Gio.SimpleAsyncResult.get_op_res_gboolean], and
166// [method@Gio.SimpleAsyncResult.get_op_res_gssize] are
167// provided, getting the operation’s result as a `gpointer`, `gboolean`, and
168// `gssize`, respectively.
169//
170// For the details of the requirements implementations must respect, see
171// [iface@Gio.AsyncResult]. A typical implementation of an asynchronous
172// operation using `GSimpleAsyncResult` looks something like this:
173//
174// ```c
175// static void
176// baked_cb (Cake *cake,
177//
178// gpointer user_data)
179//
180// {
181// // In this example, this callback is not given a reference to the cake,
182// // so the GSimpleAsyncResult has to take a reference to it.
183// GSimpleAsyncResult *result = user_data;
184//
185// if (cake == NULL)
186// g_simple_async_result_set_error (result,
187// BAKER_ERRORS,
188// BAKER_ERROR_NO_FLOUR,
189// "Go to the supermarket");
190// else
191// g_simple_async_result_set_op_res_gpointer (result,
192// g_object_ref (cake),
193// g_object_unref);
194//
195//
196// // In this example, we assume that baked_cb is called as a callback from
197// // the mainloop, so it's safe to complete the operation synchronously here.
198// // If, however, _baker_prepare_cake () might call its callback without
199// // first returning to the mainloop — inadvisable, but some APIs do so —
200// // we would need to use g_simple_async_result_complete_in_idle().
201// g_simple_async_result_complete (result);
202// g_object_unref (result);
203// }
204//
205// void
206// baker_bake_cake_async (Baker *self,
207//
208// guint radius,
209// GAsyncReadyCallback callback,
210// gpointer user_data)
211//
212// {
213// GSimpleAsyncResult *simple;
214// Cake *cake;
215//
216// if (radius < 3)
217// {
218// g_simple_async_report_error_in_idle (G_OBJECT (self),
219// callback,
220// user_data,
221// BAKER_ERRORS,
222// BAKER_ERROR_TOO_SMALL,
223// "%ucm radius cakes are silly",
224// radius);
225// return;
226// }
227//
228// simple = g_simple_async_result_new (G_OBJECT (self),
229// callback,
230// user_data,
231// baker_bake_cake_async);
232// cake = _baker_get_cached_cake (self, radius);
233//
234// if (cake != NULL)
235// {
236// g_simple_async_result_set_op_res_gpointer (simple,
237// g_object_ref (cake),
238// g_object_unref);
239// g_simple_async_result_complete_in_idle (simple);
240// g_object_unref (simple);
241// // Drop the reference returned by _baker_get_cached_cake();
242// // the GSimpleAsyncResult has taken its own reference.
243// g_object_unref (cake);
244// return;
245// }
246//
247// _baker_prepare_cake (self, radius, baked_cb, simple);
248// }
249//
250// Cake *
251// baker_bake_cake_finish (Baker *self,
252//
253// GAsyncResult *result,
254// GError **error)
255//
256// {
257// GSimpleAsyncResult *simple;
258// Cake *cake;
259//
260// g_return_val_if_fail (g_simple_async_result_is_valid (result,
261// G_OBJECT (self),
262// baker_bake_cake_async),
263// NULL);
264//
265// simple = (GSimpleAsyncResult *) result;
266//
267// if (g_simple_async_result_propagate_error (simple, error))
268// return NULL;
269//
270// cake = CAKE (g_simple_async_result_get_op_res_gpointer (simple));
271// return g_object_ref (cake);
272// }
273//
274// ```
275type SimpleAsyncResult struct {
276 gobject.Object
277}
278
279var xSimpleAsyncResultGLibType func() types.GType
280
281func SimpleAsyncResultGLibType() types.GType {
282 return xSimpleAsyncResultGLibType()
283}
284
285func SimpleAsyncResultNewFromInternalPtr(ptr uintptr) *SimpleAsyncResult {
286 cls := &SimpleAsyncResult{}
287 cls.Ptr = ptr
288 return cls
289}
290
291var xNewSimpleAsyncResult func(uintptr, uintptr, uintptr, uintptr) uintptr
292
293// Creates a #GSimpleAsyncResult.
294//
295// The common convention is to create the #GSimpleAsyncResult in the
296// function that starts the asynchronous operation and use that same
297// function as the @source_tag.
298//
299// If your operation supports cancellation with #GCancellable (which it
300// probably should) then you should provide the user's cancellable to
301// g_simple_async_result_set_check_cancellable() immediately after
302// this function returns.
303func NewSimpleAsyncResult(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, SourceTagVar uintptr) *SimpleAsyncResult {
304 var cls *SimpleAsyncResult
305
306 var CallbackVarRef uintptr
307 if CallbackVar != nil {
308 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
309 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
310 CallbackVarRef = cbRefPtr
311 } else {
312 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
313 cbFn := *CallbackVar
314 cbFn(arg0, arg1, arg2)
315 }
316 CallbackVarRef = purego.NewCallback(fcb)
317 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
318 }
319 }
320
321 cret := xNewSimpleAsyncResult(SourceObjectVar.GoPointer(), CallbackVarRef, UserDataVar, SourceTagVar)
322
323 if cret == 0 {
324 return nil
325 }
326 cls = &SimpleAsyncResult{}
327 cls.Ptr = cret
328 return cls
329}
330
331var xNewSimpleAsyncResultError func(uintptr, uintptr, uintptr, glib.Quark, int, string, ...interface{}) uintptr
332
333// Creates a new #GSimpleAsyncResult with a set error.
334func NewSimpleAsyncResultError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) *SimpleAsyncResult {
335 var cls *SimpleAsyncResult
336
337 var CallbackVarRef uintptr
338 if CallbackVar != nil {
339 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
340 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
341 CallbackVarRef = cbRefPtr
342 } else {
343 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
344 cbFn := *CallbackVar
345 cbFn(arg0, arg1, arg2)
346 }
347 CallbackVarRef = purego.NewCallback(fcb)
348 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
349 }
350 }
351
352 cret := xNewSimpleAsyncResultError(SourceObjectVar.GoPointer(), CallbackVarRef, UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...)
353
354 if cret == 0 {
355 return nil
356 }
357 cls = &SimpleAsyncResult{}
358 cls.Ptr = cret
359 return cls
360}
361
362var xNewSimpleAsyncResultFromError func(uintptr, uintptr, uintptr, *glib.Error) uintptr
363
364// Creates a #GSimpleAsyncResult from an error condition.
365func NewSimpleAsyncResultFromError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult {
366 var cls *SimpleAsyncResult
367
368 var CallbackVarRef uintptr
369 if CallbackVar != nil {
370 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
371 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
372 CallbackVarRef = cbRefPtr
373 } else {
374 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
375 cbFn := *CallbackVar
376 cbFn(arg0, arg1, arg2)
377 }
378 CallbackVarRef = purego.NewCallback(fcb)
379 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
380 }
381 }
382
383 cret := xNewSimpleAsyncResultFromError(SourceObjectVar.GoPointer(), CallbackVarRef, UserDataVar, ErrorVar)
384
385 if cret == 0 {
386 return nil
387 }
388 cls = &SimpleAsyncResult{}
389 cls.Ptr = cret
390 return cls
391}
392
393var xNewSimpleAsyncResultTakeError func(uintptr, uintptr, uintptr, *glib.Error) uintptr
394
395// Creates a #GSimpleAsyncResult from an error condition, and takes over the
396// caller's ownership of @error, so the caller does not need to free it anymore.
397func NewSimpleAsyncResultTakeError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult {
398 var cls *SimpleAsyncResult
399
400 var CallbackVarRef uintptr
401 if CallbackVar != nil {
402 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
403 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
404 CallbackVarRef = cbRefPtr
405 } else {
406 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
407 cbFn := *CallbackVar
408 cbFn(arg0, arg1, arg2)
409 }
410 CallbackVarRef = purego.NewCallback(fcb)
411 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
412 }
413 }
414
415 cret := xNewSimpleAsyncResultTakeError(SourceObjectVar.GoPointer(), CallbackVarRef, UserDataVar, ErrorVar)
416
417 if cret == 0 {
418 return nil
419 }
420 cls = &SimpleAsyncResult{}
421 cls.Ptr = cret
422 return cls
423}
424
425var xSimpleAsyncResultComplete func(uintptr)
426
427// Completes an asynchronous I/O job immediately. Must be called in
428// the thread where the asynchronous result was to be delivered, as it
429// invokes the callback directly. If you are in a different thread use
430// g_simple_async_result_complete_in_idle().
431//
432// Calling this function takes a reference to @simple for as long as
433// is needed to complete the call.
434func (x *SimpleAsyncResult) Complete() {
435
436 xSimpleAsyncResultComplete(x.GoPointer())
437
438}
439
440var xSimpleAsyncResultCompleteInIdle func(uintptr)
441
442// Completes an asynchronous function in an idle handler in the
443// thread-default main context (see [method@GLib.MainContext.push_thread_default])
444// of the thread that @simple was initially created in
445// (and re-pushes that context around the invocation of the callback).
446//
447// Calling this function takes a reference to @simple for as long as
448// is needed to complete the call.
449func (x *SimpleAsyncResult) CompleteInIdle() {
450
451 xSimpleAsyncResultCompleteInIdle(x.GoPointer())
452
453}
454
455var xSimpleAsyncResultGetOpResGboolean func(uintptr) bool
456
457// Gets the operation result boolean from within the asynchronous result.
458func (x *SimpleAsyncResult) GetOpResGboolean() bool {
459
460 cret := xSimpleAsyncResultGetOpResGboolean(x.GoPointer())
461 return cret
462}
463
464var xSimpleAsyncResultGetOpResGpointer func(uintptr) uintptr
465
466// Gets a pointer result as returned by the asynchronous function.
467func (x *SimpleAsyncResult) GetOpResGpointer() uintptr {
468
469 cret := xSimpleAsyncResultGetOpResGpointer(x.GoPointer())
470 return cret
471}
472
473var xSimpleAsyncResultGetOpResGssize func(uintptr) int
474
475// Gets a gssize from the asynchronous result.
476func (x *SimpleAsyncResult) GetOpResGssize() int {
477
478 cret := xSimpleAsyncResultGetOpResGssize(x.GoPointer())
479 return cret
480}
481
482var xSimpleAsyncResultGetSourceTag func(uintptr) uintptr
483
484// Gets the source tag for the #GSimpleAsyncResult.
485func (x *SimpleAsyncResult) GetSourceTag() uintptr {
486
487 cret := xSimpleAsyncResultGetSourceTag(x.GoPointer())
488 return cret
489}
490
491var xSimpleAsyncResultPropagateError func(uintptr) bool
492
493// Propagates an error from within the simple asynchronous result to
494// a given destination.
495//
496// If the #GCancellable given to a prior call to
497// g_simple_async_result_set_check_cancellable() is cancelled then this
498// function will return %TRUE with @dest set appropriately.
499func (x *SimpleAsyncResult) PropagateError() (bool, error) {
500 var cerr *glib.Error
501
502 cret := xSimpleAsyncResultPropagateError(x.GoPointer())
503 if cerr == nil {
504 return cret, nil
505 }
506 return cret, cerr
507
508}
509
510var xSimpleAsyncResultRunInThread func(uintptr, uintptr, int, uintptr)
511
512// Runs the asynchronous job in a separate thread and then calls
513// g_simple_async_result_complete_in_idle() on @simple to return
514// the result to the appropriate main loop.
515//
516// Calling this function takes a reference to @simple for as long as
517// is needed to run the job and report its completion.
518func (x *SimpleAsyncResult) RunInThread(FuncVar *SimpleAsyncThreadFunc, IoPriorityVar int, CancellableVar *Cancellable) {
519
520 var FuncVarRef uintptr
521 if FuncVar != nil {
522 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
523 if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
524 FuncVarRef = cbRefPtr
525 } else {
526 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
527 cbFn := *FuncVar
528 cbFn(arg0, arg1, arg2)
529 }
530 FuncVarRef = purego.NewCallback(fcb)
531 glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
532 }
533 }
534
535 xSimpleAsyncResultRunInThread(x.GoPointer(), FuncVarRef, IoPriorityVar, CancellableVar.GoPointer())
536
537}
538
539var xSimpleAsyncResultSetCheckCancellable func(uintptr, uintptr)
540
541// Sets a #GCancellable to check before dispatching results.
542//
543// This function has one very specific purpose: the provided cancellable
544// is checked at the time of g_simple_async_result_propagate_error() If
545// it is cancelled, these functions will return an "Operation was
546// cancelled" error (%G_IO_ERROR_CANCELLED).
547//
548// Implementors of cancellable asynchronous functions should use this in
549// order to provide a guarantee to their callers that cancelling an
550// async operation will reliably result in an error being returned for
551// that operation (even if a positive result for the operation has
552// already been sent as an idle to the main context to be dispatched).
553//
554// The checking described above is done regardless of any call to the
555// unrelated g_simple_async_result_set_handle_cancellation() function.
556func (x *SimpleAsyncResult) SetCheckCancellable(CheckCancellableVar *Cancellable) {
557
558 xSimpleAsyncResultSetCheckCancellable(x.GoPointer(), CheckCancellableVar.GoPointer())
559
560}
561
562var xSimpleAsyncResultSetError func(uintptr, glib.Quark, int, string, ...interface{})
563
564// Sets an error within the asynchronous result without a #GError.
565func (x *SimpleAsyncResult) SetError(DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) {
566
567 xSimpleAsyncResultSetError(x.GoPointer(), DomainVar, CodeVar, FormatVar, varArgs...)
568
569}
570
571var xSimpleAsyncResultSetErrorVa func(uintptr, glib.Quark, int, string, []interface{})
572
573// Sets an error within the asynchronous result without a #GError.
574// Unless writing a binding, see g_simple_async_result_set_error().
575func (x *SimpleAsyncResult) SetErrorVa(DomainVar glib.Quark, CodeVar int, FormatVar string, ArgsVar []interface{}) {
576
577 xSimpleAsyncResultSetErrorVa(x.GoPointer(), DomainVar, CodeVar, FormatVar, ArgsVar)
578
579}
580
581var xSimpleAsyncResultSetFromError func(uintptr, *glib.Error)
582
583// Sets the result from a #GError.
584func (x *SimpleAsyncResult) SetFromError(ErrorVar *glib.Error) {
585
586 xSimpleAsyncResultSetFromError(x.GoPointer(), ErrorVar)
587
588}
589
590var xSimpleAsyncResultSetHandleCancellation func(uintptr, bool)
591
592// Sets whether to handle cancellation within the asynchronous operation.
593//
594// This function has nothing to do with
595// g_simple_async_result_set_check_cancellable(). It only refers to the
596// #GCancellable passed to g_simple_async_result_run_in_thread().
597func (x *SimpleAsyncResult) SetHandleCancellation(HandleCancellationVar bool) {
598
599 xSimpleAsyncResultSetHandleCancellation(x.GoPointer(), HandleCancellationVar)
600
601}
602
603var xSimpleAsyncResultSetOpResGboolean func(uintptr, bool)
604
605// Sets the operation result to a boolean within the asynchronous result.
606func (x *SimpleAsyncResult) SetOpResGboolean(OpResVar bool) {
607
608 xSimpleAsyncResultSetOpResGboolean(x.GoPointer(), OpResVar)
609
610}
611
612var xSimpleAsyncResultSetOpResGpointer func(uintptr, uintptr, uintptr)
613
614// Sets the operation result within the asynchronous result to a pointer.
615func (x *SimpleAsyncResult) SetOpResGpointer(OpResVar uintptr, DestroyOpResVar *glib.DestroyNotify) {
616
617 var DestroyOpResVarRef uintptr
618 if DestroyOpResVar != nil {
619 DestroyOpResVarPtr := uintptr(unsafe.Pointer(DestroyOpResVar))
620 if cbRefPtr, ok := glib.GetCallback(DestroyOpResVarPtr); ok {
621 DestroyOpResVarRef = cbRefPtr
622 } else {
623 fcb := func(arg0 uintptr) {
624 cbFn := *DestroyOpResVar
625 cbFn(arg0)
626 }
627 DestroyOpResVarRef = purego.NewCallback(fcb)
628 glib.SaveCallbackWithClosure(DestroyOpResVarPtr, DestroyOpResVarRef, DestroyOpResVar)
629 }
630 }
631
632 xSimpleAsyncResultSetOpResGpointer(x.GoPointer(), OpResVar, DestroyOpResVarRef)
633
634}
635
636var xSimpleAsyncResultSetOpResGssize func(uintptr, int)
637
638// Sets the operation result within the asynchronous result to
639// the given @op_res.
640func (x *SimpleAsyncResult) SetOpResGssize(OpResVar int) {
641
642 xSimpleAsyncResultSetOpResGssize(x.GoPointer(), OpResVar)
643
644}
645
646var xSimpleAsyncResultTakeError func(uintptr, *glib.Error)
647
648// Sets the result from @error, and takes over the caller's ownership
649// of @error, so the caller does not need to free it any more.
650func (x *SimpleAsyncResult) TakeError(ErrorVar *glib.Error) {
651
652 xSimpleAsyncResultTakeError(x.GoPointer(), ErrorVar)
653
654}
655
656func (c *SimpleAsyncResult) GoPointer() uintptr {
657 if c == nil {
658 return 0
659 }
660 return c.Ptr
661}
662
663func (c *SimpleAsyncResult) SetGoPointer(ptr uintptr) {
664 c.Ptr = ptr
665}
666
667// Gets the source object from a [iface@Gio.AsyncResult].
668func (x *SimpleAsyncResult) GetSourceObject() *gobject.Object {
669 var cls *gobject.Object
670
671 cret := XGAsyncResultGetSourceObject(x.GoPointer())
672
673 if cret == 0 {
674 return nil
675 }
676 cls = &gobject.Object{}
677 cls.Ptr = cret
678 return cls
679}
680
681// Gets the user data from a [iface@Gio.AsyncResult].
682func (x *SimpleAsyncResult) GetUserData() uintptr {
683
684 cret := XGAsyncResultGetUserData(x.GoPointer())
685 return cret
686}
687
688// Checks if @res has the given @source_tag (generally a function
689// pointer indicating the function @res was created by).
690func (x *SimpleAsyncResult) IsTagged(SourceTagVar uintptr) bool {
691
692 cret := XGAsyncResultIsTagged(x.GoPointer(), SourceTagVar)
693 return cret
694}
695
696// If @res is a [class@Gio.SimpleAsyncResult], this is equivalent to
697// [method@Gio.SimpleAsyncResult.propagate_error]. Otherwise it returns
698// `FALSE`.
699//
700// This can be used for legacy error handling in async `*_finish()`
701// wrapper functions that traditionally handled [class@Gio.SimpleAsyncResult]
702// error returns themselves rather than calling into the virtual method.
703// This should not be used in new code; [iface@Gio.AsyncResult] errors that are
704// set by virtual methods should also be extracted by virtual methods,
705// to enable subclasses to chain up correctly.
706func (x *SimpleAsyncResult) LegacyPropagateError() (bool, error) {
707 var cerr *glib.Error
708
709 cret := XGAsyncResultLegacyPropagateError(x.GoPointer())
710 if cerr == nil {
711 return cret, nil
712 }
713 return cret, cerr
714
715}
716
717var xSimpleAsyncResultIsValid func(uintptr, uintptr, uintptr) bool
718
719// Ensures that the data passed to the _finish function of an async
720// operation is consistent. Three checks are performed.
721//
722// First, @result is checked to ensure that it is really a
723// #GSimpleAsyncResult. Second, @source is checked to ensure that it
724// matches the source object of @result. Third, @source_tag is
725// checked to ensure that it is equal to the @source_tag argument given
726// to g_simple_async_result_new() (which, by convention, is a pointer
727// to the _async function corresponding to the _finish function from
728// which this function is called). (Alternatively, if either
729// @source_tag or @result's source tag is %NULL, then the source tag
730// check is skipped.)
731func SimpleAsyncResultIsValid(ResultVar AsyncResult, SourceVar *gobject.Object, SourceTagVar uintptr) bool {
732
733 cret := xSimpleAsyncResultIsValid(ResultVar.GoPointer(), SourceVar.GoPointer(), SourceTagVar)
734 return cret
735}
736
737func init() {
738 core.SetPackageName("GIO", "gio-2.0")
739 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
740 var libs []uintptr
741 for _, libPath := range core.GetPaths("GIO") {
742 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
743 if err != nil {
744 panic(err)
745 }
746 libs = append(libs, lib)
747 }
748
749 core.PuregoSafeRegister(&xSimpleAsyncReportErrorInIdle, libs, "g_simple_async_report_error_in_idle")
750 core.PuregoSafeRegister(&xSimpleAsyncReportGerrorInIdle, libs, "g_simple_async_report_gerror_in_idle")
751 core.PuregoSafeRegister(&xSimpleAsyncReportTakeGerrorInIdle, libs, "g_simple_async_report_take_gerror_in_idle")
752
753 core.PuregoSafeRegister(&xSimpleAsyncResultGLibType, libs, "g_simple_async_result_get_type")
754
755 core.PuregoSafeRegister(&xNewSimpleAsyncResult, libs, "g_simple_async_result_new")
756 core.PuregoSafeRegister(&xNewSimpleAsyncResultError, libs, "g_simple_async_result_new_error")
757 core.PuregoSafeRegister(&xNewSimpleAsyncResultFromError, libs, "g_simple_async_result_new_from_error")
758 core.PuregoSafeRegister(&xNewSimpleAsyncResultTakeError, libs, "g_simple_async_result_new_take_error")
759
760 core.PuregoSafeRegister(&xSimpleAsyncResultComplete, libs, "g_simple_async_result_complete")
761 core.PuregoSafeRegister(&xSimpleAsyncResultCompleteInIdle, libs, "g_simple_async_result_complete_in_idle")
762 core.PuregoSafeRegister(&xSimpleAsyncResultGetOpResGboolean, libs, "g_simple_async_result_get_op_res_gboolean")
763 core.PuregoSafeRegister(&xSimpleAsyncResultGetOpResGpointer, libs, "g_simple_async_result_get_op_res_gpointer")
764 core.PuregoSafeRegister(&xSimpleAsyncResultGetOpResGssize, libs, "g_simple_async_result_get_op_res_gssize")
765 core.PuregoSafeRegister(&xSimpleAsyncResultGetSourceTag, libs, "g_simple_async_result_get_source_tag")
766 core.PuregoSafeRegister(&xSimpleAsyncResultPropagateError, libs, "g_simple_async_result_propagate_error")
767 core.PuregoSafeRegister(&xSimpleAsyncResultRunInThread, libs, "g_simple_async_result_run_in_thread")
768 core.PuregoSafeRegister(&xSimpleAsyncResultSetCheckCancellable, libs, "g_simple_async_result_set_check_cancellable")
769 core.PuregoSafeRegister(&xSimpleAsyncResultSetError, libs, "g_simple_async_result_set_error")
770 core.PuregoSafeRegister(&xSimpleAsyncResultSetErrorVa, libs, "g_simple_async_result_set_error_va")
771 core.PuregoSafeRegister(&xSimpleAsyncResultSetFromError, libs, "g_simple_async_result_set_from_error")
772 core.PuregoSafeRegister(&xSimpleAsyncResultSetHandleCancellation, libs, "g_simple_async_result_set_handle_cancellation")
773 core.PuregoSafeRegister(&xSimpleAsyncResultSetOpResGboolean, libs, "g_simple_async_result_set_op_res_gboolean")
774 core.PuregoSafeRegister(&xSimpleAsyncResultSetOpResGpointer, libs, "g_simple_async_result_set_op_res_gpointer")
775 core.PuregoSafeRegister(&xSimpleAsyncResultSetOpResGssize, libs, "g_simple_async_result_set_op_res_gssize")
776 core.PuregoSafeRegister(&xSimpleAsyncResultTakeError, libs, "g_simple_async_result_take_error")
777
778 core.PuregoSafeRegister(&xSimpleAsyncResultIsValid, libs, "g_simple_async_result_is_valid")
779
780}