1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/gio"
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// The type of a function that can be registered with gdk_content_register_deserializer().
17//
18// When the function gets called to operate on content, it can call functions on the
19// @deserializer object to obtain the mime type, input stream, user data, etc. for its
20// operation.
21type ContentDeserializeFunc func(uintptr)
22
23var xContentDeserializeAsync func(uintptr, string, types.GType, int, uintptr, uintptr, uintptr)
24
25// Reads content from the given input stream and deserialize it, asynchronously.
26//
27// The default I/O priority is `G_PRIORITY_DEFAULT` (i.e. 0), and lower numbers
28// indicate a higher priority.
29func ContentDeserializeAsync(StreamVar *gio.InputStream, MimeTypeVar string, TypeVar types.GType, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
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 xContentDeserializeAsync(StreamVar.GoPointer(), MimeTypeVar, TypeVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
47
48}
49
50var xContentDeserializeFinish func(uintptr, *gobject.Value, **glib.Error) bool
51
52// Finishes a content deserialization operation.
53func ContentDeserializeFinish(ResultVar gio.AsyncResult, ValueVar *gobject.Value) (bool, error) {
54 var cerr *glib.Error
55
56 cret := xContentDeserializeFinish(ResultVar.GoPointer(), ValueVar, &cerr)
57 if cerr == nil {
58 return cret, nil
59 }
60 return cret, cerr
61
62}
63
64var xContentRegisterDeserializer func(string, types.GType, uintptr, uintptr, uintptr)
65
66// Registers a function to deserialize object of a given type.
67//
68// Since 4.20, when looking up a deserializer to use, GTK will
69// use the last registered deserializer for a given mime type,
70// so applications can override the built-in deserializers.
71func ContentRegisterDeserializer(MimeTypeVar string, TypeVar types.GType, DeserializeVar *ContentDeserializeFunc, DataVar uintptr, NotifyVar *glib.DestroyNotify) {
72
73 var DeserializeVarRef uintptr
74 if DeserializeVar != nil {
75 DeserializeVarPtr := uintptr(unsafe.Pointer(DeserializeVar))
76 if cbRefPtr, ok := glib.GetCallback(DeserializeVarPtr); ok {
77 DeserializeVarRef = cbRefPtr
78 } else {
79 fcb := func(arg0 uintptr) {
80 cbFn := *DeserializeVar
81 cbFn(arg0)
82 }
83 DeserializeVarRef = purego.NewCallback(fcb)
84 glib.SaveCallbackWithClosure(DeserializeVarPtr, DeserializeVarRef, DeserializeVar)
85 }
86 }
87
88 var NotifyVarRef uintptr
89 if NotifyVar != nil {
90 NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar))
91 if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok {
92 NotifyVarRef = cbRefPtr
93 } else {
94 fcb := func(arg0 uintptr) {
95 cbFn := *NotifyVar
96 cbFn(arg0)
97 }
98 NotifyVarRef = purego.NewCallback(fcb)
99 glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar)
100 }
101 }
102
103 xContentRegisterDeserializer(MimeTypeVar, TypeVar, DeserializeVarRef, DataVar, NotifyVarRef)
104
105}
106
107// Deserializes content received via inter-application data transfers.
108//
109// The `GdkContentDeserializer` transforms serialized content that is
110// identified by a mime type into an object identified by a GType.
111//
112// GTK provides serializers and deserializers for common data types
113// such as text, colors, images or file lists. To register your own
114// deserialization functions, use [func@content_register_deserializer].
115//
116// Also see [class@Gdk.ContentSerializer].
117type ContentDeserializer struct {
118 gobject.Object
119}
120
121var xContentDeserializerGLibType func() types.GType
122
123func ContentDeserializerGLibType() types.GType {
124 return xContentDeserializerGLibType()
125}
126
127func ContentDeserializerNewFromInternalPtr(ptr uintptr) *ContentDeserializer {
128 cls := &ContentDeserializer{}
129 cls.Ptr = ptr
130 return cls
131}
132
133var xContentDeserializerGetCancellable func(uintptr) uintptr
134
135// Gets the cancellable for the current operation.
136//
137// This is the `GCancellable` that was passed to [func@Gdk.content_deserialize_async].
138func (x *ContentDeserializer) GetCancellable() *gio.Cancellable {
139 var cls *gio.Cancellable
140
141 cret := xContentDeserializerGetCancellable(x.GoPointer())
142
143 if cret == 0 {
144 return nil
145 }
146 gobject.IncreaseRef(cret)
147 cls = &gio.Cancellable{}
148 cls.Ptr = cret
149 return cls
150}
151
152var xContentDeserializerGetGtype func(uintptr) types.GType
153
154// Gets the `GType` to create an instance of.
155func (x *ContentDeserializer) GetGtype() types.GType {
156
157 cret := xContentDeserializerGetGtype(x.GoPointer())
158 return cret
159}
160
161var xContentDeserializerGetInputStream func(uintptr) uintptr
162
163// Gets the input stream for the current operation.
164//
165// This is the stream that was passed to [func@Gdk.content_deserialize_async].
166func (x *ContentDeserializer) GetInputStream() *gio.InputStream {
167 var cls *gio.InputStream
168
169 cret := xContentDeserializerGetInputStream(x.GoPointer())
170
171 if cret == 0 {
172 return nil
173 }
174 gobject.IncreaseRef(cret)
175 cls = &gio.InputStream{}
176 cls.Ptr = cret
177 return cls
178}
179
180var xContentDeserializerGetMimeType func(uintptr) string
181
182// Gets the mime type to deserialize from.
183func (x *ContentDeserializer) GetMimeType() string {
184
185 cret := xContentDeserializerGetMimeType(x.GoPointer())
186 return cret
187}
188
189var xContentDeserializerGetPriority func(uintptr) int
190
191// Gets the I/O priority for the current operation.
192//
193// This is the priority that was passed to [func@Gdk.content_deserialize_async].
194func (x *ContentDeserializer) GetPriority() int {
195
196 cret := xContentDeserializerGetPriority(x.GoPointer())
197 return cret
198}
199
200var xContentDeserializerGetTaskData func(uintptr) uintptr
201
202// Gets the data that was associated with the current operation.
203//
204// See [method@Gdk.ContentDeserializer.set_task_data].
205func (x *ContentDeserializer) GetTaskData() uintptr {
206
207 cret := xContentDeserializerGetTaskData(x.GoPointer())
208 return cret
209}
210
211var xContentDeserializerGetUserData func(uintptr) uintptr
212
213// Gets the user data that was passed when the deserializer was registered.
214func (x *ContentDeserializer) GetUserData() uintptr {
215
216 cret := xContentDeserializerGetUserData(x.GoPointer())
217 return cret
218}
219
220var xContentDeserializerGetValue func(uintptr) *gobject.Value
221
222// Gets the `GValue` to store the deserialized object in.
223func (x *ContentDeserializer) GetValue() *gobject.Value {
224
225 cret := xContentDeserializerGetValue(x.GoPointer())
226 return cret
227}
228
229var xContentDeserializerReturnError func(uintptr, *glib.Error)
230
231// Indicate that the deserialization has ended with an error.
232//
233// This function consumes @error.
234func (x *ContentDeserializer) ReturnError(ErrorVar *glib.Error) {
235
236 xContentDeserializerReturnError(x.GoPointer(), ErrorVar)
237
238}
239
240var xContentDeserializerReturnSuccess func(uintptr)
241
242// Indicate that the deserialization has been successfully completed.
243func (x *ContentDeserializer) ReturnSuccess() {
244
245 xContentDeserializerReturnSuccess(x.GoPointer())
246
247}
248
249var xContentDeserializerSetTaskData func(uintptr, uintptr, uintptr)
250
251// Associate data with the current deserialization operation.
252func (x *ContentDeserializer) SetTaskData(DataVar uintptr, NotifyVar *glib.DestroyNotify) {
253
254 var NotifyVarRef uintptr
255 if NotifyVar != nil {
256 NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar))
257 if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok {
258 NotifyVarRef = cbRefPtr
259 } else {
260 fcb := func(arg0 uintptr) {
261 cbFn := *NotifyVar
262 cbFn(arg0)
263 }
264 NotifyVarRef = purego.NewCallback(fcb)
265 glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar)
266 }
267 }
268
269 xContentDeserializerSetTaskData(x.GoPointer(), DataVar, NotifyVarRef)
270
271}
272
273func (c *ContentDeserializer) GoPointer() uintptr {
274 if c == nil {
275 return 0
276 }
277 return c.Ptr
278}
279
280func (c *ContentDeserializer) SetGoPointer(ptr uintptr) {
281 c.Ptr = ptr
282}
283
284// Gets the source object from a [iface@Gio.AsyncResult].
285func (x *ContentDeserializer) GetSourceObject() *gobject.Object {
286 var cls *gobject.Object
287
288 cret := gio.XGAsyncResultGetSourceObject(x.GoPointer())
289
290 if cret == 0 {
291 return nil
292 }
293 cls = &gobject.Object{}
294 cls.Ptr = cret
295 return cls
296}
297
298// Checks if @res has the given @source_tag (generally a function
299// pointer indicating the function @res was created by).
300func (x *ContentDeserializer) IsTagged(SourceTagVar uintptr) bool {
301
302 cret := gio.XGAsyncResultIsTagged(x.GoPointer(), SourceTagVar)
303 return cret
304}
305
306// If @res is a [class@Gio.SimpleAsyncResult], this is equivalent to
307// [method@Gio.SimpleAsyncResult.propagate_error]. Otherwise it returns
308// `FALSE`.
309//
310// This can be used for legacy error handling in async `*_finish()`
311// wrapper functions that traditionally handled [class@Gio.SimpleAsyncResult]
312// error returns themselves rather than calling into the virtual method.
313// This should not be used in new code; [iface@Gio.AsyncResult] errors that are
314// set by virtual methods should also be extracted by virtual methods,
315// to enable subclasses to chain up correctly.
316func (x *ContentDeserializer) LegacyPropagateError() (bool, error) {
317 var cerr *glib.Error
318
319 cret := gio.XGAsyncResultLegacyPropagateError(x.GoPointer())
320 if cerr == nil {
321 return cret, nil
322 }
323 return cret, cerr
324
325}
326
327func init() {
328 core.SetPackageName("GDK", "gtk4")
329 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
330 var libs []uintptr
331 for _, libPath := range core.GetPaths("GDK") {
332 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
333 if err != nil {
334 panic(err)
335 }
336 libs = append(libs, lib)
337 }
338
339 core.PuregoSafeRegister(&xContentDeserializeAsync, libs, "gdk_content_deserialize_async")
340 core.PuregoSafeRegister(&xContentDeserializeFinish, libs, "gdk_content_deserialize_finish")
341 core.PuregoSafeRegister(&xContentRegisterDeserializer, libs, "gdk_content_register_deserializer")
342
343 core.PuregoSafeRegister(&xContentDeserializerGLibType, libs, "gdk_content_deserializer_get_type")
344
345 core.PuregoSafeRegister(&xContentDeserializerGetCancellable, libs, "gdk_content_deserializer_get_cancellable")
346 core.PuregoSafeRegister(&xContentDeserializerGetGtype, libs, "gdk_content_deserializer_get_gtype")
347 core.PuregoSafeRegister(&xContentDeserializerGetInputStream, libs, "gdk_content_deserializer_get_input_stream")
348 core.PuregoSafeRegister(&xContentDeserializerGetMimeType, libs, "gdk_content_deserializer_get_mime_type")
349 core.PuregoSafeRegister(&xContentDeserializerGetPriority, libs, "gdk_content_deserializer_get_priority")
350 core.PuregoSafeRegister(&xContentDeserializerGetTaskData, libs, "gdk_content_deserializer_get_task_data")
351 core.PuregoSafeRegister(&xContentDeserializerGetUserData, libs, "gdk_content_deserializer_get_user_data")
352 core.PuregoSafeRegister(&xContentDeserializerGetValue, libs, "gdk_content_deserializer_get_value")
353 core.PuregoSafeRegister(&xContentDeserializerReturnError, libs, "gdk_content_deserializer_return_error")
354 core.PuregoSafeRegister(&xContentDeserializerReturnSuccess, libs, "gdk_content_deserializer_return_success")
355 core.PuregoSafeRegister(&xContentDeserializerSetTaskData, libs, "gdk_content_deserializer_set_task_data")
356
357}