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 PermissionClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xAcquire uintptr
22
23 xAcquireAsync uintptr
24
25 xAcquireFinish uintptr
26
27 xRelease uintptr
28
29 xReleaseAsync uintptr
30
31 xReleaseFinish uintptr
32
33 Reserved [16]uintptr
34}
35
36func (x *PermissionClass) GoPointer() uintptr {
37 return uintptr(unsafe.Pointer(x))
38}
39
40// OverrideAcquire sets the "acquire" callback function.
41func (x *PermissionClass) OverrideAcquire(cb func(*Permission, *Cancellable) bool) {
42 if cb == nil {
43 x.xAcquire = 0
44 } else {
45 x.xAcquire = purego.NewCallback(func(PermissionVarp uintptr, CancellableVarp uintptr) bool {
46 return cb(PermissionNewFromInternalPtr(PermissionVarp), CancellableNewFromInternalPtr(CancellableVarp))
47 })
48 }
49}
50
51// GetAcquire gets the "acquire" callback function.
52func (x *PermissionClass) GetAcquire() func(*Permission, *Cancellable) bool {
53 if x.xAcquire == 0 {
54 return nil
55 }
56 var rawCallback func(PermissionVarp uintptr, CancellableVarp uintptr) bool
57 purego.RegisterFunc(&rawCallback, x.xAcquire)
58 return func(PermissionVar *Permission, CancellableVar *Cancellable) bool {
59 return rawCallback(PermissionVar.GoPointer(), CancellableVar.GoPointer())
60 }
61}
62
63// OverrideAcquireAsync sets the "acquire_async" callback function.
64func (x *PermissionClass) OverrideAcquireAsync(cb func(*Permission, *Cancellable, *AsyncReadyCallback, uintptr)) {
65 if cb == nil {
66 x.xAcquireAsync = 0
67 } else {
68 x.xAcquireAsync = purego.NewCallback(func(PermissionVarp uintptr, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
69 cb(PermissionNewFromInternalPtr(PermissionVarp), CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
70 })
71 }
72}
73
74// GetAcquireAsync gets the "acquire_async" callback function.
75func (x *PermissionClass) GetAcquireAsync() func(*Permission, *Cancellable, *AsyncReadyCallback, uintptr) {
76 if x.xAcquireAsync == 0 {
77 return nil
78 }
79 var rawCallback func(PermissionVarp uintptr, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
80 purego.RegisterFunc(&rawCallback, x.xAcquireAsync)
81 return func(PermissionVar *Permission, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
82 rawCallback(PermissionVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
83 }
84}
85
86// OverrideAcquireFinish sets the "acquire_finish" callback function.
87func (x *PermissionClass) OverrideAcquireFinish(cb func(*Permission, AsyncResult) bool) {
88 if cb == nil {
89 x.xAcquireFinish = 0
90 } else {
91 x.xAcquireFinish = purego.NewCallback(func(PermissionVarp uintptr, ResultVarp uintptr) bool {
92 return cb(PermissionNewFromInternalPtr(PermissionVarp), &AsyncResultBase{Ptr: ResultVarp})
93 })
94 }
95}
96
97// GetAcquireFinish gets the "acquire_finish" callback function.
98func (x *PermissionClass) GetAcquireFinish() func(*Permission, AsyncResult) bool {
99 if x.xAcquireFinish == 0 {
100 return nil
101 }
102 var rawCallback func(PermissionVarp uintptr, ResultVarp uintptr) bool
103 purego.RegisterFunc(&rawCallback, x.xAcquireFinish)
104 return func(PermissionVar *Permission, ResultVar AsyncResult) bool {
105 return rawCallback(PermissionVar.GoPointer(), ResultVar.GoPointer())
106 }
107}
108
109// OverrideRelease sets the "release" callback function.
110func (x *PermissionClass) OverrideRelease(cb func(*Permission, *Cancellable) bool) {
111 if cb == nil {
112 x.xRelease = 0
113 } else {
114 x.xRelease = purego.NewCallback(func(PermissionVarp uintptr, CancellableVarp uintptr) bool {
115 return cb(PermissionNewFromInternalPtr(PermissionVarp), CancellableNewFromInternalPtr(CancellableVarp))
116 })
117 }
118}
119
120// GetRelease gets the "release" callback function.
121func (x *PermissionClass) GetRelease() func(*Permission, *Cancellable) bool {
122 if x.xRelease == 0 {
123 return nil
124 }
125 var rawCallback func(PermissionVarp uintptr, CancellableVarp uintptr) bool
126 purego.RegisterFunc(&rawCallback, x.xRelease)
127 return func(PermissionVar *Permission, CancellableVar *Cancellable) bool {
128 return rawCallback(PermissionVar.GoPointer(), CancellableVar.GoPointer())
129 }
130}
131
132// OverrideReleaseAsync sets the "release_async" callback function.
133func (x *PermissionClass) OverrideReleaseAsync(cb func(*Permission, *Cancellable, *AsyncReadyCallback, uintptr)) {
134 if cb == nil {
135 x.xReleaseAsync = 0
136 } else {
137 x.xReleaseAsync = purego.NewCallback(func(PermissionVarp uintptr, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
138 cb(PermissionNewFromInternalPtr(PermissionVarp), CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
139 })
140 }
141}
142
143// GetReleaseAsync gets the "release_async" callback function.
144func (x *PermissionClass) GetReleaseAsync() func(*Permission, *Cancellable, *AsyncReadyCallback, uintptr) {
145 if x.xReleaseAsync == 0 {
146 return nil
147 }
148 var rawCallback func(PermissionVarp uintptr, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
149 purego.RegisterFunc(&rawCallback, x.xReleaseAsync)
150 return func(PermissionVar *Permission, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
151 rawCallback(PermissionVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
152 }
153}
154
155// OverrideReleaseFinish sets the "release_finish" callback function.
156func (x *PermissionClass) OverrideReleaseFinish(cb func(*Permission, AsyncResult) bool) {
157 if cb == nil {
158 x.xReleaseFinish = 0
159 } else {
160 x.xReleaseFinish = purego.NewCallback(func(PermissionVarp uintptr, ResultVarp uintptr) bool {
161 return cb(PermissionNewFromInternalPtr(PermissionVarp), &AsyncResultBase{Ptr: ResultVarp})
162 })
163 }
164}
165
166// GetReleaseFinish gets the "release_finish" callback function.
167func (x *PermissionClass) GetReleaseFinish() func(*Permission, AsyncResult) bool {
168 if x.xReleaseFinish == 0 {
169 return nil
170 }
171 var rawCallback func(PermissionVarp uintptr, ResultVarp uintptr) bool
172 purego.RegisterFunc(&rawCallback, x.xReleaseFinish)
173 return func(PermissionVar *Permission, ResultVar AsyncResult) bool {
174 return rawCallback(PermissionVar.GoPointer(), ResultVar.GoPointer())
175 }
176}
177
178type PermissionPrivate struct {
179 _ structs.HostLayout
180}
181
182func (x *PermissionPrivate) GoPointer() uintptr {
183 return uintptr(unsafe.Pointer(x))
184}
185
186// A `GPermission` represents the status of the caller’s permission to
187// perform a certain action.
188//
189// You can query if the action is currently allowed and if it is
190// possible to acquire the permission so that the action will be allowed
191// in the future.
192//
193// There is also an API to actually acquire the permission and one to
194// release it.
195//
196// As an example, a `GPermission` might represent the ability for the
197// user to write to a [class@Gio.Settings] object. This `GPermission` object
198// could then be used to decide if it is appropriate to show a “Click here to
199// unlock” button in a dialog and to provide the mechanism to invoke
200// when that button is clicked.
201type Permission struct {
202 gobject.Object
203}
204
205var xPermissionGLibType func() types.GType
206
207func PermissionGLibType() types.GType {
208 return xPermissionGLibType()
209}
210
211func PermissionNewFromInternalPtr(ptr uintptr) *Permission {
212 cls := &Permission{}
213 cls.Ptr = ptr
214 return cls
215}
216
217var xPermissionAcquire func(uintptr, uintptr, **glib.Error) bool
218
219// Attempts to acquire the permission represented by @permission.
220//
221// The precise method by which this happens depends on the permission
222// and the underlying authentication mechanism. A simple example is
223// that a dialog may appear asking the user to enter their password.
224//
225// You should check with g_permission_get_can_acquire() before calling
226// this function.
227//
228// If the permission is acquired then %TRUE is returned. Otherwise,
229// %FALSE is returned and @error is set appropriately.
230//
231// This call is blocking, likely for a very long time (in the case that
232// user interaction is required). See g_permission_acquire_async() for
233// the non-blocking version.
234func (x *Permission) Acquire(CancellableVar *Cancellable) (bool, error) {
235 var cerr *glib.Error
236
237 cret := xPermissionAcquire(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
238 if cerr == nil {
239 return cret, nil
240 }
241 return cret, cerr
242
243}
244
245var xPermissionAcquireAsync func(uintptr, uintptr, uintptr, uintptr)
246
247// Attempts to acquire the permission represented by @permission.
248//
249// This is the first half of the asynchronous version of
250// g_permission_acquire().
251func (x *Permission) AcquireAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
252
253 var CallbackVarRef uintptr
254 if CallbackVar != nil {
255 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
256 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
257 CallbackVarRef = cbRefPtr
258 } else {
259 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
260 cbFn := *CallbackVar
261 cbFn(arg0, arg1, arg2)
262 }
263 CallbackVarRef = purego.NewCallback(fcb)
264 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
265 }
266 }
267
268 xPermissionAcquireAsync(x.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
269
270}
271
272var xPermissionAcquireFinish func(uintptr, uintptr, **glib.Error) bool
273
274// Collects the result of attempting to acquire the permission
275// represented by @permission.
276//
277// This is the second half of the asynchronous version of
278// g_permission_acquire().
279func (x *Permission) AcquireFinish(ResultVar AsyncResult) (bool, error) {
280 var cerr *glib.Error
281
282 cret := xPermissionAcquireFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
283 if cerr == nil {
284 return cret, nil
285 }
286 return cret, cerr
287
288}
289
290var xPermissionGetAllowed func(uintptr) bool
291
292// Gets the value of the 'allowed' property. This property is %TRUE if
293// the caller currently has permission to perform the action that
294// @permission represents the permission to perform.
295func (x *Permission) GetAllowed() bool {
296
297 cret := xPermissionGetAllowed(x.GoPointer())
298 return cret
299}
300
301var xPermissionGetCanAcquire func(uintptr) bool
302
303// Gets the value of the 'can-acquire' property. This property is %TRUE
304// if it is generally possible to acquire the permission by calling
305// g_permission_acquire().
306func (x *Permission) GetCanAcquire() bool {
307
308 cret := xPermissionGetCanAcquire(x.GoPointer())
309 return cret
310}
311
312var xPermissionGetCanRelease func(uintptr) bool
313
314// Gets the value of the 'can-release' property. This property is %TRUE
315// if it is generally possible to release the permission by calling
316// g_permission_release().
317func (x *Permission) GetCanRelease() bool {
318
319 cret := xPermissionGetCanRelease(x.GoPointer())
320 return cret
321}
322
323var xPermissionImplUpdate func(uintptr, bool, bool, bool)
324
325// This function is called by the #GPermission implementation to update
326// the properties of the permission. You should never call this
327// function except from a #GPermission implementation.
328//
329// GObject notify signals are generated, as appropriate.
330func (x *Permission) ImplUpdate(AllowedVar bool, CanAcquireVar bool, CanReleaseVar bool) {
331
332 xPermissionImplUpdate(x.GoPointer(), AllowedVar, CanAcquireVar, CanReleaseVar)
333
334}
335
336var xPermissionRelease func(uintptr, uintptr, **glib.Error) bool
337
338// Attempts to release the permission represented by @permission.
339//
340// The precise method by which this happens depends on the permission
341// and the underlying authentication mechanism. In most cases the
342// permission will be dropped immediately without further action.
343//
344// You should check with g_permission_get_can_release() before calling
345// this function.
346//
347// If the permission is released then %TRUE is returned. Otherwise,
348// %FALSE is returned and @error is set appropriately.
349//
350// This call is blocking, likely for a very long time (in the case that
351// user interaction is required). See g_permission_release_async() for
352// the non-blocking version.
353func (x *Permission) Release(CancellableVar *Cancellable) (bool, error) {
354 var cerr *glib.Error
355
356 cret := xPermissionRelease(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
357 if cerr == nil {
358 return cret, nil
359 }
360 return cret, cerr
361
362}
363
364var xPermissionReleaseAsync func(uintptr, uintptr, uintptr, uintptr)
365
366// Attempts to release the permission represented by @permission.
367//
368// This is the first half of the asynchronous version of
369// g_permission_release().
370func (x *Permission) ReleaseAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
371
372 var CallbackVarRef uintptr
373 if CallbackVar != nil {
374 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
375 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
376 CallbackVarRef = cbRefPtr
377 } else {
378 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
379 cbFn := *CallbackVar
380 cbFn(arg0, arg1, arg2)
381 }
382 CallbackVarRef = purego.NewCallback(fcb)
383 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
384 }
385 }
386
387 xPermissionReleaseAsync(x.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
388
389}
390
391var xPermissionReleaseFinish func(uintptr, uintptr, **glib.Error) bool
392
393// Collects the result of attempting to release the permission
394// represented by @permission.
395//
396// This is the second half of the asynchronous version of
397// g_permission_release().
398func (x *Permission) ReleaseFinish(ResultVar AsyncResult) (bool, error) {
399 var cerr *glib.Error
400
401 cret := xPermissionReleaseFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
402 if cerr == nil {
403 return cret, nil
404 }
405 return cret, cerr
406
407}
408
409func (c *Permission) GoPointer() uintptr {
410 if c == nil {
411 return 0
412 }
413 return c.Ptr
414}
415
416func (c *Permission) SetGoPointer(ptr uintptr) {
417 c.Ptr = ptr
418}
419
420// GetPropertyAllowed gets the "allowed" property.
421// %TRUE if the caller currently has permission to perform the action that
422// @permission represents the permission to perform.
423func (x *Permission) GetPropertyAllowed() bool {
424 var v gobject.Value
425 x.GetProperty("allowed", &v)
426 return v.GetBoolean()
427}
428
429// GetPropertyCanAcquire gets the "can-acquire" property.
430// %TRUE if it is generally possible to acquire the permission by calling
431// g_permission_acquire().
432func (x *Permission) GetPropertyCanAcquire() bool {
433 var v gobject.Value
434 x.GetProperty("can-acquire", &v)
435 return v.GetBoolean()
436}
437
438// GetPropertyCanRelease gets the "can-release" property.
439// %TRUE if it is generally possible to release the permission by calling
440// g_permission_release().
441func (x *Permission) GetPropertyCanRelease() bool {
442 var v gobject.Value
443 x.GetProperty("can-release", &v)
444 return v.GetBoolean()
445}
446
447func init() {
448 core.SetPackageName("GIO", "gio-2.0")
449 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
450 var libs []uintptr
451 for _, libPath := range core.GetPaths("GIO") {
452 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
453 if err != nil {
454 panic(err)
455 }
456 libs = append(libs, lib)
457 }
458
459 core.PuregoSafeRegister(&xPermissionGLibType, libs, "g_permission_get_type")
460
461 core.PuregoSafeRegister(&xPermissionAcquire, libs, "g_permission_acquire")
462 core.PuregoSafeRegister(&xPermissionAcquireAsync, libs, "g_permission_acquire_async")
463 core.PuregoSafeRegister(&xPermissionAcquireFinish, libs, "g_permission_acquire_finish")
464 core.PuregoSafeRegister(&xPermissionGetAllowed, libs, "g_permission_get_allowed")
465 core.PuregoSafeRegister(&xPermissionGetCanAcquire, libs, "g_permission_get_can_acquire")
466 core.PuregoSafeRegister(&xPermissionGetCanRelease, libs, "g_permission_get_can_release")
467 core.PuregoSafeRegister(&xPermissionImplUpdate, libs, "g_permission_impl_update")
468 core.PuregoSafeRegister(&xPermissionRelease, libs, "g_permission_release")
469 core.PuregoSafeRegister(&xPermissionReleaseAsync, libs, "g_permission_release_async")
470 core.PuregoSafeRegister(&xPermissionReleaseFinish, libs, "g_permission_release_finish")
471
472}