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 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// Type definition for a function that will be called back when an asynchronous
17// operation within GIO has been completed. #GAsyncReadyCallback
18// callbacks from #GTask are guaranteed to be invoked in a later
19// iteration of the thread-default main context
20// (see [method@GLib.MainContext.push_thread_default])
21// where the #GTask was created. All other users of
22// #GAsyncReadyCallback must likewise call it asynchronously in a
23// later iteration of the main context.
24//
25// The asynchronous operation is guaranteed to have held a reference to
26// @source_object from the time when the `*_async()` function was called, until
27// after this callback returns.
28type AsyncReadyCallback func(uintptr, uintptr, uintptr)
29
30// This is the function type of the callback used for the #GSource
31// returned by g_cancellable_source_new().
32type CancellableSourceFunc func(uintptr, uintptr) bool
33
34// Function signature for a function used to determine the #GType to
35// use for an interface proxy (if @interface_name is not %NULL) or
36// object proxy (if @interface_name is %NULL).
37//
38// This function is called in the thread-default main context
39// (see [method@GLib.MainContext.push_thread_default])
40// that @manager was constructed in.
41type DBusProxyTypeFunc func(uintptr, string, string, uintptr) types.GType
42
43// This is the function type of the callback used for the #GSource
44// returned by g_datagram_based_create_source().
45type DatagramBasedSourceFunc func(uintptr, glib.IOCondition, uintptr) bool
46
47// This callback type is used by g_file_measure_disk_usage() to make
48// periodic progress reports when measuring the amount of disk spaced
49// used by a directory.
50//
51// These calls are made on a best-effort basis and not all types of
52// #GFile will support them. At the minimum, however, one call will
53// always be made immediately.
54//
55// In the case that there is no support, @reporting will be set to
56// %FALSE (and the other values undefined) and no further calls will be
57// made. Otherwise, the @reporting will be %TRUE and the other values
58// all-zeros during the first (immediate) call. In this way, you can
59// know which type of progress UI to show without a delay.
60//
61// For g_file_measure_disk_usage() the callback is made directly. For
62// g_file_measure_disk_usage_async() the callback is made via the
63// default main context of the calling thread (ie: the same way that the
64// final async result would be reported).
65//
66// @current_size is in the same units as requested by the operation (see
67// %G_FILE_MEASURE_APPARENT_SIZE).
68//
69// The frequency of the updates is implementation defined, but is
70// ideally about once every 200ms.
71//
72// The last progress callback may or may not be equal to the final
73// result. Always check the async result to get the final value.
74type FileMeasureProgressCallback func(bool, uint64, uint64, uint64, uintptr)
75
76// When doing file operations that may take a while, such as moving
77// a file or copying a file, a progress callback is used to pass how
78// far along that operation is to the application.
79type FileProgressCallback func(int64, int64, uintptr)
80
81// When loading the partial contents of a file with g_file_load_partial_contents_async(),
82// it may become necessary to determine if any more data from the file should be loaded.
83// A #GFileReadMoreCallback function facilitates this by returning %TRUE if more data
84// should be read, or %FALSE otherwise.
85type FileReadMoreCallback func(string, int64, uintptr) bool
86
87// I/O Job function.
88//
89// Long-running jobs should periodically check the @cancellable
90// to see if they have been cancelled.
91type IOSchedulerJobFunc func(*IOSchedulerJob, uintptr, uintptr) bool
92
93// This is the function type of the callback used for the #GSource
94// returned by g_pollable_input_stream_create_source() and
95// g_pollable_output_stream_create_source().
96type PollableSourceFunc func(uintptr, uintptr) bool
97
98// Simple thread function that runs an asynchronous operation and
99// checks for cancellation.
100type SimpleAsyncThreadFunc func(uintptr, uintptr, uintptr)
101
102// This is the function type of the callback used for the #GSource
103// returned by g_socket_create_source().
104type SocketSourceFunc func(uintptr, glib.IOCondition, uintptr) bool
105
106// Determines if a string matches a file attribute.
107type FileAttributeMatcher struct {
108 _ structs.HostLayout
109}
110
111var xFileAttributeMatcherGLibType func() types.GType
112
113func FileAttributeMatcherGLibType() types.GType {
114 return xFileAttributeMatcherGLibType()
115}
116
117func (x *FileAttributeMatcher) GoPointer() uintptr {
118 return uintptr(unsafe.Pointer(x))
119}
120
121var xNewFileAttributeMatcher func(string) *FileAttributeMatcher
122
123// Creates a new file attribute matcher, which matches attributes
124// against a given string. #GFileAttributeMatchers are reference
125// counted structures, and are created with a reference count of 1. If
126// the number of references falls to 0, the #GFileAttributeMatcher is
127// automatically destroyed.
128//
129// The @attributes string should be formatted with specific keys separated
130// from namespaces with a double colon. Several "namespace::key" strings may be
131// concatenated with a single comma (e.g. "standard::type,standard::is-hidden").
132// The wildcard "*" may be used to match all keys and namespaces, or
133// "namespace::*" will match all keys in a given namespace.
134//
135// ## Examples of file attribute matcher strings and results
136//
137// - `"*"`: matches all attributes.
138// - `"standard::is-hidden"`: matches only the key is-hidden in the
139// standard namespace.
140// - `"standard::type,unix::*"`: matches the type key in the standard
141// namespace and all keys in the unix namespace.
142func NewFileAttributeMatcher(AttributesVar string) *FileAttributeMatcher {
143
144 cret := xNewFileAttributeMatcher(AttributesVar)
145 return cret
146}
147
148var xFileAttributeMatcherEnumerateNamespace func(uintptr, string) bool
149
150// Checks if the matcher will match all of the keys in a given namespace.
151// This will always return %TRUE if a wildcard character is in use (e.g. if
152// matcher was created with "standard::*" and @ns is "standard", or if matcher was created
153// using "*" and namespace is anything.)
154//
155// TODO: this is awkwardly worded.
156func (x *FileAttributeMatcher) EnumerateNamespace(NsVar string) bool {
157
158 cret := xFileAttributeMatcherEnumerateNamespace(x.GoPointer(), NsVar)
159 return cret
160}
161
162var xFileAttributeMatcherEnumerateNext func(uintptr) string
163
164// Gets the next matched attribute from a #GFileAttributeMatcher.
165func (x *FileAttributeMatcher) EnumerateNext() string {
166
167 cret := xFileAttributeMatcherEnumerateNext(x.GoPointer())
168 return cret
169}
170
171var xFileAttributeMatcherMatches func(uintptr, string) bool
172
173// Checks if an attribute will be matched by an attribute matcher. If
174// the matcher was created with the "*" matching string, this function
175// will always return %TRUE.
176func (x *FileAttributeMatcher) Matches(AttributeVar string) bool {
177
178 cret := xFileAttributeMatcherMatches(x.GoPointer(), AttributeVar)
179 return cret
180}
181
182var xFileAttributeMatcherMatchesOnly func(uintptr, string) bool
183
184// Checks if an attribute matcher only matches a given attribute. Always
185// returns %FALSE if "*" was used when creating the matcher.
186func (x *FileAttributeMatcher) MatchesOnly(AttributeVar string) bool {
187
188 cret := xFileAttributeMatcherMatchesOnly(x.GoPointer(), AttributeVar)
189 return cret
190}
191
192var xFileAttributeMatcherRef func(uintptr) *FileAttributeMatcher
193
194// References a file attribute matcher.
195func (x *FileAttributeMatcher) Ref() *FileAttributeMatcher {
196
197 cret := xFileAttributeMatcherRef(x.GoPointer())
198 return cret
199}
200
201var xFileAttributeMatcherSubtract func(uintptr, *FileAttributeMatcher) *FileAttributeMatcher
202
203// Subtracts all attributes of @subtract from @matcher and returns
204// a matcher that supports those attributes.
205//
206// Note that currently it is not possible to remove a single
207// attribute when the @matcher matches the whole namespace - or remove
208// a namespace or attribute when the matcher matches everything. This
209// is a limitation of the current implementation, but may be fixed
210// in the future.
211func (x *FileAttributeMatcher) Subtract(SubtractVar *FileAttributeMatcher) *FileAttributeMatcher {
212
213 cret := xFileAttributeMatcherSubtract(x.GoPointer(), SubtractVar)
214 return cret
215}
216
217var xFileAttributeMatcherToString func(uintptr) string
218
219// Prints what the matcher is matching against. The format will be
220// equal to the format passed to g_file_attribute_matcher_new().
221// The output however, might not be identical, as the matcher may
222// decide to use a different order or omit needless parts.
223func (x *FileAttributeMatcher) ToString() string {
224
225 cret := xFileAttributeMatcherToString(x.GoPointer())
226 return cret
227}
228
229var xFileAttributeMatcherUnref func(uintptr)
230
231// Unreferences @matcher. If the reference count falls below 1,
232// the @matcher is automatically freed.
233func (x *FileAttributeMatcher) Unref() {
234
235 xFileAttributeMatcherUnref(x.GoPointer())
236
237}
238
239// #GIOExtension is an opaque data structure and can only be accessed
240// using the following functions.
241type IOExtension struct {
242 _ structs.HostLayout
243}
244
245func (x *IOExtension) GoPointer() uintptr {
246 return uintptr(unsafe.Pointer(x))
247}
248
249var xIOExtensionGetName func(uintptr) string
250
251// Gets the name under which @extension was registered.
252//
253// Note that the same type may be registered as extension
254// for multiple extension points, under different names.
255func (x *IOExtension) GetName() string {
256
257 cret := xIOExtensionGetName(x.GoPointer())
258 return cret
259}
260
261var xIOExtensionGetPriority func(uintptr) int
262
263// Gets the priority with which @extension was registered.
264func (x *IOExtension) GetPriority() int {
265
266 cret := xIOExtensionGetPriority(x.GoPointer())
267 return cret
268}
269
270var xIOExtensionGetType func(uintptr) types.GType
271
272// Gets the type associated with @extension.
273func (x *IOExtension) GetType() types.GType {
274
275 cret := xIOExtensionGetType(x.GoPointer())
276 return cret
277}
278
279var xIOExtensionRefClass func(uintptr) *gobject.TypeClass
280
281// Gets a reference to the class for the type that is
282// associated with @extension.
283func (x *IOExtension) RefClass() *gobject.TypeClass {
284
285 cret := xIOExtensionRefClass(x.GoPointer())
286 return cret
287}
288
289// `GIOExtensionPoint` provides a mechanism for modules to extend the
290// functionality of the library or application that loaded it in an
291// organized fashion.
292//
293// An extension point is identified by a name, and it may optionally
294// require that any implementation must be of a certain type (or derived
295// thereof). Use [func@Gio.IOExtensionPoint.register] to register an
296// extension point, and [method@Gio.IOExtensionPoint.set_required_type] to
297// set a required type.
298//
299// A module can implement an extension point by specifying the
300// [type@GObject.Type] that implements the functionality. Additionally, each
301// implementation of an extension point has a name, and a priority. Use
302// [func@Gio.IOExtensionPoint.implement] to implement an extension point.
303//
304// ```c
305// GIOExtensionPoint *ep;
306//
307// // Register an extension point
308// ep = g_io_extension_point_register ("my-extension-point");
309// g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
310// ```
311//
312// ```c
313// // Implement an extension point
314// G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE)
315// g_io_extension_point_implement ("my-extension-point",
316//
317// my_example_impl_get_type (),
318// "my-example",
319// 10);
320//
321// ```
322//
323// It is up to the code that registered the extension point how
324// it uses the implementations that have been associated with it.
325// Depending on the use case, it may use all implementations, or
326// only the one with the highest priority, or pick a specific
327// one by name.
328//
329// To avoid opening all modules just to find out what extension
330// points they implement, GIO makes use of a caching mechanism,
331// see [gio-querymodules](gio-querymodules.html).
332// You are expected to run this command after installing a
333// GIO module.
334//
335// The `GIO_EXTRA_MODULES` environment variable can be used to
336// specify additional directories to automatically load modules
337// from. This environment variable has the same syntax as the
338// `PATH`. If two modules have the same base name in different
339// directories, then the latter one will be ignored. If additional
340// directories are specified GIO will load modules from the built-in
341// directory last.
342type IOExtensionPoint struct {
343 _ structs.HostLayout
344}
345
346func (x *IOExtensionPoint) GoPointer() uintptr {
347 return uintptr(unsafe.Pointer(x))
348}
349
350var xIOExtensionPointGetExtensionByName func(uintptr, string) *IOExtension
351
352// Finds a #GIOExtension for an extension point by name.
353func (x *IOExtensionPoint) GetExtensionByName(NameVar string) *IOExtension {
354
355 cret := xIOExtensionPointGetExtensionByName(x.GoPointer(), NameVar)
356 return cret
357}
358
359var xIOExtensionPointGetExtensions func(uintptr) *glib.List
360
361// Gets a list of all extensions that implement this extension point.
362// The list is sorted by priority, beginning with the highest priority.
363func (x *IOExtensionPoint) GetExtensions() *glib.List {
364
365 cret := xIOExtensionPointGetExtensions(x.GoPointer())
366 return cret
367}
368
369var xIOExtensionPointGetRequiredType func(uintptr) types.GType
370
371// Gets the required type for @extension_point.
372func (x *IOExtensionPoint) GetRequiredType() types.GType {
373
374 cret := xIOExtensionPointGetRequiredType(x.GoPointer())
375 return cret
376}
377
378var xIOExtensionPointSetRequiredType func(uintptr, types.GType)
379
380// Sets the required type for @extension_point to @type.
381// All implementations must henceforth have this type.
382func (x *IOExtensionPoint) SetRequiredType(TypeVar types.GType) {
383
384 xIOExtensionPointSetRequiredType(x.GoPointer(), TypeVar)
385
386}
387
388// Opaque class for defining and scheduling IO jobs.
389type IOSchedulerJob struct {
390 _ structs.HostLayout
391}
392
393func (x *IOSchedulerJob) GoPointer() uintptr {
394 return uintptr(unsafe.Pointer(x))
395}
396
397var xIOSchedulerJobSendToMainloop func(uintptr, uintptr, uintptr, uintptr) bool
398
399// Used from an I/O job to send a callback to be run in the thread
400// that the job was started from, waiting for the result (and thus
401// blocking the I/O job).
402func (x *IOSchedulerJob) SendToMainloop(FuncVar *glib.SourceFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) bool {
403
404 var FuncVarRef uintptr
405 if FuncVar != nil {
406 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
407 if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
408 FuncVarRef = cbRefPtr
409 } else {
410 fcb := func(arg0 uintptr) bool {
411 cbFn := *FuncVar
412 return cbFn(arg0)
413 }
414 FuncVarRef = purego.NewCallback(fcb)
415 glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
416 }
417 }
418
419 var NotifyVarRef uintptr
420 if NotifyVar != nil {
421 NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar))
422 if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok {
423 NotifyVarRef = cbRefPtr
424 } else {
425 fcb := func(arg0 uintptr) {
426 cbFn := *NotifyVar
427 cbFn(arg0)
428 }
429 NotifyVarRef = purego.NewCallback(fcb)
430 glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar)
431 }
432 }
433
434 cret := xIOSchedulerJobSendToMainloop(x.GoPointer(), FuncVarRef, UserDataVar, NotifyVarRef)
435 return cret
436}
437
438var xIOSchedulerJobSendToMainloopAsync func(uintptr, uintptr, uintptr, uintptr)
439
440// Used from an I/O job to send a callback to be run asynchronously in
441// the thread that the job was started from. The callback will be run
442// when the main loop is available, but at that time the I/O job might
443// have finished. The return value from the callback is ignored.
444//
445// Note that if you are passing the @user_data from g_io_scheduler_push_job()
446// on to this function you have to ensure that it is not freed before
447// @func is called, either by passing %NULL as @notify to
448// g_io_scheduler_push_job() or by using refcounting for @user_data.
449func (x *IOSchedulerJob) SendToMainloopAsync(FuncVar *glib.SourceFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) {
450
451 var FuncVarRef uintptr
452 if FuncVar != nil {
453 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
454 if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
455 FuncVarRef = cbRefPtr
456 } else {
457 fcb := func(arg0 uintptr) bool {
458 cbFn := *FuncVar
459 return cbFn(arg0)
460 }
461 FuncVarRef = purego.NewCallback(fcb)
462 glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
463 }
464 }
465
466 var NotifyVarRef uintptr
467 if NotifyVar != nil {
468 NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar))
469 if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok {
470 NotifyVarRef = cbRefPtr
471 } else {
472 fcb := func(arg0 uintptr) {
473 cbFn := *NotifyVar
474 cbFn(arg0)
475 }
476 NotifyVarRef = purego.NewCallback(fcb)
477 glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar)
478 }
479 }
480
481 xIOSchedulerJobSendToMainloopAsync(x.GoPointer(), FuncVarRef, UserDataVar, NotifyVarRef)
482
483}
484
485type IOStreamAdapter struct {
486 _ structs.HostLayout
487}
488
489func (x *IOStreamAdapter) GoPointer() uintptr {
490 return uintptr(unsafe.Pointer(x))
491}
492
493// Structure used for scatter/gather data input when receiving multiple
494// messages or packets in one go. You generally pass in an array of empty
495// #GInputVectors and the operation will use all the buffers as if they
496// were one buffer, and will set @bytes_received to the total number of bytes
497// received across all #GInputVectors.
498//
499// This structure closely mirrors `struct mmsghdr` and `struct msghdr` from
500// the POSIX sockets API (see `man 2 recvmmsg`).
501//
502// If @address is non-%NULL then it is set to the source address the message
503// was received from, and the caller must free it afterwards.
504//
505// If @control_messages is non-%NULL then it is set to an array of control
506// messages received with the message (if any), and the caller must free it
507// afterwards. @num_control_messages is set to the number of elements in
508// this array, which may be zero.
509//
510// Flags relevant to this message will be returned in @flags. For example,
511// `MSG_EOR` or `MSG_TRUNC`.
512type InputMessage struct {
513 _ structs.HostLayout
514
515 Address **SocketAddress
516
517 Vectors []InputVector
518
519 NumVectors uint
520
521 BytesReceived uint
522
523 Flags int32
524
525 ControlMessages uintptr
526
527 NumControlMessages uint
528}
529
530func (x *InputMessage) GoPointer() uintptr {
531 return uintptr(unsafe.Pointer(x))
532}
533
534// Structure used for scatter/gather data input.
535// You generally pass in an array of #GInputVectors
536// and the operation will store the read data starting in the
537// first buffer, switching to the next as needed.
538type InputVector struct {
539 _ structs.HostLayout
540
541 Buffer uintptr
542
543 Size uint
544}
545
546func (x *InputVector) GoPointer() uintptr {
547 return uintptr(unsafe.Pointer(x))
548}
549
550// Structure used for scatter/gather data output when sending multiple
551// messages or packets in one go. You generally pass in an array of
552// #GOutputVectors and the operation will use all the buffers as if they
553// were one buffer.
554//
555// If @address is %NULL then the message is sent to the default receiver
556// (as previously set by g_socket_connect()).
557type OutputMessage struct {
558 _ structs.HostLayout
559
560 Address *SocketAddress
561
562 Vectors *OutputVector
563
564 NumVectors uint
565
566 BytesSent uint
567
568 ControlMessages uintptr
569
570 NumControlMessages uint
571}
572
573func (x *OutputMessage) GoPointer() uintptr {
574 return uintptr(unsafe.Pointer(x))
575}
576
577// Structure used for scatter/gather data output.
578// You generally pass in an array of #GOutputVectors
579// and the operation will use all the buffers as if they were
580// one buffer.
581type OutputVector struct {
582 _ structs.HostLayout
583
584 Buffer uintptr
585
586 Size uint
587}
588
589func (x *OutputVector) GoPointer() uintptr {
590 return uintptr(unsafe.Pointer(x))
591}
592
593// Applications and libraries often contain binary or textual data that is
594// really part of the application, rather than user data. For instance
595// [`GtkBuilder`](https://docs.gtk.org/gtk4/class.Builder.html) `.ui` files,
596// splashscreen images, [class@Gio.Menu] markup XML, CSS files, icons, etc.
597// These are often shipped as files in `$datadir/appname`, or manually
598// included as literal strings in the code.
599//
600// The `GResource` API and the
601// [`glib-compile-resources`](glib-compile-resources.html) program provide a
602// convenient and efficient alternative to this which has some nice properties.
603// You maintain the files as normal files, so it’s easy to edit them, but during
604// the build the files are combined into a binary bundle that is linked into the
605// executable. This means that loading the resource files are efficient (as they
606// are already in memory, shared with other instances) and simple (no need to
607// check for things like I/O errors or locate the files in the filesystem). It
608// also makes it easier to create relocatable applications.
609//
610// Resource files can also be marked as compressed. Such files will be included
611// in the resource bundle in a compressed form, but will be automatically
612// uncompressed when the resource is used. This is very useful e.g. for larger
613// text files that are parsed once (or rarely) and then thrown away.
614//
615// Resource files can also be marked to be preprocessed, by setting the value of the
616// `preprocess` attribute to a comma-separated list of preprocessing options.
617// The only options currently supported are:
618//
619// - `xml-stripblanks` which will use the [`xmllint`](man:xmllint(1)) command
620// to strip ignorable whitespace from the XML file. For this to work,
621// the `XMLLINT` environment variable must be set to the full path to
622// the xmllint executable, or xmllint must be in the `PATH`; otherwise
623// the preprocessing step is skipped.
624//
625// - `to-pixdata` (deprecated since gdk-pixbuf 2.32) which will use the
626// `gdk-pixbuf-pixdata` command to convert images to the [`GdkPixdata`](https://docs.gtk.org/gdk-pixbuf/class.Pixdata.html)
627// format, which allows you to create pixbufs directly using the data inside
628// the resource file, rather than an (uncompressed) copy of it. For this, the
629// `gdk-pixbuf-pixdata` program must be in the `PATH`, or the
630// `GDK_PIXBUF_PIXDATA` environment variable must be set to the full path to
631// the `gdk-pixbuf-pixdata` executable; otherwise the resource compiler will
632// abort. `to-pixdata` has been deprecated since gdk-pixbuf 2.32, as
633// `GResource` supports embedding modern image formats just as well. Instead
634// of using it, embed a PNG or SVG file in your `GResource`.
635//
636// - `json-stripblanks` which will use the
637// [`json-glib-format`](man:json-glib-format(1)) command to strip ignorable
638// whitespace from the JSON file. For this to work, the `JSON_GLIB_FORMAT`
639// environment variable must be set to the full path to the
640// `json-glib-format` executable, or it must be in the `PATH`; otherwise the
641// preprocessing step is skipped. In addition, at least version 1.6 of
642// `json-glib-format` is required.
643//
644// Resource files will be exported in the `GResource` namespace using the
645// combination of the given `prefix` and the filename from the `file` element.
646// The `alias` attribute can be used to alter the filename to expose them at a
647// different location in the resource namespace. Typically, this is used to
648// include files from a different source directory without exposing the source
649// directory in the resource namespace, as in the example below.
650//
651// Resource bundles are created by the
652// [`glib-compile-resources`](glib-compile-resources.html) program
653// which takes an XML file that describes the bundle, and a set of files that
654// the XML references. These are combined into a binary resource bundle.
655//
656// An example resource description:
657// ```xml
658// <?xml version="1.0" encoding="UTF-8"?>
659// <gresources>
660//
661// <gresource prefix="/org/gtk/Example">
662// <file>data/splashscreen.png</file>
663// <file compressed="true">dialog.ui</file>
664// <file preprocess="xml-stripblanks">menumarkup.xml</file>
665// <file alias="example.css">data/example.css</file>
666// </gresource>
667//
668// </gresources>
669// ```
670//
671// This will create a resource bundle with the following files:
672// ```
673// /org/gtk/Example/data/splashscreen.png
674// /org/gtk/Example/dialog.ui
675// /org/gtk/Example/menumarkup.xml
676// /org/gtk/Example/example.css
677// ```
678//
679// Note that all resources in the process share the same namespace, so use
680// Java-style path prefixes (like in the above example) to avoid conflicts.
681//
682// You can then use [`glib-compile-resources`](glib-compile-resources.html) to
683// compile the XML to a binary bundle that you can load with
684// [func@Gio.Resource.load]. However, it’s more common to use the
685// `--generate-source` and `--generate-header` arguments to create a source file
686// and header to link directly into your application.
687// This will generate `get_resource()`, `register_resource()` and
688// `unregister_resource()` functions, prefixed by the `--c-name` argument passed
689// to [`glib-compile-resources`](glib-compile-resources.html). `get_resource()`
690// returns the generated `GResource` object. The register and unregister
691// functions register the resource so its files can be accessed using
692// [func@Gio.resources_lookup_data].
693//
694// Once a `GResource` has been created and registered all the data in it can be
695// accessed globally in the process by using API calls like
696// [func@Gio.resources_open_stream] to stream the data or
697// [func@Gio.resources_lookup_data] to get a direct pointer to the data. You can
698// also use URIs like `resource:///org/gtk/Example/data/splashscreen.png` with
699// [iface@Gio.File] to access the resource data.
700//
701// Some higher-level APIs, such as [`GtkApplication`](https://docs.gtk.org/gtk4/class.Application.html),
702// will automatically load resources from certain well-known paths in the
703// resource namespace as a convenience. See the documentation for those APIs
704// for details.
705//
706// There are two forms of the generated source, the default version uses the
707// compiler support for constructor and destructor functions (where available)
708// to automatically create and register the `GResource` on startup or library
709// load time. If you pass `--manual-register`, two functions to
710// register/unregister the resource are created instead. This requires an
711// explicit initialization call in your application/library, but it works on all
712// platforms, even on the minor ones where constructors are not supported.
713// (Constructor support is available for at least Win32, Mac OS and Linux.)
714//
715// Note that resource data can point directly into the data segment of e.g. a
716// library, so if you are unloading libraries during runtime you need to be very
717// careful with keeping around pointers to data from a resource, as this goes
718// away when the library is unloaded. However, in practice this is not generally
719// a problem, since most resource accesses are for your own resources, and
720// resource data is often used once, during parsing, and then released.
721//
722// # Overlays
723//
724// When debugging a program or testing a change to an installed version, it is
725// often useful to be able to replace resources in the program or library,
726// without recompiling, for debugging or quick hacking and testing purposes.
727// Since GLib 2.50, it is possible to use the `G_RESOURCE_OVERLAYS` environment
728// variable to selectively overlay resources with replacements from the
729// filesystem. It is a `G_SEARCHPATH_SEPARATOR`-separated list of substitutions
730// to perform during resource lookups. It is ignored when running in a setuid
731// process.
732//
733// # A substitution has the form
734//
735// ```
736// /org/gtk/libgtk=/home/desrt/gtk-overlay
737// ```
738//
739// The part before the `=` is the resource subpath for which the overlay
740// applies. The part after is a filesystem path which contains files and
741// subdirectories as you would like to be loaded as resources with the
742// equivalent names.
743//
744// In the example above, if an application tried to load a resource with the
745// resource path `/org/gtk/libgtk/ui/gtkdialog.ui` then `GResource` would check
746// the filesystem path `/home/desrt/gtk-overlay/ui/gtkdialog.ui`. If a file was
747// found there, it would be used instead. This is an overlay, not an outright
748// replacement, which means that if a file is not found at that path, the
749// built-in version will be used instead. Whiteouts are not currently
750// supported.
751//
752// Substitutions must start with a slash, and must not contain a trailing slash
753// before the `=`. The path after the slash should ideally be absolute, but
754// this is not strictly required. It is possible to overlay the location of a
755// single resource with an individual file.
756type Resource struct {
757 _ structs.HostLayout
758}
759
760var xResourceGLibType func() types.GType
761
762func ResourceGLibType() types.GType {
763 return xResourceGLibType()
764}
765
766func (x *Resource) GoPointer() uintptr {
767 return uintptr(unsafe.Pointer(x))
768}
769
770var xNewResourceFromData func(*glib.Bytes, **glib.Error) *Resource
771
772// Creates a [struct@Gio.Resource] from a reference to the binary resource bundle.
773//
774// This will keep a reference to @data while the resource lives, so
775// the data should not be modified or freed.
776//
777// If you want to use this resource in the global resource namespace you need
778// to register it with [func@Gio.resources_register].
779//
780// Note: @data must be backed by memory that is at least pointer aligned.
781// Otherwise this function will internally create a copy of the memory since
782// GLib 2.56, or in older versions fail and exit the process.
783//
784// If @data is empty or corrupt, %G_RESOURCE_ERROR_INTERNAL will be returned.
785func NewResourceFromData(DataVar *glib.Bytes) (*Resource, error) {
786 var cerr *glib.Error
787
788 cret := xNewResourceFromData(DataVar, &cerr)
789 if cerr == nil {
790 return cret, nil
791 }
792 return cret, cerr
793
794}
795
796var xResourceRegister func(uintptr)
797
798// Registers the resource with the process-global set of resources.
799//
800// Once a resource is registered the files in it can be accessed
801// with the global resource lookup functions like
802// [func@Gio.resources_lookup_data].
803func (x *Resource) Register() {
804
805 xResourceRegister(x.GoPointer())
806
807}
808
809var xResourceUnregister func(uintptr)
810
811// Unregisters the resource from the process-global set of resources.
812func (x *Resource) Unregister() {
813
814 xResourceUnregister(x.GoPointer())
815
816}
817
818var xResourceEnumerateChildren func(uintptr, string, ResourceLookupFlags, **glib.Error) []string
819
820// Returns all the names of children at the specified @path in the resource.
821//
822// The return result is a `NULL` terminated list of strings which should
823// be released with [func@GLib.strfreev].
824//
825// If @path is invalid or does not exist in the [struct@Gio.Resource],
826// %G_RESOURCE_ERROR_NOT_FOUND will be returned.
827//
828// @lookup_flags controls the behaviour of the lookup.
829func (x *Resource) EnumerateChildren(PathVar string, LookupFlagsVar ResourceLookupFlags) ([]string, error) {
830 var cerr *glib.Error
831
832 cret := xResourceEnumerateChildren(x.GoPointer(), PathVar, LookupFlagsVar, &cerr)
833 if cerr == nil {
834 return cret, nil
835 }
836 return cret, cerr
837
838}
839
840var xResourceGetInfo func(uintptr, string, ResourceLookupFlags, *uint, *uint32, **glib.Error) bool
841
842// Looks for a file at the specified @path in the resource and
843// if found returns information about it.
844//
845// @lookup_flags controls the behaviour of the lookup.
846//
847// The only error this can return is %G_RESOURCE_ERROR_NOT_FOUND, if @path was
848// not found in @resource.
849func (x *Resource) GetInfo(PathVar string, LookupFlagsVar ResourceLookupFlags, SizeVar *uint, FlagsVar *uint32) (bool, error) {
850 var cerr *glib.Error
851
852 cret := xResourceGetInfo(x.GoPointer(), PathVar, LookupFlagsVar, SizeVar, FlagsVar, &cerr)
853 if cerr == nil {
854 return cret, nil
855 }
856 return cret, cerr
857
858}
859
860var xResourceHasChildren func(uintptr, string) bool
861
862// Returns whether the specified @path in the resource
863// has children.
864func (x *Resource) HasChildren(PathVar string) bool {
865
866 cret := xResourceHasChildren(x.GoPointer(), PathVar)
867 return cret
868}
869
870var xResourceLookupData func(uintptr, string, ResourceLookupFlags, **glib.Error) *glib.Bytes
871
872// Looks for a file at the specified @path in the resource and
873// returns a [struct@GLib.Bytes] that lets you directly access the data in
874// memory.
875//
876// The data is always followed by a zero byte, so you
877// can safely use the data as a C string. However, that byte
878// is not included in the size of the [struct@GLib.Bytes].
879//
880// For uncompressed resource files this is a pointer directly into
881// the resource bundle, which is typically in some read-only data section
882// in the program binary. For compressed files, memory is allocated on
883// the heap and the data is automatically uncompressed.
884//
885// @lookup_flags controls the behaviour of the lookup.
886//
887// This can return error %G_RESOURCE_ERROR_NOT_FOUND if @path was not found in
888// @resource, or %G_RESOURCE_ERROR_INTERNAL if decompression of a compressed
889// resource failed.
890func (x *Resource) LookupData(PathVar string, LookupFlagsVar ResourceLookupFlags) (*glib.Bytes, error) {
891 var cerr *glib.Error
892
893 cret := xResourceLookupData(x.GoPointer(), PathVar, LookupFlagsVar, &cerr)
894 if cerr == nil {
895 return cret, nil
896 }
897 return cret, cerr
898
899}
900
901var xResourceOpenStream func(uintptr, string, ResourceLookupFlags, **glib.Error) uintptr
902
903// Looks for a file at the specified @path in the resource and
904// returns a [class@Gio.InputStream] that lets you read the data.
905//
906// @lookup_flags controls the behaviour of the lookup.
907//
908// The only error this can return is %G_RESOURCE_ERROR_NOT_FOUND, if @path was
909// not found in @resource.
910func (x *Resource) OpenStream(PathVar string, LookupFlagsVar ResourceLookupFlags) (*InputStream, error) {
911 var cls *InputStream
912 var cerr *glib.Error
913
914 cret := xResourceOpenStream(x.GoPointer(), PathVar, LookupFlagsVar, &cerr)
915
916 if cret == 0 {
917 return nil, cerr
918 }
919 cls = &InputStream{}
920 cls.Ptr = cret
921 if cerr == nil {
922 return cls, nil
923 }
924 return cls, cerr
925
926}
927
928var xResourceRef func(uintptr) *Resource
929
930// Atomically increments the reference count of @resource by one.
931//
932// This function is threadsafe and may be called from any thread.
933func (x *Resource) Ref() *Resource {
934
935 cret := xResourceRef(x.GoPointer())
936 return cret
937}
938
939var xResourceUnref func(uintptr)
940
941// Atomically decrements the reference count of @resource by one.
942//
943// If the reference count drops to 0, all memory allocated by the resource is
944// released. This function is threadsafe and may be called from any
945// thread.
946func (x *Resource) Unref() {
947
948 xResourceUnref(x.GoPointer())
949
950}
951
952// A single target host/port that a network service is running on.
953//
954// SRV (service) records are used by some network protocols to provide
955// service-specific aliasing and load-balancing. For example, XMPP
956// (Jabber) uses SRV records to locate the XMPP server for a domain;
957// rather than connecting directly to ‘example.com’ or assuming a
958// specific server hostname like ‘xmpp.example.com’, an XMPP client
959// would look up the `xmpp-client` SRV record for ‘example.com’, and
960// then connect to whatever host was pointed to by that record.
961//
962// You can use [method@Gio.Resolver.lookup_service] or
963// [method@Gio.Resolver.lookup_service_async] to find the `GSrvTarget`s
964// for a given service. However, if you are simply planning to connect
965// to the remote service, you can use [class@Gio.NetworkService]’s
966// [iface@Gio.SocketConnectable] interface and not need to worry about
967// `GSrvTarget` at all.
968type SrvTarget struct {
969 _ structs.HostLayout
970}
971
972var xSrvTargetGLibType func() types.GType
973
974func SrvTargetGLibType() types.GType {
975 return xSrvTargetGLibType()
976}
977
978func (x *SrvTarget) GoPointer() uintptr {
979 return uintptr(unsafe.Pointer(x))
980}
981
982var xNewSrvTarget func(string, uint16, uint16, uint16) *SrvTarget
983
984// Creates a new #GSrvTarget with the given parameters.
985//
986// You should not need to use this; normally #GSrvTargets are
987// created by #GResolver.
988func NewSrvTarget(HostnameVar string, PortVar uint16, PriorityVar uint16, WeightVar uint16) *SrvTarget {
989
990 cret := xNewSrvTarget(HostnameVar, PortVar, PriorityVar, WeightVar)
991 return cret
992}
993
994var xSrvTargetCopy func(uintptr) *SrvTarget
995
996// Copies @target
997func (x *SrvTarget) Copy() *SrvTarget {
998
999 cret := xSrvTargetCopy(x.GoPointer())
1000 return cret
1001}
1002
1003var xSrvTargetFree func(uintptr)
1004
1005// Frees @target
1006func (x *SrvTarget) Free() {
1007
1008 xSrvTargetFree(x.GoPointer())
1009
1010}
1011
1012var xSrvTargetGetHostname func(uintptr) string
1013
1014// Gets @target's hostname (in ASCII form; if you are going to present
1015// this to the user, you should use g_hostname_is_ascii_encoded() to
1016// check if it contains encoded Unicode segments, and use
1017// g_hostname_to_unicode() to convert it if it does.)
1018func (x *SrvTarget) GetHostname() string {
1019
1020 cret := xSrvTargetGetHostname(x.GoPointer())
1021 return cret
1022}
1023
1024var xSrvTargetGetPort func(uintptr) uint16
1025
1026// Gets @target's port
1027func (x *SrvTarget) GetPort() uint16 {
1028
1029 cret := xSrvTargetGetPort(x.GoPointer())
1030 return cret
1031}
1032
1033var xSrvTargetGetPriority func(uintptr) uint16
1034
1035// Gets @target's priority. You should not need to look at this;
1036// #GResolver already sorts the targets according to the algorithm in
1037// RFC 2782.
1038func (x *SrvTarget) GetPriority() uint16 {
1039
1040 cret := xSrvTargetGetPriority(x.GoPointer())
1041 return cret
1042}
1043
1044var xSrvTargetGetWeight func(uintptr) uint16
1045
1046// Gets @target's weight. You should not need to look at this;
1047// #GResolver already sorts the targets according to the algorithm in
1048// RFC 2782.
1049func (x *SrvTarget) GetWeight() uint16 {
1050
1051 cret := xSrvTargetGetWeight(x.GoPointer())
1052 return cret
1053}
1054
1055func init() {
1056 core.SetPackageName("GIO", "gio-2.0")
1057 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
1058 var libs []uintptr
1059 for _, libPath := range core.GetPaths("GIO") {
1060 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1061 if err != nil {
1062 panic(err)
1063 }
1064 libs = append(libs, lib)
1065 }
1066
1067 core.PuregoSafeRegister(&xFileAttributeMatcherGLibType, libs, "g_file_attribute_matcher_get_type")
1068
1069 core.PuregoSafeRegister(&xNewFileAttributeMatcher, libs, "g_file_attribute_matcher_new")
1070
1071 core.PuregoSafeRegister(&xFileAttributeMatcherEnumerateNamespace, libs, "g_file_attribute_matcher_enumerate_namespace")
1072 core.PuregoSafeRegister(&xFileAttributeMatcherEnumerateNext, libs, "g_file_attribute_matcher_enumerate_next")
1073 core.PuregoSafeRegister(&xFileAttributeMatcherMatches, libs, "g_file_attribute_matcher_matches")
1074 core.PuregoSafeRegister(&xFileAttributeMatcherMatchesOnly, libs, "g_file_attribute_matcher_matches_only")
1075 core.PuregoSafeRegister(&xFileAttributeMatcherRef, libs, "g_file_attribute_matcher_ref")
1076 core.PuregoSafeRegister(&xFileAttributeMatcherSubtract, libs, "g_file_attribute_matcher_subtract")
1077 core.PuregoSafeRegister(&xFileAttributeMatcherToString, libs, "g_file_attribute_matcher_to_string")
1078 core.PuregoSafeRegister(&xFileAttributeMatcherUnref, libs, "g_file_attribute_matcher_unref")
1079
1080 core.PuregoSafeRegister(&xIOExtensionGetName, libs, "g_io_extension_get_name")
1081 core.PuregoSafeRegister(&xIOExtensionGetPriority, libs, "g_io_extension_get_priority")
1082 core.PuregoSafeRegister(&xIOExtensionGetType, libs, "g_io_extension_get_type")
1083 core.PuregoSafeRegister(&xIOExtensionRefClass, libs, "g_io_extension_ref_class")
1084
1085 core.PuregoSafeRegister(&xIOExtensionPointGetExtensionByName, libs, "g_io_extension_point_get_extension_by_name")
1086 core.PuregoSafeRegister(&xIOExtensionPointGetExtensions, libs, "g_io_extension_point_get_extensions")
1087 core.PuregoSafeRegister(&xIOExtensionPointGetRequiredType, libs, "g_io_extension_point_get_required_type")
1088 core.PuregoSafeRegister(&xIOExtensionPointSetRequiredType, libs, "g_io_extension_point_set_required_type")
1089
1090 core.PuregoSafeRegister(&xIOSchedulerJobSendToMainloop, libs, "g_io_scheduler_job_send_to_mainloop")
1091 core.PuregoSafeRegister(&xIOSchedulerJobSendToMainloopAsync, libs, "g_io_scheduler_job_send_to_mainloop_async")
1092
1093 core.PuregoSafeRegister(&xResourceGLibType, libs, "g_resource_get_type")
1094
1095 core.PuregoSafeRegister(&xNewResourceFromData, libs, "g_resource_new_from_data")
1096
1097 core.PuregoSafeRegister(&xResourceRegister, libs, "g_resources_register")
1098 core.PuregoSafeRegister(&xResourceUnregister, libs, "g_resources_unregister")
1099 core.PuregoSafeRegister(&xResourceEnumerateChildren, libs, "g_resource_enumerate_children")
1100 core.PuregoSafeRegister(&xResourceGetInfo, libs, "g_resource_get_info")
1101 core.PuregoSafeRegister(&xResourceHasChildren, libs, "g_resource_has_children")
1102 core.PuregoSafeRegister(&xResourceLookupData, libs, "g_resource_lookup_data")
1103 core.PuregoSafeRegister(&xResourceOpenStream, libs, "g_resource_open_stream")
1104 core.PuregoSafeRegister(&xResourceRef, libs, "g_resource_ref")
1105 core.PuregoSafeRegister(&xResourceUnref, libs, "g_resource_unref")
1106
1107 core.PuregoSafeRegister(&xSrvTargetGLibType, libs, "g_srv_target_get_type")
1108
1109 core.PuregoSafeRegister(&xNewSrvTarget, libs, "g_srv_target_new")
1110
1111 core.PuregoSafeRegister(&xSrvTargetCopy, libs, "g_srv_target_copy")
1112 core.PuregoSafeRegister(&xSrvTargetFree, libs, "g_srv_target_free")
1113 core.PuregoSafeRegister(&xSrvTargetGetHostname, libs, "g_srv_target_get_hostname")
1114 core.PuregoSafeRegister(&xSrvTargetGetPort, libs, "g_srv_target_get_port")
1115 core.PuregoSafeRegister(&xSrvTargetGetPriority, libs, "g_srv_target_get_priority")
1116 core.PuregoSafeRegister(&xSrvTargetGetWeight, libs, "g_srv_target_get_weight")
1117
1118}