1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type DmabufTextureClass struct {
17 _ structs.HostLayout
18}
19
20func (x *DmabufTextureClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24var xDmabufErrorQuark func() glib.Quark
25
26// Registers an error quark for [class@Gdk.DmabufTexture] errors.
27func DmabufErrorQuark() glib.Quark {
28
29 cret := xDmabufErrorQuark()
30 return cret
31}
32
33// A `GdkTexture` representing a DMA buffer.
34//
35// To create a `GdkDmabufTexture`, use the auxiliary
36// [class@Gdk.DmabufTextureBuilder] object.
37//
38// Dma-buf textures can only be created on Linux.
39type DmabufTexture struct {
40 Texture
41}
42
43var xDmabufTextureGLibType func() types.GType
44
45func DmabufTextureGLibType() types.GType {
46 return xDmabufTextureGLibType()
47}
48
49func DmabufTextureNewFromInternalPtr(ptr uintptr) *DmabufTexture {
50 cls := &DmabufTexture{}
51 cls.Ptr = ptr
52 return cls
53}
54
55func (c *DmabufTexture) GoPointer() uintptr {
56 if c == nil {
57 return 0
58 }
59 return c.Ptr
60}
61
62func (c *DmabufTexture) SetGoPointer(ptr uintptr) {
63 c.Ptr = ptr
64}
65
66// Compute a concrete size for the `GdkPaintable`.
67//
68// Applies the sizing algorithm outlined in the
69// [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing)
70// to the given @paintable. See that link for more details.
71//
72// It is not necessary to call this function when both @specified_width
73// and @specified_height are known, but it is useful to call this
74// function in GtkWidget:measure implementations to compute the
75// other dimension when only one dimension is given.
76func (x *DmabufTexture) ComputeConcreteSize(SpecifiedWidthVar float64, SpecifiedHeightVar float64, DefaultWidthVar float64, DefaultHeightVar float64, ConcreteWidthVar *float64, ConcreteHeightVar *float64) {
77
78 XGdkPaintableComputeConcreteSize(x.GoPointer(), SpecifiedWidthVar, SpecifiedHeightVar, DefaultWidthVar, DefaultHeightVar, ConcreteWidthVar, ConcreteHeightVar)
79
80}
81
82// Gets an immutable paintable for the current contents displayed by @paintable.
83//
84// This is useful when you want to retain the current state of an animation,
85// for example to take a screenshot of a running animation.
86//
87// If the @paintable is already immutable, it will return itself.
88func (x *DmabufTexture) GetCurrentImage() *PaintableBase {
89 var cls *PaintableBase
90
91 cret := XGdkPaintableGetCurrentImage(x.GoPointer())
92
93 if cret == 0 {
94 return nil
95 }
96 cls = &PaintableBase{}
97 cls.Ptr = cret
98 return cls
99}
100
101// Get flags for the paintable.
102//
103// This is oftentimes useful for optimizations.
104//
105// See [flags@Gdk.PaintableFlags] for the flags and what they mean.
106func (x *DmabufTexture) GetFlags() PaintableFlags {
107
108 cret := XGdkPaintableGetFlags(x.GoPointer())
109 return cret
110}
111
112// Gets the preferred aspect ratio the @paintable would like to be displayed at.
113//
114// The aspect ratio is the width divided by the height, so a value of 0.5
115// means that the @paintable prefers to be displayed twice as high as it
116// is wide. Consumers of this interface can use this to preserve aspect
117// ratio when displaying the paintable.
118//
119// This is a purely informational value and does not in any way limit the
120// values that may be passed to [method@Gdk.Paintable.snapshot].
121//
122// Usually when a @paintable returns nonzero values from
123// [method@Gdk.Paintable.get_intrinsic_width] and
124// [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio
125// should conform to those values, though that is not required.
126//
127// If the @paintable does not have a preferred aspect ratio,
128// it returns 0. Negative values are never returned.
129func (x *DmabufTexture) GetIntrinsicAspectRatio() float64 {
130
131 cret := XGdkPaintableGetIntrinsicAspectRatio(x.GoPointer())
132 return cret
133}
134
135// Gets the preferred height the @paintable would like to be displayed at.
136//
137// Consumers of this interface can use this to reserve enough space to draw
138// the paintable.
139//
140// This is a purely informational value and does not in any way limit the
141// values that may be passed to [method@Gdk.Paintable.snapshot].
142//
143// If the @paintable does not have a preferred height, it returns 0.
144// Negative values are never returned.
145func (x *DmabufTexture) GetIntrinsicHeight() int {
146
147 cret := XGdkPaintableGetIntrinsicHeight(x.GoPointer())
148 return cret
149}
150
151// Gets the preferred width the @paintable would like to be displayed at.
152//
153// Consumers of this interface can use this to reserve enough space to draw
154// the paintable.
155//
156// This is a purely informational value and does not in any way limit the
157// values that may be passed to [method@Gdk.Paintable.snapshot].
158//
159// If the @paintable does not have a preferred width, it returns 0.
160// Negative values are never returned.
161func (x *DmabufTexture) GetIntrinsicWidth() int {
162
163 cret := XGdkPaintableGetIntrinsicWidth(x.GoPointer())
164 return cret
165}
166
167// Called by implementations of `GdkPaintable` to invalidate their contents.
168//
169// Unless the contents are invalidated, implementations must guarantee that
170// multiple calls of [method@Gdk.Paintable.snapshot] produce the same output.
171//
172// This function will emit the [signal@Gdk.Paintable::invalidate-contents]
173// signal.
174//
175// If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag,
176// it must not call this function.
177func (x *DmabufTexture) InvalidateContents() {
178
179 XGdkPaintableInvalidateContents(x.GoPointer())
180
181}
182
183// Called by implementations of `GdkPaintable` to invalidate their size.
184//
185// As long as the size is not invalidated, @paintable must return the same
186// values for its intrinsic width, height and aspect ratio.
187//
188// This function will emit the [signal@Gdk.Paintable::invalidate-size]
189// signal.
190//
191// If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag,
192// it must not call this function.
193func (x *DmabufTexture) InvalidateSize() {
194
195 XGdkPaintableInvalidateSize(x.GoPointer())
196
197}
198
199// Snapshots the given paintable with the given @width and @height.
200//
201// The paintable is drawn at the current (0,0) offset of the @snapshot.
202// If @width and @height are not larger than zero, this function will
203// do nothing.
204func (x *DmabufTexture) Snapshot(SnapshotVar *Snapshot, WidthVar float64, HeightVar float64) {
205
206 XGdkPaintableSnapshot(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar)
207
208}
209
210// Checks if two icons are equal.
211func (x *DmabufTexture) Equal(Icon2Var gio.Icon) bool {
212
213 cret := gio.XGIconEqual(x.GoPointer(), Icon2Var.GoPointer())
214 return cret
215}
216
217// Gets a hash for an icon.
218func (x *DmabufTexture) Hash() uint {
219
220 cret := gio.XGIconHash(x.GoPointer())
221 return cret
222}
223
224// Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
225// back by calling g_icon_deserialize() on the returned value.
226// As serialization will avoid using raw icon data when possible, it only
227// makes sense to transfer the #GVariant between processes on the same machine,
228// (as opposed to over the network), and within the same file system namespace.
229func (x *DmabufTexture) Serialize() *glib.Variant {
230
231 cret := gio.XGIconSerialize(x.GoPointer())
232 return cret
233}
234
235// Generates a textual representation of @icon that can be used for
236// serialization such as when passing @icon to a different process or
237// saving it to persistent storage. Use g_icon_new_for_string() to
238// get @icon back from the returned string.
239//
240// The encoding of the returned string is proprietary to #GIcon except
241// in the following two cases
242//
243// - If @icon is a #GFileIcon, the returned string is a native path
244// (such as `/path/to/my icon.png`) without escaping
245// if the #GFile for @icon is a native file. If the file is not
246// native, the returned string is the result of g_file_get_uri()
247// (such as `sftp://path/to/my%20icon.png`).
248//
249// - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
250// the encoding is simply the name (such as `network-server`).
251func (x *DmabufTexture) ToString() string {
252
253 cret := gio.XGIconToString(x.GoPointer())
254 return cret
255}
256
257// Loads a loadable icon. For the asynchronous version of this function,
258// see g_loadable_icon_load_async().
259func (x *DmabufTexture) Load(SizeVar int, TypeVar *string, CancellableVar *gio.Cancellable) (*gio.InputStream, error) {
260 var cls *gio.InputStream
261 var cerr *glib.Error
262
263 cret := gio.XGLoadableIconLoad(x.GoPointer(), SizeVar, TypeVar, CancellableVar.GoPointer(), &cerr)
264
265 if cret == 0 {
266 return nil, cerr
267 }
268 cls = &gio.InputStream{}
269 cls.Ptr = cret
270 if cerr == nil {
271 return cls, nil
272 }
273 return cls, cerr
274
275}
276
277// Loads an icon asynchronously. To finish this function, see
278// g_loadable_icon_load_finish(). For the synchronous, blocking
279// version of this function, see g_loadable_icon_load().
280func (x *DmabufTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
281
282 gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
283
284}
285
286// Finishes an asynchronous icon load started in g_loadable_icon_load_async().
287func (x *DmabufTexture) LoadFinish(ResVar gio.AsyncResult, TypeVar *string) (*gio.InputStream, error) {
288 var cls *gio.InputStream
289 var cerr *glib.Error
290
291 cret := gio.XGLoadableIconLoadFinish(x.GoPointer(), ResVar.GoPointer(), TypeVar, &cerr)
292
293 if cret == 0 {
294 return nil, cerr
295 }
296 cls = &gio.InputStream{}
297 cls.Ptr = cret
298 if cerr == nil {
299 return cls, nil
300 }
301 return cls, cerr
302
303}
304
305func init() {
306 core.SetPackageName("GDK", "gtk4")
307 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
308 var libs []uintptr
309 for _, libPath := range core.GetPaths("GDK") {
310 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
311 if err != nil {
312 panic(err)
313 }
314 libs = append(libs, lib)
315 }
316
317 core.PuregoSafeRegister(&xDmabufErrorQuark, libs, "gdk_dmabuf_error_quark")
318
319 core.PuregoSafeRegister(&xDmabufTextureGLibType, libs, "gdk_dmabuf_texture_get_type")
320
321}