1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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)
13
14// `GStaticResource` is an opaque data structure and can only be accessed
15// using the following functions.
16type StaticResource struct {
17 _ structs.HostLayout
18
19 Data byte
20
21 DataLen uint
22
23 Resource *Resource
24
25 Next *StaticResource
26
27 Padding uintptr
28}
29
30func (x *StaticResource) GoPointer() uintptr {
31 return uintptr(unsafe.Pointer(x))
32}
33
34var xStaticResourceFini func(uintptr)
35
36// Finalizes a [struct@Gio.Resource] initialized by
37// [method@Gio.StaticResource.init].
38//
39// This is normally used by code generated by
40// [`glib-compile-resources`](glib-compile-resources.html)
41// and is not typically used by other code.
42func (x *StaticResource) Fini() {
43
44 xStaticResourceFini(x.GoPointer())
45
46}
47
48var xStaticResourceGetResource func(uintptr) *Resource
49
50// Gets the [struct@Gio.Resource] that was registered by a call to
51// [method@Gio.StaticResource.init].
52//
53// This is normally used by code generated by
54// [`glib-compile-resources`](glib-compile-resources.html)
55// and is not typically used by other code.
56func (x *StaticResource) GetResource() *Resource {
57
58 cret := xStaticResourceGetResource(x.GoPointer())
59 return cret
60}
61
62var xStaticResourceInit func(uintptr)
63
64// Initializes a [struct@Gio.Resource] from static data using a
65// [struct@Gio.StaticResource].
66//
67// This is normally used by code generated by
68// [`glib-compile-resources`](glib-compile-resources.html)
69// and is not typically used by other code.
70func (x *StaticResource) Init() {
71
72 xStaticResourceInit(x.GoPointer())
73
74}
75
76var xResourceErrorQuark func() glib.Quark
77
78// Gets the [struct@Gio.Resource] Error Quark.
79func ResourceErrorQuark() glib.Quark {
80
81 cret := xResourceErrorQuark()
82 return cret
83}
84
85var xResourceLoad func(string, **glib.Error) *Resource
86
87// Loads a binary resource bundle and creates a [struct@Gio.Resource]
88// representation of it, allowing you to query it for data.
89//
90// If you want to use this resource in the global resource namespace you need
91// to register it with [func@Gio.resources_register].
92//
93// If @filename is empty or the data in it is corrupt,
94// %G_RESOURCE_ERROR_INTERNAL will be returned. If @filename doesn’t exist, or
95// there is an error in reading it, an error from [ctor@GLib.MappedFile.new]
96// will be returned.
97func ResourceLoad(FilenameVar string) (*Resource, error) {
98 var cerr *glib.Error
99
100 cret := xResourceLoad(FilenameVar, &cerr)
101 if cerr == nil {
102 return cret, nil
103 }
104 return cret, cerr
105
106}
107
108var xResourcesEnumerateChildren func(string, ResourceLookupFlags, **glib.Error) []string
109
110// Returns all the names of children at the specified @path in the set of
111// globally registered resources.
112//
113// The return result is a `NULL` terminated list of strings which should
114// be released with [func@GLib.strfreev].
115//
116// @lookup_flags controls the behaviour of the lookup.
117func ResourcesEnumerateChildren(PathVar string, LookupFlagsVar ResourceLookupFlags) ([]string, error) {
118 var cerr *glib.Error
119
120 cret := xResourcesEnumerateChildren(PathVar, LookupFlagsVar, &cerr)
121 if cerr == nil {
122 return cret, nil
123 }
124 return cret, cerr
125
126}
127
128var xResourcesGetInfo func(string, ResourceLookupFlags, *uint, *uint32, **glib.Error) bool
129
130// Looks for a file at the specified @path in the set of
131// globally registered resources and if found returns information about it.
132//
133// @lookup_flags controls the behaviour of the lookup.
134func ResourcesGetInfo(PathVar string, LookupFlagsVar ResourceLookupFlags, SizeVar *uint, FlagsVar *uint32) (bool, error) {
135 var cerr *glib.Error
136
137 cret := xResourcesGetInfo(PathVar, LookupFlagsVar, SizeVar, FlagsVar, &cerr)
138 if cerr == nil {
139 return cret, nil
140 }
141 return cret, cerr
142
143}
144
145var xResourcesHasChildren func(string) bool
146
147// Returns whether the specified @path in the set of
148// globally registered resources has children.
149func ResourcesHasChildren(PathVar string) bool {
150
151 cret := xResourcesHasChildren(PathVar)
152 return cret
153}
154
155var xResourcesLookupData func(string, ResourceLookupFlags, **glib.Error) *glib.Bytes
156
157// Looks for a file at the specified @path in the set of
158// globally registered resources and returns a [struct@GLib.Bytes] that
159// lets you directly access the data in memory.
160//
161// The data is always followed by a zero byte, so you
162// can safely use the data as a C string. However, that byte
163// is not included in the size of the [struct@GLib.Bytes].
164//
165// For uncompressed resource files this is a pointer directly into
166// the resource bundle, which is typically in some read-only data section
167// in the program binary. For compressed files we allocate memory on
168// the heap and automatically uncompress the data.
169//
170// @lookup_flags controls the behaviour of the lookup.
171func ResourcesLookupData(PathVar string, LookupFlagsVar ResourceLookupFlags) (*glib.Bytes, error) {
172 var cerr *glib.Error
173
174 cret := xResourcesLookupData(PathVar, LookupFlagsVar, &cerr)
175 if cerr == nil {
176 return cret, nil
177 }
178 return cret, cerr
179
180}
181
182var xResourcesOpenStream func(string, ResourceLookupFlags, **glib.Error) uintptr
183
184// Looks for a file at the specified @path in the set of
185// globally registered resources and returns a [class@Gio.InputStream]
186// that lets you read the data.
187//
188// @lookup_flags controls the behaviour of the lookup.
189func ResourcesOpenStream(PathVar string, LookupFlagsVar ResourceLookupFlags) (*InputStream, error) {
190 var cls *InputStream
191 var cerr *glib.Error
192
193 cret := xResourcesOpenStream(PathVar, LookupFlagsVar, &cerr)
194
195 if cret == 0 {
196 return nil, cerr
197 }
198 cls = &InputStream{}
199 cls.Ptr = cret
200 if cerr == nil {
201 return cls, nil
202 }
203 return cls, cerr
204
205}
206
207var xResourcesRegister func(*Resource)
208
209// Registers the resource with the process-global set of resources.
210//
211// Once a resource is registered the files in it can be accessed
212// with the global resource lookup functions like
213// [func@Gio.resources_lookup_data].
214func ResourcesRegister(ResourceVar *Resource) {
215
216 xResourcesRegister(ResourceVar)
217
218}
219
220var xResourcesUnregister func(*Resource)
221
222// Unregisters the resource from the process-global set of resources.
223func ResourcesUnregister(ResourceVar *Resource) {
224
225 xResourcesUnregister(ResourceVar)
226
227}
228
229func init() {
230 core.SetPackageName("GIO", "gio-2.0")
231 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
232 var libs []uintptr
233 for _, libPath := range core.GetPaths("GIO") {
234 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
235 if err != nil {
236 panic(err)
237 }
238 libs = append(libs, lib)
239 }
240
241 core.PuregoSafeRegister(&xResourceErrorQuark, libs, "g_resource_error_quark")
242 core.PuregoSafeRegister(&xResourceLoad, libs, "g_resource_load")
243 core.PuregoSafeRegister(&xResourcesEnumerateChildren, libs, "g_resources_enumerate_children")
244 core.PuregoSafeRegister(&xResourcesGetInfo, libs, "g_resources_get_info")
245 core.PuregoSafeRegister(&xResourcesHasChildren, libs, "g_resources_has_children")
246 core.PuregoSafeRegister(&xResourcesLookupData, libs, "g_resources_lookup_data")
247 core.PuregoSafeRegister(&xResourcesOpenStream, libs, "g_resources_open_stream")
248 core.PuregoSafeRegister(&xResourcesRegister, libs, "g_resources_register")
249 core.PuregoSafeRegister(&xResourcesUnregister, libs, "g_resources_unregister")
250
251 core.PuregoSafeRegister(&xStaticResourceFini, libs, "g_static_resource_fini")
252 core.PuregoSafeRegister(&xStaticResourceGetResource, libs, "g_static_resource_get_resource")
253 core.PuregoSafeRegister(&xStaticResourceInit, libs, "g_static_resource_init")
254
255}