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// Base object type for D-Bus objects.
16type DBusObjectIface struct {
17 _ structs.HostLayout
18
19 ParentIface uintptr
20
21 xGetObjectPath uintptr
22
23 xGetInterfaces uintptr
24
25 xGetInterface uintptr
26
27 xInterfaceAdded uintptr
28
29 xInterfaceRemoved uintptr
30}
31
32func (x *DBusObjectIface) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideGetObjectPath sets the "get_object_path" callback function.
37// Returns the object path. See g_dbus_object_get_object_path().
38func (x *DBusObjectIface) OverrideGetObjectPath(cb func(DBusObject) string) {
39 if cb == nil {
40 x.xGetObjectPath = 0
41 } else {
42 x.xGetObjectPath = purego.NewCallback(func(ObjectVarp uintptr) string {
43 return cb(&DBusObjectBase{Ptr: ObjectVarp})
44 })
45 }
46}
47
48// GetGetObjectPath gets the "get_object_path" callback function.
49// Returns the object path. See g_dbus_object_get_object_path().
50func (x *DBusObjectIface) GetGetObjectPath() func(DBusObject) string {
51 if x.xGetObjectPath == 0 {
52 return nil
53 }
54 var rawCallback func(ObjectVarp uintptr) string
55 purego.RegisterFunc(&rawCallback, x.xGetObjectPath)
56 return func(ObjectVar DBusObject) string {
57 return rawCallback(ObjectVar.GoPointer())
58 }
59}
60
61// OverrideGetInterfaces sets the "get_interfaces" callback function.
62// Returns all interfaces. See g_dbus_object_get_interfaces().
63func (x *DBusObjectIface) OverrideGetInterfaces(cb func(DBusObject) *glib.List) {
64 if cb == nil {
65 x.xGetInterfaces = 0
66 } else {
67 x.xGetInterfaces = purego.NewCallback(func(ObjectVarp uintptr) *glib.List {
68 return cb(&DBusObjectBase{Ptr: ObjectVarp})
69 })
70 }
71}
72
73// GetGetInterfaces gets the "get_interfaces" callback function.
74// Returns all interfaces. See g_dbus_object_get_interfaces().
75func (x *DBusObjectIface) GetGetInterfaces() func(DBusObject) *glib.List {
76 if x.xGetInterfaces == 0 {
77 return nil
78 }
79 var rawCallback func(ObjectVarp uintptr) *glib.List
80 purego.RegisterFunc(&rawCallback, x.xGetInterfaces)
81 return func(ObjectVar DBusObject) *glib.List {
82 return rawCallback(ObjectVar.GoPointer())
83 }
84}
85
86// OverrideGetInterface sets the "get_interface" callback function.
87// Returns an interface by name. See g_dbus_object_get_interface().
88func (x *DBusObjectIface) OverrideGetInterface(cb func(DBusObject, string) *DBusInterfaceBase) {
89 if cb == nil {
90 x.xGetInterface = 0
91 } else {
92 x.xGetInterface = purego.NewCallback(func(ObjectVarp uintptr, InterfaceNameVarp string) uintptr {
93 ret := cb(&DBusObjectBase{Ptr: ObjectVarp}, InterfaceNameVarp)
94 if ret == nil {
95 return 0
96 }
97 return ret.GoPointer()
98 })
99 }
100}
101
102// GetGetInterface gets the "get_interface" callback function.
103// Returns an interface by name. See g_dbus_object_get_interface().
104func (x *DBusObjectIface) GetGetInterface() func(DBusObject, string) *DBusInterfaceBase {
105 if x.xGetInterface == 0 {
106 return nil
107 }
108 var rawCallback func(ObjectVarp uintptr, InterfaceNameVarp string) uintptr
109 purego.RegisterFunc(&rawCallback, x.xGetInterface)
110 return func(ObjectVar DBusObject, InterfaceNameVar string) *DBusInterfaceBase {
111 rawRet := rawCallback(ObjectVar.GoPointer(), InterfaceNameVar)
112 if rawRet == 0 {
113 return nil
114 }
115 ret := &DBusInterfaceBase{}
116 ret.Ptr = rawRet
117 return ret
118 }
119}
120
121// OverrideInterfaceAdded sets the "interface_added" callback function.
122// Signal handler for the #GDBusObject::interface-added signal.
123func (x *DBusObjectIface) OverrideInterfaceAdded(cb func(DBusObject, DBusInterface)) {
124 if cb == nil {
125 x.xInterfaceAdded = 0
126 } else {
127 x.xInterfaceAdded = purego.NewCallback(func(ObjectVarp uintptr, InterfaceVarp uintptr) {
128 cb(&DBusObjectBase{Ptr: ObjectVarp}, &DBusInterfaceBase{Ptr: InterfaceVarp})
129 })
130 }
131}
132
133// GetInterfaceAdded gets the "interface_added" callback function.
134// Signal handler for the #GDBusObject::interface-added signal.
135func (x *DBusObjectIface) GetInterfaceAdded() func(DBusObject, DBusInterface) {
136 if x.xInterfaceAdded == 0 {
137 return nil
138 }
139 var rawCallback func(ObjectVarp uintptr, InterfaceVarp uintptr)
140 purego.RegisterFunc(&rawCallback, x.xInterfaceAdded)
141 return func(ObjectVar DBusObject, InterfaceVar DBusInterface) {
142 rawCallback(ObjectVar.GoPointer(), InterfaceVar.GoPointer())
143 }
144}
145
146// OverrideInterfaceRemoved sets the "interface_removed" callback function.
147// Signal handler for the #GDBusObject::interface-removed signal.
148func (x *DBusObjectIface) OverrideInterfaceRemoved(cb func(DBusObject, DBusInterface)) {
149 if cb == nil {
150 x.xInterfaceRemoved = 0
151 } else {
152 x.xInterfaceRemoved = purego.NewCallback(func(ObjectVarp uintptr, InterfaceVarp uintptr) {
153 cb(&DBusObjectBase{Ptr: ObjectVarp}, &DBusInterfaceBase{Ptr: InterfaceVarp})
154 })
155 }
156}
157
158// GetInterfaceRemoved gets the "interface_removed" callback function.
159// Signal handler for the #GDBusObject::interface-removed signal.
160func (x *DBusObjectIface) GetInterfaceRemoved() func(DBusObject, DBusInterface) {
161 if x.xInterfaceRemoved == 0 {
162 return nil
163 }
164 var rawCallback func(ObjectVarp uintptr, InterfaceVarp uintptr)
165 purego.RegisterFunc(&rawCallback, x.xInterfaceRemoved)
166 return func(ObjectVar DBusObject, InterfaceVar DBusInterface) {
167 rawCallback(ObjectVar.GoPointer(), InterfaceVar.GoPointer())
168 }
169}
170
171// The `GDBusObject` type is the base type for D-Bus objects on both
172// the service side (see [class@Gio.DBusObjectSkeleton]) and the client side
173// (see [class@Gio.DBusObjectProxy]). It is essentially just a container of
174// interfaces.
175type DBusObject interface {
176 GoPointer() uintptr
177 SetGoPointer(uintptr)
178 GetInterface(InterfaceNameVar string) *DBusInterfaceBase
179 GetInterfaces() *glib.List
180 GetObjectPath() string
181}
182
183var xDBusObjectGLibType func() types.GType
184
185func DBusObjectGLibType() types.GType {
186 return xDBusObjectGLibType()
187}
188
189type DBusObjectBase struct {
190 Ptr uintptr
191}
192
193func (x *DBusObjectBase) GoPointer() uintptr {
194 if x == nil {
195 return 0
196 }
197 return x.Ptr
198}
199
200func (x *DBusObjectBase) SetGoPointer(ptr uintptr) {
201 x.Ptr = ptr
202}
203
204// Gets the D-Bus interface with name @interface_name associated with
205// @object, if any.
206func (x *DBusObjectBase) GetInterface(InterfaceNameVar string) *DBusInterfaceBase {
207 var cls *DBusInterfaceBase
208
209 cret := XGDbusObjectGetInterface(x.GoPointer(), InterfaceNameVar)
210
211 if cret == 0 {
212 return nil
213 }
214 cls = &DBusInterfaceBase{}
215 cls.Ptr = cret
216 return cls
217}
218
219// Gets the D-Bus interfaces associated with @object.
220func (x *DBusObjectBase) GetInterfaces() *glib.List {
221
222 cret := XGDbusObjectGetInterfaces(x.GoPointer())
223 return cret
224}
225
226// Gets the object path for @object.
227func (x *DBusObjectBase) GetObjectPath() string {
228
229 cret := XGDbusObjectGetObjectPath(x.GoPointer())
230 return cret
231}
232
233var XGDbusObjectGetInterface func(uintptr, string) uintptr
234var XGDbusObjectGetInterfaces func(uintptr) *glib.List
235var XGDbusObjectGetObjectPath func(uintptr) string
236
237func init() {
238 core.SetPackageName("GIO", "gio-2.0")
239 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
240 var libs []uintptr
241 for _, libPath := range core.GetPaths("GIO") {
242 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
243 if err != nil {
244 panic(err)
245 }
246 libs = append(libs, lib)
247 }
248
249 core.PuregoSafeRegister(&xDBusObjectGLibType, libs, "g_dbus_object_get_type")
250
251 core.PuregoSafeRegister(&XGDbusObjectGetInterface, libs, "g_dbus_object_get_interface")
252 core.PuregoSafeRegister(&XGDbusObjectGetInterfaces, libs, "g_dbus_object_get_interfaces")
253 core.PuregoSafeRegister(&XGDbusObjectGetObjectPath, libs, "g_dbus_object_get_object_path")
254
255}