// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gdk import ( "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gio" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // The type of a function that can be registered with gdk_content_register_deserializer(). // // When the function gets called to operate on content, it can call functions on the // @deserializer object to obtain the mime type, input stream, user data, etc. for its // operation. type ContentDeserializeFunc func(uintptr) var xContentDeserializeAsync func(uintptr, string, types.GType, int, uintptr, uintptr, uintptr) // Reads content from the given input stream and deserialize it, asynchronously. // // The default I/O priority is `G_PRIORITY_DEFAULT` (i.e. 0), and lower numbers // indicate a higher priority. func ContentDeserializeAsync(StreamVar *gio.InputStream, MimeTypeVar string, TypeVar types.GType, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xContentDeserializeAsync(StreamVar.GoPointer(), MimeTypeVar, TypeVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xContentDeserializeFinish func(uintptr, *gobject.Value, **glib.Error) bool // Finishes a content deserialization operation. func ContentDeserializeFinish(ResultVar gio.AsyncResult, ValueVar *gobject.Value) (bool, error) { var cerr *glib.Error cret := xContentDeserializeFinish(ResultVar.GoPointer(), ValueVar, &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xContentRegisterDeserializer func(string, types.GType, uintptr, uintptr, uintptr) // Registers a function to deserialize object of a given type. // // Since 4.20, when looking up a deserializer to use, GTK will // use the last registered deserializer for a given mime type, // so applications can override the built-in deserializers. func ContentRegisterDeserializer(MimeTypeVar string, TypeVar types.GType, DeserializeVar *ContentDeserializeFunc, DataVar uintptr, NotifyVar *glib.DestroyNotify) { var DeserializeVarRef uintptr if DeserializeVar != nil { DeserializeVarPtr := uintptr(unsafe.Pointer(DeserializeVar)) if cbRefPtr, ok := glib.GetCallback(DeserializeVarPtr); ok { DeserializeVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *DeserializeVar cbFn(arg0) } DeserializeVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(DeserializeVarPtr, DeserializeVarRef, DeserializeVar) } } var NotifyVarRef uintptr if NotifyVar != nil { NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar)) if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok { NotifyVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *NotifyVar cbFn(arg0) } NotifyVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar) } } xContentRegisterDeserializer(MimeTypeVar, TypeVar, DeserializeVarRef, DataVar, NotifyVarRef) } // Deserializes content received via inter-application data transfers. // // The `GdkContentDeserializer` transforms serialized content that is // identified by a mime type into an object identified by a GType. // // GTK provides serializers and deserializers for common data types // such as text, colors, images or file lists. To register your own // deserialization functions, use [func@content_register_deserializer]. // // Also see [class@Gdk.ContentSerializer]. type ContentDeserializer struct { gobject.Object } var xContentDeserializerGLibType func() types.GType func ContentDeserializerGLibType() types.GType { return xContentDeserializerGLibType() } func ContentDeserializerNewFromInternalPtr(ptr uintptr) *ContentDeserializer { cls := &ContentDeserializer{} cls.Ptr = ptr return cls } var xContentDeserializerGetCancellable func(uintptr) uintptr // Gets the cancellable for the current operation. // // This is the `GCancellable` that was passed to [func@Gdk.content_deserialize_async]. func (x *ContentDeserializer) GetCancellable() *gio.Cancellable { var cls *gio.Cancellable cret := xContentDeserializerGetCancellable(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.Cancellable{} cls.Ptr = cret return cls } var xContentDeserializerGetGtype func(uintptr) types.GType // Gets the `GType` to create an instance of. func (x *ContentDeserializer) GetGtype() types.GType { cret := xContentDeserializerGetGtype(x.GoPointer()) return cret } var xContentDeserializerGetInputStream func(uintptr) uintptr // Gets the input stream for the current operation. // // This is the stream that was passed to [func@Gdk.content_deserialize_async]. func (x *ContentDeserializer) GetInputStream() *gio.InputStream { var cls *gio.InputStream cret := xContentDeserializerGetInputStream(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.InputStream{} cls.Ptr = cret return cls } var xContentDeserializerGetMimeType func(uintptr) string // Gets the mime type to deserialize from. func (x *ContentDeserializer) GetMimeType() string { cret := xContentDeserializerGetMimeType(x.GoPointer()) return cret } var xContentDeserializerGetPriority func(uintptr) int // Gets the I/O priority for the current operation. // // This is the priority that was passed to [func@Gdk.content_deserialize_async]. func (x *ContentDeserializer) GetPriority() int { cret := xContentDeserializerGetPriority(x.GoPointer()) return cret } var xContentDeserializerGetTaskData func(uintptr) uintptr // Gets the data that was associated with the current operation. // // See [method@Gdk.ContentDeserializer.set_task_data]. func (x *ContentDeserializer) GetTaskData() uintptr { cret := xContentDeserializerGetTaskData(x.GoPointer()) return cret } var xContentDeserializerGetUserData func(uintptr) uintptr // Gets the user data that was passed when the deserializer was registered. func (x *ContentDeserializer) GetUserData() uintptr { cret := xContentDeserializerGetUserData(x.GoPointer()) return cret } var xContentDeserializerGetValue func(uintptr) *gobject.Value // Gets the `GValue` to store the deserialized object in. func (x *ContentDeserializer) GetValue() *gobject.Value { cret := xContentDeserializerGetValue(x.GoPointer()) return cret } var xContentDeserializerReturnError func(uintptr, *glib.Error) // Indicate that the deserialization has ended with an error. // // This function consumes @error. func (x *ContentDeserializer) ReturnError(ErrorVar *glib.Error) { xContentDeserializerReturnError(x.GoPointer(), ErrorVar) } var xContentDeserializerReturnSuccess func(uintptr) // Indicate that the deserialization has been successfully completed. func (x *ContentDeserializer) ReturnSuccess() { xContentDeserializerReturnSuccess(x.GoPointer()) } var xContentDeserializerSetTaskData func(uintptr, uintptr, uintptr) // Associate data with the current deserialization operation. func (x *ContentDeserializer) SetTaskData(DataVar uintptr, NotifyVar *glib.DestroyNotify) { var NotifyVarRef uintptr if NotifyVar != nil { NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar)) if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok { NotifyVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *NotifyVar cbFn(arg0) } NotifyVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar) } } xContentDeserializerSetTaskData(x.GoPointer(), DataVar, NotifyVarRef) } func (c *ContentDeserializer) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *ContentDeserializer) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Gets the source object from a [iface@Gio.AsyncResult]. func (x *ContentDeserializer) GetSourceObject() *gobject.Object { var cls *gobject.Object cret := gio.XGAsyncResultGetSourceObject(x.GoPointer()) if cret == 0 { return nil } cls = &gobject.Object{} cls.Ptr = cret return cls } // Checks if @res has the given @source_tag (generally a function // pointer indicating the function @res was created by). func (x *ContentDeserializer) IsTagged(SourceTagVar uintptr) bool { cret := gio.XGAsyncResultIsTagged(x.GoPointer(), SourceTagVar) return cret } // If @res is a [class@Gio.SimpleAsyncResult], this is equivalent to // [method@Gio.SimpleAsyncResult.propagate_error]. Otherwise it returns // `FALSE`. // // This can be used for legacy error handling in async `*_finish()` // wrapper functions that traditionally handled [class@Gio.SimpleAsyncResult] // error returns themselves rather than calling into the virtual method. // This should not be used in new code; [iface@Gio.AsyncResult] errors that are // set by virtual methods should also be extracted by virtual methods, // to enable subclasses to chain up correctly. func (x *ContentDeserializer) LegacyPropagateError() (bool, error) { var cerr *glib.Error cret := gio.XGAsyncResultLegacyPropagateError(x.GoPointer()) if cerr == nil { return cret, nil } return cret, cerr } func init() { core.SetPackageName("GDK", "gtk4") core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GDK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xContentDeserializeAsync, libs, "gdk_content_deserialize_async") core.PuregoSafeRegister(&xContentDeserializeFinish, libs, "gdk_content_deserialize_finish") core.PuregoSafeRegister(&xContentRegisterDeserializer, libs, "gdk_content_register_deserializer") core.PuregoSafeRegister(&xContentDeserializerGLibType, libs, "gdk_content_deserializer_get_type") core.PuregoSafeRegister(&xContentDeserializerGetCancellable, libs, "gdk_content_deserializer_get_cancellable") core.PuregoSafeRegister(&xContentDeserializerGetGtype, libs, "gdk_content_deserializer_get_gtype") core.PuregoSafeRegister(&xContentDeserializerGetInputStream, libs, "gdk_content_deserializer_get_input_stream") core.PuregoSafeRegister(&xContentDeserializerGetMimeType, libs, "gdk_content_deserializer_get_mime_type") core.PuregoSafeRegister(&xContentDeserializerGetPriority, libs, "gdk_content_deserializer_get_priority") core.PuregoSafeRegister(&xContentDeserializerGetTaskData, libs, "gdk_content_deserializer_get_task_data") core.PuregoSafeRegister(&xContentDeserializerGetUserData, libs, "gdk_content_deserializer_get_user_data") core.PuregoSafeRegister(&xContentDeserializerGetValue, libs, "gdk_content_deserializer_get_value") core.PuregoSafeRegister(&xContentDeserializerReturnError, libs, "gdk_content_deserializer_return_error") core.PuregoSafeRegister(&xContentDeserializerReturnSuccess, libs, "gdk_content_deserializer_return_success") core.PuregoSafeRegister(&xContentDeserializerSetTaskData, libs, "gdk_content_deserializer_set_task_data") }