1// Package gdkpixbuf was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdkpixbuf
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/gmodule"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// Sets up the image loading state.
17//
18// The image loader is responsible for storing the given function pointers
19// and user data, and call them when needed.
20//
21// The image loader should set up an internal state object, and return it
22// from this function; the state object will then be updated from the
23// [callback@GdkPixbuf.PixbufModuleIncrementLoadFunc] callback, and will be freed
24// by [callback@GdkPixbuf.PixbufModuleStopLoadFunc] callback.
25type PixbufModuleBeginLoadFunc func(uintptr, uintptr, uintptr, uintptr, **glib.Error) uintptr
26
27// Defines the type of the function used to fill a
28// #GdkPixbufFormat structure with information about a module.
29type PixbufModuleFillInfoFunc func(*PixbufFormat)
30
31// Defines the type of the function used to set the vtable of a
32// #GdkPixbufModule when it is loaded.
33type PixbufModuleFillVtableFunc func(*PixbufModule)
34
35// Incrementally loads a buffer into the image data.
36type PixbufModuleIncrementLoadFunc func(uintptr, []byte, uint, **glib.Error) bool
37
38// Loads a file from a standard C file stream into a new `GdkPixbufAnimation`.
39//
40// In case of error, this function should return `NULL` and set the `error` argument.
41type PixbufModuleLoadAnimationFunc func(uintptr, **glib.Error) uintptr
42
43// Loads a file from a standard C file stream into a new `GdkPixbuf`.
44//
45// In case of error, this function should return `NULL` and set the `error` argument.
46type PixbufModuleLoadFunc func(uintptr, **glib.Error) uintptr
47
48// Loads XPM data into a new `GdkPixbuf`.
49type PixbufModuleLoadXpmDataFunc func([]string) uintptr
50
51// Defines the type of the function that gets called once the initial
52// setup of @pixbuf is done.
53//
54// #GdkPixbufLoader uses a function of this type to emit the
55// "<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
56// signal.
57type PixbufModulePreparedFunc func(uintptr, uintptr, uintptr)
58
59// Saves a `GdkPixbuf` by calling the provided function.
60//
61// The optional `option_keys` and `option_values` arrays contain the keys and
62// values (in the same order) for attributes to be saved alongside the image
63// data.
64type PixbufModuleSaveCallbackFunc func(uintptr, uintptr, uintptr, []string, []string, **glib.Error) bool
65
66// Saves a `GdkPixbuf` into a standard C file stream.
67//
68// The optional `param_keys` and `param_values` arrays contain the keys and
69// values (in the same order) for attributes to be saved alongside the image
70// data.
71type PixbufModuleSaveFunc func(uintptr, uintptr, []string, []string, **glib.Error) bool
72
73// Checks whether the given `option_key` is supported when saving.
74type PixbufModuleSaveOptionSupportedFunc func(string) bool
75
76// Defines the type of the function that gets called once the size
77// of the loaded image is known.
78//
79// The function is expected to set @width and @height to the desired
80// size to which the image should be scaled. If a module has no efficient
81// way to achieve the desired scaling during the loading of the image, it may
82// either ignore the size request, or only approximate it - gdk-pixbuf will
83// then perform the required scaling on the completely loaded image.
84//
85// If the function sets @width or @height to zero, the module should interpret
86// this as a hint that it will be closed soon and shouldn't allocate further
87// resources. This convention is used to implement gdk_pixbuf_get_file_info()
88// efficiently.
89type PixbufModuleSizeFunc func(int, int, uintptr)
90
91// Finalizes the image loading state.
92//
93// This function is called on success and error states.
94type PixbufModuleStopLoadFunc func(uintptr, **glib.Error) bool
95
96// Defines the type of the function that gets called every time a region
97// of @pixbuf is updated.
98//
99// #GdkPixbufLoader uses a function of this type to emit the
100// "<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
101// signal.
102type PixbufModuleUpdatedFunc func(uintptr, int, int, int, int, uintptr)
103
104// A `GdkPixbufFormat` contains information about the image format accepted
105// by a module.
106//
107// Only modules should access the fields directly, applications should
108// use the `gdk_pixbuf_format_*` family of functions.
109type PixbufFormat struct {
110 _ structs.HostLayout
111
112 Name uintptr
113
114 Signature *PixbufModulePattern
115
116 Domain uintptr
117
118 Description uintptr
119
120 MimeTypes []string
121
122 Extensions []string
123
124 Flags uint32
125
126 Disabled bool
127
128 License uintptr
129}
130
131var xPixbufFormatGLibType func() types.GType
132
133func PixbufFormatGLibType() types.GType {
134 return xPixbufFormatGLibType()
135}
136
137func (x *PixbufFormat) GoPointer() uintptr {
138 return uintptr(unsafe.Pointer(x))
139}
140
141var xPixbufFormatCopy func(uintptr) *PixbufFormat
142
143// Creates a copy of `format`.
144func (x *PixbufFormat) Copy() *PixbufFormat {
145
146 cret := xPixbufFormatCopy(x.GoPointer())
147 return cret
148}
149
150var xPixbufFormatFree func(uintptr)
151
152// Frees the resources allocated when copying a `GdkPixbufFormat`
153// using gdk_pixbuf_format_copy()
154func (x *PixbufFormat) Free() {
155
156 xPixbufFormatFree(x.GoPointer())
157
158}
159
160var xPixbufFormatGetDescription func(uintptr) string
161
162// Returns a description of the format.
163func (x *PixbufFormat) GetDescription() string {
164
165 cret := xPixbufFormatGetDescription(x.GoPointer())
166 return cret
167}
168
169var xPixbufFormatGetExtensions func(uintptr) []string
170
171// Returns the filename extensions typically used for files in the
172// given format.
173func (x *PixbufFormat) GetExtensions() []string {
174
175 cret := xPixbufFormatGetExtensions(x.GoPointer())
176 return cret
177}
178
179var xPixbufFormatGetLicense func(uintptr) string
180
181// Returns information about the license of the image loader for the format.
182//
183// The returned string should be a shorthand for a well known license, e.g.
184// "LGPL", "GPL", "QPL", "GPL/QPL", or "other" to indicate some other license.
185func (x *PixbufFormat) GetLicense() string {
186
187 cret := xPixbufFormatGetLicense(x.GoPointer())
188 return cret
189}
190
191var xPixbufFormatGetMimeTypes func(uintptr) []string
192
193// Returns the mime types supported by the format.
194func (x *PixbufFormat) GetMimeTypes() []string {
195
196 cret := xPixbufFormatGetMimeTypes(x.GoPointer())
197 return cret
198}
199
200var xPixbufFormatGetName func(uintptr) string
201
202// Returns the name of the format.
203func (x *PixbufFormat) GetName() string {
204
205 cret := xPixbufFormatGetName(x.GoPointer())
206 return cret
207}
208
209var xPixbufFormatIsDisabled func(uintptr) bool
210
211// Returns whether this image format is disabled.
212//
213// See gdk_pixbuf_format_set_disabled().
214func (x *PixbufFormat) IsDisabled() bool {
215
216 cret := xPixbufFormatIsDisabled(x.GoPointer())
217 return cret
218}
219
220var xPixbufFormatIsSaveOptionSupported func(uintptr, string) bool
221
222// Returns `TRUE` if the save option specified by @option_key is supported when
223// saving a pixbuf using the module implementing @format.
224//
225// See gdk_pixbuf_save() for more information about option keys.
226func (x *PixbufFormat) IsSaveOptionSupported(OptionKeyVar string) bool {
227
228 cret := xPixbufFormatIsSaveOptionSupported(x.GoPointer(), OptionKeyVar)
229 return cret
230}
231
232var xPixbufFormatIsScalable func(uintptr) bool
233
234// Returns whether this image format is scalable.
235//
236// If a file is in a scalable format, it is preferable to load it at
237// the desired size, rather than loading it at the default size and
238// scaling the resulting pixbuf to the desired size.
239func (x *PixbufFormat) IsScalable() bool {
240
241 cret := xPixbufFormatIsScalable(x.GoPointer())
242 return cret
243}
244
245var xPixbufFormatIsWritable func(uintptr) bool
246
247// Returns whether pixbufs can be saved in the given format.
248func (x *PixbufFormat) IsWritable() bool {
249
250 cret := xPixbufFormatIsWritable(x.GoPointer())
251 return cret
252}
253
254var xPixbufFormatSetDisabled func(uintptr, bool)
255
256// Disables or enables an image format.
257//
258// If a format is disabled, GdkPixbuf won't use the image loader for
259// this format to load images.
260//
261// Applications can use this to avoid using image loaders with an
262// inappropriate license, see gdk_pixbuf_format_get_license().
263func (x *PixbufFormat) SetDisabled(DisabledVar bool) {
264
265 xPixbufFormatSetDisabled(x.GoPointer(), DisabledVar)
266
267}
268
269// A `GdkPixbufModule` contains the necessary functions to load and save
270// images in a certain file format.
271//
272// If `GdkPixbuf` has been compiled with `GModule` support, it can be extended
273// by modules which can load (and perhaps also save) new image and animation
274// formats.
275//
276// ## Implementing modules
277//
278// The `GdkPixbuf` interfaces needed for implementing modules are contained in
279// `gdk-pixbuf-io.h` (and `gdk-pixbuf-animation.h` if the module supports
280// animations). They are not covered by the same stability guarantees as the
281// regular GdkPixbuf API. To underline this fact, they are protected by the
282// `GDK_PIXBUF_ENABLE_BACKEND` pre-processor symbol.
283//
284// Each loadable module must contain a `GdkPixbufModuleFillVtableFunc` function
285// named `fill_vtable`, which will get called when the module
286// is loaded and must set the function pointers of the `GdkPixbufModule`.
287//
288// In order to make format-checking work before actually loading the modules
289// (which may require calling `dlopen` to load image libraries), modules export
290// their signatures (and other information) via the `fill_info` function. An
291// external utility, `gdk-pixbuf-query-loaders`, uses this to create a text
292// file containing a list of all available loaders and their signatures.
293// This file is then read at runtime by `GdkPixbuf` to obtain the list of
294// available loaders and their signatures.
295//
296// Modules may only implement a subset of the functionality available via
297// `GdkPixbufModule`. If a particular functionality is not implemented, the
298// `fill_vtable` function will simply not set the corresponding
299// function pointers of the `GdkPixbufModule` structure. If a module supports
300// incremental loading (i.e. provides `begin_load`, `stop_load` and
301// `load_increment`), it doesn't have to implement `load`, since `GdkPixbuf`
302// can supply a generic `load` implementation wrapping the incremental loading.
303//
304// ## Installing modules
305//
306// Installing a module is a two-step process:
307//
308// - copy the module file(s) to the loader directory (normally
309// `$libdir/gdk-pixbuf-2.0/$version/loaders`, unless overridden by the
310// environment variable `GDK_PIXBUF_MODULEDIR`)
311// - call `gdk-pixbuf-query-loaders` to update the module file (normally
312// `$libdir/gdk-pixbuf-2.0/$version/loaders.cache`, unless overridden
313// by the environment variable `GDK_PIXBUF_MODULE_FILE`)
314type PixbufModule struct {
315 _ structs.HostLayout
316
317 ModuleName uintptr
318
319 ModulePath uintptr
320
321 Module *gmodule.Module
322
323 Info *PixbufFormat
324
325 Load PixbufModuleLoadFunc
326
327 LoadXpmData PixbufModuleLoadXpmDataFunc
328
329 BeginLoad PixbufModuleBeginLoadFunc
330
331 StopLoad PixbufModuleStopLoadFunc
332
333 LoadIncrement PixbufModuleIncrementLoadFunc
334
335 LoadAnimation PixbufModuleLoadAnimationFunc
336
337 Save PixbufModuleSaveFunc
338
339 SaveToCallback PixbufModuleSaveCallbackFunc
340
341 IsSaveOptionSupported PixbufModuleSaveOptionSupportedFunc
342
343 xReserved1 uintptr
344
345 xReserved2 uintptr
346
347 xReserved3 uintptr
348
349 xReserved4 uintptr
350}
351
352func (x *PixbufModule) GoPointer() uintptr {
353 return uintptr(unsafe.Pointer(x))
354}
355
356// OverrideReserved1 sets the "_reserved1" callback function.
357func (x *PixbufModule) OverrideReserved1(cb func()) {
358 if cb == nil {
359 x.xReserved1 = 0
360 } else {
361 x.xReserved1 = purego.NewCallback(func() {
362 cb()
363 })
364 }
365}
366
367// GetReserved1 gets the "_reserved1" callback function.
368func (x *PixbufModule) GetReserved1() func() {
369 if x.xReserved1 == 0 {
370 return nil
371 }
372 var rawCallback func()
373 purego.RegisterFunc(&rawCallback, x.xReserved1)
374 return func() {
375 rawCallback()
376 }
377}
378
379// OverrideReserved2 sets the "_reserved2" callback function.
380func (x *PixbufModule) OverrideReserved2(cb func()) {
381 if cb == nil {
382 x.xReserved2 = 0
383 } else {
384 x.xReserved2 = purego.NewCallback(func() {
385 cb()
386 })
387 }
388}
389
390// GetReserved2 gets the "_reserved2" callback function.
391func (x *PixbufModule) GetReserved2() func() {
392 if x.xReserved2 == 0 {
393 return nil
394 }
395 var rawCallback func()
396 purego.RegisterFunc(&rawCallback, x.xReserved2)
397 return func() {
398 rawCallback()
399 }
400}
401
402// OverrideReserved3 sets the "_reserved3" callback function.
403func (x *PixbufModule) OverrideReserved3(cb func()) {
404 if cb == nil {
405 x.xReserved3 = 0
406 } else {
407 x.xReserved3 = purego.NewCallback(func() {
408 cb()
409 })
410 }
411}
412
413// GetReserved3 gets the "_reserved3" callback function.
414func (x *PixbufModule) GetReserved3() func() {
415 if x.xReserved3 == 0 {
416 return nil
417 }
418 var rawCallback func()
419 purego.RegisterFunc(&rawCallback, x.xReserved3)
420 return func() {
421 rawCallback()
422 }
423}
424
425// OverrideReserved4 sets the "_reserved4" callback function.
426func (x *PixbufModule) OverrideReserved4(cb func()) {
427 if cb == nil {
428 x.xReserved4 = 0
429 } else {
430 x.xReserved4 = purego.NewCallback(func() {
431 cb()
432 })
433 }
434}
435
436// GetReserved4 gets the "_reserved4" callback function.
437func (x *PixbufModule) GetReserved4() func() {
438 if x.xReserved4 == 0 {
439 return nil
440 }
441 var rawCallback func()
442 purego.RegisterFunc(&rawCallback, x.xReserved4)
443 return func() {
444 rawCallback()
445 }
446}
447
448// The signature prefix for a module.
449//
450// The signature of a module is a set of prefixes. Prefixes are encoded as
451// pairs of ordinary strings, where the second string, called the mask, if
452// not `NULL`, must be of the same length as the first one and may contain
453// ' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
454// not matched, "don't-care"-bytes, zeros and non-zeros, respectively.
455//
456// Each prefix has an associated integer that describes the relevance of
457// the prefix, with 0 meaning a mismatch and 100 a "perfect match".
458//
459// Starting with gdk-pixbuf 2.8, the first byte of the mask may be '*',
460// indicating an unanchored pattern that matches not only at the beginning,
461// but also in the middle. Versions prior to 2.8 will interpret the '*'
462// like an 'x'.
463//
464// The signature of a module is stored as an array of
465// `GdkPixbufModulePatterns`. The array is terminated by a pattern
466// where the `prefix` is `NULL`.
467//
468// ```c
469//
470// GdkPixbufModulePattern *signature[] = {
471// { "abcdx", " !x z", 100 },
472// { "bla", NULL, 90 },
473// { NULL, NULL, 0 }
474// };
475//
476// ```
477//
478// In the example above, the signature matches e.g. "auud\0" with
479// relevance 100, and "blau" with relevance 90.
480type PixbufModulePattern struct {
481 _ structs.HostLayout
482
483 Prefix uintptr
484
485 Mask uintptr
486
487 Relevance int
488}
489
490func (x *PixbufModulePattern) GoPointer() uintptr {
491 return uintptr(unsafe.Pointer(x))
492}
493
494// Flags which allow a module to specify further details about the supported
495// operations.
496type PixbufFormatFlags int
497
498const (
499
500 // the module can write out images in the format.
501 GdkPixbufFormatWritableValue PixbufFormatFlags = 1
502 // the image format is scalable
503 GdkPixbufFormatScalableValue PixbufFormatFlags = 2
504 // the module is threadsafe. gdk-pixbuf
505 // ignores modules that are not marked as threadsafe. (Since 2.28).
506 GdkPixbufFormatThreadsafeValue PixbufFormatFlags = 4
507)
508
509func init() {
510 core.SetPackageName("GDKPIXBUF", "gdk-pixbuf-2.0")
511 core.SetSharedLibraries("GDKPIXBUF", []string{"libgdk_pixbuf-2.0.so.0"})
512 var libs []uintptr
513 for _, libPath := range core.GetPaths("GDKPIXBUF") {
514 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
515 if err != nil {
516 panic(err)
517 }
518 libs = append(libs, lib)
519 }
520
521 core.PuregoSafeRegister(&xPixbufFormatGLibType, libs, "gdk_pixbuf_format_get_type")
522
523 core.PuregoSafeRegister(&xPixbufFormatCopy, libs, "gdk_pixbuf_format_copy")
524 core.PuregoSafeRegister(&xPixbufFormatFree, libs, "gdk_pixbuf_format_free")
525 core.PuregoSafeRegister(&xPixbufFormatGetDescription, libs, "gdk_pixbuf_format_get_description")
526 core.PuregoSafeRegister(&xPixbufFormatGetExtensions, libs, "gdk_pixbuf_format_get_extensions")
527 core.PuregoSafeRegister(&xPixbufFormatGetLicense, libs, "gdk_pixbuf_format_get_license")
528 core.PuregoSafeRegister(&xPixbufFormatGetMimeTypes, libs, "gdk_pixbuf_format_get_mime_types")
529 core.PuregoSafeRegister(&xPixbufFormatGetName, libs, "gdk_pixbuf_format_get_name")
530 core.PuregoSafeRegister(&xPixbufFormatIsDisabled, libs, "gdk_pixbuf_format_is_disabled")
531 core.PuregoSafeRegister(&xPixbufFormatIsSaveOptionSupported, libs, "gdk_pixbuf_format_is_save_option_supported")
532 core.PuregoSafeRegister(&xPixbufFormatIsScalable, libs, "gdk_pixbuf_format_is_scalable")
533 core.PuregoSafeRegister(&xPixbufFormatIsWritable, libs, "gdk_pixbuf_format_is_writable")
534 core.PuregoSafeRegister(&xPixbufFormatSetDisabled, libs, "gdk_pixbuf_format_set_disabled")
535
536}