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// Base type for D-Bus interfaces.
16type DBusInterfaceIface struct {
17 _ structs.HostLayout
18
19 ParentIface uintptr
20
21 xGetInfo uintptr
22
23 xGetObject uintptr
24
25 xSetObject uintptr
26
27 xDupObject uintptr
28}
29
30func (x *DBusInterfaceIface) GoPointer() uintptr {
31 return uintptr(unsafe.Pointer(x))
32}
33
34// OverrideGetInfo sets the "get_info" callback function.
35// Returns a #GDBusInterfaceInfo. See g_dbus_interface_get_info().
36func (x *DBusInterfaceIface) OverrideGetInfo(cb func(DBusInterface) *DBusInterfaceInfo) {
37 if cb == nil {
38 x.xGetInfo = 0
39 } else {
40 x.xGetInfo = purego.NewCallback(func(InterfaceVarp uintptr) *DBusInterfaceInfo {
41 return cb(&DBusInterfaceBase{Ptr: InterfaceVarp})
42 })
43 }
44}
45
46// GetGetInfo gets the "get_info" callback function.
47// Returns a #GDBusInterfaceInfo. See g_dbus_interface_get_info().
48func (x *DBusInterfaceIface) GetGetInfo() func(DBusInterface) *DBusInterfaceInfo {
49 if x.xGetInfo == 0 {
50 return nil
51 }
52 var rawCallback func(InterfaceVarp uintptr) *DBusInterfaceInfo
53 purego.RegisterFunc(&rawCallback, x.xGetInfo)
54 return func(InterfaceVar DBusInterface) *DBusInterfaceInfo {
55 return rawCallback(InterfaceVar.GoPointer())
56 }
57}
58
59// OverrideGetObject sets the "get_object" callback function.
60// Gets the enclosing #GDBusObject. See g_dbus_interface_get_object().
61func (x *DBusInterfaceIface) OverrideGetObject(cb func(DBusInterface) *DBusObjectBase) {
62 if cb == nil {
63 x.xGetObject = 0
64 } else {
65 x.xGetObject = purego.NewCallback(func(InterfaceVarp uintptr) uintptr {
66 ret := cb(&DBusInterfaceBase{Ptr: InterfaceVarp})
67 if ret == nil {
68 return 0
69 }
70 return ret.GoPointer()
71 })
72 }
73}
74
75// GetGetObject gets the "get_object" callback function.
76// Gets the enclosing #GDBusObject. See g_dbus_interface_get_object().
77func (x *DBusInterfaceIface) GetGetObject() func(DBusInterface) *DBusObjectBase {
78 if x.xGetObject == 0 {
79 return nil
80 }
81 var rawCallback func(InterfaceVarp uintptr) uintptr
82 purego.RegisterFunc(&rawCallback, x.xGetObject)
83 return func(InterfaceVar DBusInterface) *DBusObjectBase {
84 rawRet := rawCallback(InterfaceVar.GoPointer())
85 if rawRet == 0 {
86 return nil
87 }
88 ret := &DBusObjectBase{}
89 ret.Ptr = rawRet
90 return ret
91 }
92}
93
94// OverrideSetObject sets the "set_object" callback function.
95// Sets the enclosing #GDBusObject. See g_dbus_interface_set_object().
96func (x *DBusInterfaceIface) OverrideSetObject(cb func(DBusInterface, DBusObject)) {
97 if cb == nil {
98 x.xSetObject = 0
99 } else {
100 x.xSetObject = purego.NewCallback(func(InterfaceVarp uintptr, ObjectVarp uintptr) {
101 cb(&DBusInterfaceBase{Ptr: InterfaceVarp}, &DBusObjectBase{Ptr: ObjectVarp})
102 })
103 }
104}
105
106// GetSetObject gets the "set_object" callback function.
107// Sets the enclosing #GDBusObject. See g_dbus_interface_set_object().
108func (x *DBusInterfaceIface) GetSetObject() func(DBusInterface, DBusObject) {
109 if x.xSetObject == 0 {
110 return nil
111 }
112 var rawCallback func(InterfaceVarp uintptr, ObjectVarp uintptr)
113 purego.RegisterFunc(&rawCallback, x.xSetObject)
114 return func(InterfaceVar DBusInterface, ObjectVar DBusObject) {
115 rawCallback(InterfaceVar.GoPointer(), ObjectVar.GoPointer())
116 }
117}
118
119// OverrideDupObject sets the "dup_object" callback function.
120// Gets a reference to the enclosing #GDBusObject. See g_dbus_interface_dup_object(). Added in 2.32.
121func (x *DBusInterfaceIface) OverrideDupObject(cb func(DBusInterface) *DBusObjectBase) {
122 if cb == nil {
123 x.xDupObject = 0
124 } else {
125 x.xDupObject = purego.NewCallback(func(InterfaceVarp uintptr) uintptr {
126 ret := cb(&DBusInterfaceBase{Ptr: InterfaceVarp})
127 if ret == nil {
128 return 0
129 }
130 return ret.GoPointer()
131 })
132 }
133}
134
135// GetDupObject gets the "dup_object" callback function.
136// Gets a reference to the enclosing #GDBusObject. See g_dbus_interface_dup_object(). Added in 2.32.
137func (x *DBusInterfaceIface) GetDupObject() func(DBusInterface) *DBusObjectBase {
138 if x.xDupObject == 0 {
139 return nil
140 }
141 var rawCallback func(InterfaceVarp uintptr) uintptr
142 purego.RegisterFunc(&rawCallback, x.xDupObject)
143 return func(InterfaceVar DBusInterface) *DBusObjectBase {
144 rawRet := rawCallback(InterfaceVar.GoPointer())
145 if rawRet == 0 {
146 return nil
147 }
148 ret := &DBusObjectBase{}
149 ret.Ptr = rawRet
150 return ret
151 }
152}
153
154// Base type for D-Bus interfaces.
155//
156// The `GDBusInterface` type is the base type for D-Bus interfaces both
157// on the service side (see [class@Gio.DBusInterfaceSkeleton]) and client side
158// (see [class@Gio.DBusProxy]).
159type DBusInterface interface {
160 GoPointer() uintptr
161 SetGoPointer(uintptr)
162 DupObject() *DBusObjectBase
163 GetInfo() *DBusInterfaceInfo
164 GetObject() *DBusObjectBase
165 SetObject(ObjectVar DBusObject)
166}
167
168var xDBusInterfaceGLibType func() types.GType
169
170func DBusInterfaceGLibType() types.GType {
171 return xDBusInterfaceGLibType()
172}
173
174type DBusInterfaceBase struct {
175 Ptr uintptr
176}
177
178func (x *DBusInterfaceBase) GoPointer() uintptr {
179 if x == nil {
180 return 0
181 }
182 return x.Ptr
183}
184
185func (x *DBusInterfaceBase) SetGoPointer(ptr uintptr) {
186 x.Ptr = ptr
187}
188
189// Gets the #GDBusObject that @interface_ belongs to, if any.
190func (x *DBusInterfaceBase) DupObject() *DBusObjectBase {
191 var cls *DBusObjectBase
192
193 cret := XGDbusInterfaceDupObject(x.GoPointer())
194
195 if cret == 0 {
196 return nil
197 }
198 cls = &DBusObjectBase{}
199 cls.Ptr = cret
200 return cls
201}
202
203// Gets D-Bus introspection information for the D-Bus interface
204// implemented by @interface_.
205func (x *DBusInterfaceBase) GetInfo() *DBusInterfaceInfo {
206
207 cret := XGDbusInterfaceGetInfo(x.GoPointer())
208 return cret
209}
210
211// Gets the #GDBusObject that @interface_ belongs to, if any.
212//
213// It is not safe to use the returned object if @interface_ or
214// the returned object is being used from other threads. See
215// g_dbus_interface_dup_object() for a thread-safe alternative.
216func (x *DBusInterfaceBase) GetObject() *DBusObjectBase {
217 var cls *DBusObjectBase
218
219 cret := XGDbusInterfaceGetObject(x.GoPointer())
220
221 if cret == 0 {
222 return nil
223 }
224 gobject.IncreaseRef(cret)
225 cls = &DBusObjectBase{}
226 cls.Ptr = cret
227 return cls
228}
229
230// Sets the #GDBusObject for @interface_ to @object.
231//
232// Note that @interface_ will hold a weak reference to @object.
233func (x *DBusInterfaceBase) SetObject(ObjectVar DBusObject) {
234
235 XGDbusInterfaceSetObject(x.GoPointer(), ObjectVar.GoPointer())
236
237}
238
239var XGDbusInterfaceDupObject func(uintptr) uintptr
240var XGDbusInterfaceGetInfo func(uintptr) *DBusInterfaceInfo
241var XGDbusInterfaceGetObject func(uintptr) uintptr
242var XGDbusInterfaceSetObject func(uintptr, uintptr)
243
244func init() {
245 core.SetPackageName("GIO", "gio-2.0")
246 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
247 var libs []uintptr
248 for _, libPath := range core.GetPaths("GIO") {
249 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
250 if err != nil {
251 panic(err)
252 }
253 libs = append(libs, lib)
254 }
255
256 core.PuregoSafeRegister(&xDBusInterfaceGLibType, libs, "g_dbus_interface_get_type")
257
258 core.PuregoSafeRegister(&XGDbusInterfaceDupObject, libs, "g_dbus_interface_dup_object")
259 core.PuregoSafeRegister(&XGDbusInterfaceGetInfo, libs, "g_dbus_interface_get_info")
260 core.PuregoSafeRegister(&XGDbusInterfaceGetObject, libs, "g_dbus_interface_get_object")
261 core.PuregoSafeRegister(&XGDbusInterfaceSetObject, libs, "g_dbus_interface_set_object")
262
263}