// 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_serializer(). // // When the function gets called to operate on content, it can call functions on the // @serializer object to obtain the mime type, output stream, user data, etc. for its // operation. type ContentSerializeFunc func(uintptr) var xContentRegisterSerializer func(types.GType, string, uintptr, uintptr, uintptr) // Registers a function to serialize objects of a given type. // // Since 4.20, when looking up a serializer to use, GTK will // use the last registered serializer for a given mime type, // so applications can override the built-in serializers. func ContentRegisterSerializer(TypeVar types.GType, MimeTypeVar string, SerializeVar *ContentSerializeFunc, DataVar uintptr, NotifyVar *glib.DestroyNotify) { var SerializeVarRef uintptr if SerializeVar != nil { SerializeVarPtr := uintptr(unsafe.Pointer(SerializeVar)) if cbRefPtr, ok := glib.GetCallback(SerializeVarPtr); ok { SerializeVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *SerializeVar cbFn(arg0) } SerializeVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(SerializeVarPtr, SerializeVarRef, SerializeVar) } } 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) } } xContentRegisterSerializer(TypeVar, MimeTypeVar, SerializeVarRef, DataVar, NotifyVarRef) } var xContentSerializeAsync func(uintptr, string, *gobject.Value, int, uintptr, uintptr, uintptr) // Serialize content and write it to the given output stream, asynchronously. // // The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers // indicate a higher priority. func ContentSerializeAsync(StreamVar *gio.OutputStream, MimeTypeVar string, ValueVar *gobject.Value, 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) } } xContentSerializeAsync(StreamVar.GoPointer(), MimeTypeVar, ValueVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xContentSerializeFinish func(uintptr, **glib.Error) bool // Finishes a content serialization operation. func ContentSerializeFinish(ResultVar gio.AsyncResult) (bool, error) { var cerr *glib.Error cret := xContentSerializeFinish(ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } // Serializes content for inter-application data transfers. // // The `GdkContentSerializer` transforms an object that is identified // by a GType into a serialized form (i.e. a byte stream) that is // identified by a mime type. // // GTK provides serializers and deserializers for common data types // such as text, colors, images or file lists. To register your own // serialization functions, use [func@Gdk.content_register_serializer]. // // Also see [class@Gdk.ContentDeserializer]. type ContentSerializer struct { gobject.Object } var xContentSerializerGLibType func() types.GType func ContentSerializerGLibType() types.GType { return xContentSerializerGLibType() } func ContentSerializerNewFromInternalPtr(ptr uintptr) *ContentSerializer { cls := &ContentSerializer{} cls.Ptr = ptr return cls } var xContentSerializerGetCancellable func(uintptr) uintptr // Gets the cancellable for the current operation. // // This is the `GCancellable` that was passed to [func@content_serialize_async]. func (x *ContentSerializer) GetCancellable() *gio.Cancellable { var cls *gio.Cancellable cret := xContentSerializerGetCancellable(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.Cancellable{} cls.Ptr = cret return cls } var xContentSerializerGetGtype func(uintptr) types.GType // Gets the `GType` to of the object to serialize. func (x *ContentSerializer) GetGtype() types.GType { cret := xContentSerializerGetGtype(x.GoPointer()) return cret } var xContentSerializerGetMimeType func(uintptr) string // Gets the mime type to serialize to. func (x *ContentSerializer) GetMimeType() string { cret := xContentSerializerGetMimeType(x.GoPointer()) return cret } var xContentSerializerGetOutputStream func(uintptr) uintptr // Gets the output stream for the current operation. // // This is the stream that was passed to [func@content_serialize_async]. func (x *ContentSerializer) GetOutputStream() *gio.OutputStream { var cls *gio.OutputStream cret := xContentSerializerGetOutputStream(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.OutputStream{} cls.Ptr = cret return cls } var xContentSerializerGetPriority func(uintptr) int // Gets the I/O priority for the current operation. // // This is the priority that was passed to [func@content_serialize_async]. func (x *ContentSerializer) GetPriority() int { cret := xContentSerializerGetPriority(x.GoPointer()) return cret } var xContentSerializerGetTaskData func(uintptr) uintptr // Gets the data that was associated with the current operation. // // See [method@Gdk.ContentSerializer.set_task_data]. func (x *ContentSerializer) GetTaskData() uintptr { cret := xContentSerializerGetTaskData(x.GoPointer()) return cret } var xContentSerializerGetUserData func(uintptr) uintptr // Gets the user data that was passed when the serializer was registered. func (x *ContentSerializer) GetUserData() uintptr { cret := xContentSerializerGetUserData(x.GoPointer()) return cret } var xContentSerializerGetValue func(uintptr) *gobject.Value // Gets the `GValue` to read the object to serialize from. func (x *ContentSerializer) GetValue() *gobject.Value { cret := xContentSerializerGetValue(x.GoPointer()) return cret } var xContentSerializerReturnError func(uintptr, *glib.Error) // Indicate that the serialization has ended with an error. // // This function consumes @error. func (x *ContentSerializer) ReturnError(ErrorVar *glib.Error) { xContentSerializerReturnError(x.GoPointer(), ErrorVar) } var xContentSerializerReturnSuccess func(uintptr) // Indicate that the serialization has been successfully completed. func (x *ContentSerializer) ReturnSuccess() { xContentSerializerReturnSuccess(x.GoPointer()) } var xContentSerializerSetTaskData func(uintptr, uintptr, uintptr) // Associate data with the current serialization operation. func (x *ContentSerializer) 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) } } xContentSerializerSetTaskData(x.GoPointer(), DataVar, NotifyVarRef) } func (c *ContentSerializer) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *ContentSerializer) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Gets the source object from a [iface@Gio.AsyncResult]. func (x *ContentSerializer) 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 *ContentSerializer) 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 *ContentSerializer) 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(&xContentRegisterSerializer, libs, "gdk_content_register_serializer") core.PuregoSafeRegister(&xContentSerializeAsync, libs, "gdk_content_serialize_async") core.PuregoSafeRegister(&xContentSerializeFinish, libs, "gdk_content_serialize_finish") core.PuregoSafeRegister(&xContentSerializerGLibType, libs, "gdk_content_serializer_get_type") core.PuregoSafeRegister(&xContentSerializerGetCancellable, libs, "gdk_content_serializer_get_cancellable") core.PuregoSafeRegister(&xContentSerializerGetGtype, libs, "gdk_content_serializer_get_gtype") core.PuregoSafeRegister(&xContentSerializerGetMimeType, libs, "gdk_content_serializer_get_mime_type") core.PuregoSafeRegister(&xContentSerializerGetOutputStream, libs, "gdk_content_serializer_get_output_stream") core.PuregoSafeRegister(&xContentSerializerGetPriority, libs, "gdk_content_serializer_get_priority") core.PuregoSafeRegister(&xContentSerializerGetTaskData, libs, "gdk_content_serializer_get_task_data") core.PuregoSafeRegister(&xContentSerializerGetUserData, libs, "gdk_content_serializer_get_user_data") core.PuregoSafeRegister(&xContentSerializerGetValue, libs, "gdk_content_serializer_get_value") core.PuregoSafeRegister(&xContentSerializerReturnError, libs, "gdk_content_serializer_return_error") core.PuregoSafeRegister(&xContentSerializerReturnSuccess, libs, "gdk_content_serializer_return_success") core.PuregoSafeRegister(&xContentSerializerSetTaskData, libs, "gdk_content_serializer_set_task_data") }