1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11)
12
13// Declares a type of function which takes no arguments
14// and has no return value. It is used to specify the type
15// function passed to g_atexit().
16type VoidFunc func()
17
18// Associates a string with a bit flag.
19// Used in g_parse_debug_string().
20type DebugKey struct {
21 _ structs.HostLayout
22
23 Key uintptr
24
25 Value uint
26}
27
28func (x *DebugKey) GoPointer() uintptr {
29 return uintptr(unsafe.Pointer(x))
30}
31
32// Flags to modify the format of the string returned by g_format_size_full().
33type FormatSizeFlags int
34
35const (
36
37 // behave the same as g_format_size()
38 GFormatSizeDefaultValue FormatSizeFlags = 0
39 // include the exact number of bytes as part
40 // of the returned string. For example, "45.6 kB (45,612 bytes)".
41 GFormatSizeLongFormatValue FormatSizeFlags = 1
42 // use IEC (base 1024) units with "KiB"-style
43 // suffixes. IEC units should only be used for reporting things with
44 // a strong "power of 2" basis, like RAM sizes or RAID stripe sizes.
45 // Network and storage sizes should be reported in the normal SI units.
46 GFormatSizeIecUnitsValue FormatSizeFlags = 2
47 // set the size as a quantity in bits, rather than
48 // bytes, and return units in bits. For example, ‘Mbit’ rather than ‘MB’.
49 GFormatSizeBitsValue FormatSizeFlags = 4
50 // return only value, without unit; this should
51 // not be used together with @G_FORMAT_SIZE_LONG_FORMAT
52 // nor @G_FORMAT_SIZE_ONLY_UNIT. Since: 2.74
53 GFormatSizeOnlyValueValue FormatSizeFlags = 8
54 // return only unit, without value; this should
55 // not be used together with @G_FORMAT_SIZE_LONG_FORMAT
56 // nor @G_FORMAT_SIZE_ONLY_VALUE. Since: 2.74
57 GFormatSizeOnlyUnitValue FormatSizeFlags = 16
58)
59
60// These are logical ids for special directories which are defined
61// depending on the platform used. You should use g_get_user_special_dir()
62// to retrieve the full path associated to the logical id.
63//
64// The #GUserDirectory enumeration can be extended at later date. Not
65// every platform has a directory for every logical id in this
66// enumeration.
67type UserDirectory int
68
69const (
70
71 // the user's Desktop directory
72 GUserDirectoryDesktopValue UserDirectory = 0
73 // the user's Documents directory
74 GUserDirectoryDocumentsValue UserDirectory = 1
75 // the user's Downloads directory
76 GUserDirectoryDownloadValue UserDirectory = 2
77 // the user's Music directory
78 GUserDirectoryMusicValue UserDirectory = 3
79 // the user's Pictures directory
80 GUserDirectoryPicturesValue UserDirectory = 4
81 // the user's shared directory
82 GUserDirectoryPublicShareValue UserDirectory = 5
83 // the user's Templates directory
84 GUserDirectoryTemplatesValue UserDirectory = 6
85 // the user's Movies directory
86 GUserDirectoryVideosValue UserDirectory = 7
87 // the number of enum values
88 GUserNDirectoriesValue UserDirectory = 8
89)
90
91var xAtexit func(uintptr)
92
93// Specifies a function to be called at normal program termination.
94//
95// Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
96// macro that maps to a call to the atexit() function in the C
97// library. This means that in case the code that calls g_atexit(),
98// i.e. atexit(), is in a DLL, the function will be called when the
99// DLL is detached from the program. This typically makes more sense
100// than that the function is called when the GLib DLL is detached,
101// which happened earlier when g_atexit() was a function in the GLib
102// DLL.
103//
104// The behaviour of atexit() in the context of dynamically loaded
105// modules is not formally specified and varies wildly.
106//
107// On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
108// loaded module which is unloaded before the program terminates might
109// well cause a crash at program exit.
110//
111// Some POSIX systems implement atexit() like Windows, and have each
112// dynamically loaded module maintain an own atexit chain that is
113// called when the module is unloaded.
114//
115// On other POSIX systems, before a dynamically loaded module is
116// unloaded, the registered atexit functions (if any) residing in that
117// module are called, regardless where the code that registered them
118// resided. This is presumably the most robust approach.
119//
120// As can be seen from the above, for portability it's best to avoid
121// calling g_atexit() (or atexit()) except in the main executable of a
122// program.
123func Atexit(FuncVar *VoidFunc) {
124
125 var FuncVarRef uintptr
126 if FuncVar != nil {
127 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
128 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
129 FuncVarRef = cbRefPtr
130 } else {
131 fcb := func() {
132 cbFn := *FuncVar
133 cbFn()
134 }
135 FuncVarRef = purego.NewCallback(fcb)
136 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
137 }
138 }
139
140 xAtexit(FuncVarRef)
141
142}
143
144var xBitNthLsf func(uint, int) int
145
146// Find the position of the first bit set in @mask, searching
147// from (but not including) @nth_bit upwards. Bits are numbered
148// from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
149// usually). To start searching from the 0th bit, set @nth_bit to -1.
150func BitNthLsf(MaskVar uint, NthBitVar int) int {
151
152 cret := xBitNthLsf(MaskVar, NthBitVar)
153
154 return cret
155}
156
157var xBitNthMsf func(uint, int) int
158
159// Find the position of the first bit set in @mask, searching
160// from (but not including) @nth_bit downwards. Bits are numbered
161// from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
162// usually). To start searching from the last bit, set @nth_bit to
163// -1 or GLIB_SIZEOF_LONG * 8.
164func BitNthMsf(MaskVar uint, NthBitVar int) int {
165
166 cret := xBitNthMsf(MaskVar, NthBitVar)
167
168 return cret
169}
170
171var xBitStorage func(uint) uint
172
173// Gets the number of bits used to hold @number,
174// e.g. if @number is 4, 3 bits are needed.
175func BitStorage(NumberVar uint) uint {
176
177 cret := xBitStorage(NumberVar)
178
179 return cret
180}
181
182var xFindProgramInPath func(string) string
183
184// Locates the first executable named @program in the user's path, in the
185// same way that execvp() would locate it. Returns an allocated string
186// with the absolute path name, or %NULL if the program is not found in
187// the path. If @program is already an absolute path, returns a copy of
188// @program if @program exists and is executable, and %NULL otherwise.
189//
190// On Windows, if @program does not have a file type suffix, tries
191// with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
192// the `PATHEXT` environment variable.
193//
194// On Windows, it looks for the file in the same way as CreateProcess()
195// would. This means first in the directory where the executing
196// program was loaded from, then in the current directory, then in the
197// Windows 32-bit system directory, then in the Windows directory, and
198// finally in the directories in the `PATH` environment variable. If
199// the program is found, the return value contains the full name
200// including the type suffix.
201func FindProgramInPath(ProgramVar string) string {
202
203 cret := xFindProgramInPath(ProgramVar)
204
205 return cret
206}
207
208var xFormatSize func(uint64) string
209
210// Formats a size (for example the size of a file) into a human readable
211// string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
212// and are displayed rounded to the nearest tenth. E.g. the file size
213// 3292528 bytes will be converted into the string "3.2 MB". The returned string
214// is UTF-8, and may use a non-breaking space to separate the number and units,
215// to ensure they aren’t separated when line wrapped.
216//
217// The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
218//
219// This string should be freed with g_free() when not needed any longer.
220//
221// See g_format_size_full() for more options about how the size might be
222// formatted.
223func FormatSize(SizeVar uint64) string {
224
225 cret := xFormatSize(SizeVar)
226
227 return cret
228}
229
230var xFormatSizeForDisplay func(int64) string
231
232// Formats a size (for example the size of a file) into a human
233// readable string. Sizes are rounded to the nearest size prefix
234// (KB, MB, GB) and are displayed rounded to the nearest tenth.
235// E.g. the file size 3292528 bytes will be converted into the
236// string "3.1 MB".
237//
238// The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
239//
240// This string should be freed with g_free() when not needed any longer.
241func FormatSizeForDisplay(SizeVar int64) string {
242
243 cret := xFormatSizeForDisplay(SizeVar)
244
245 return cret
246}
247
248var xFormatSizeFull func(uint64, FormatSizeFlags) string
249
250// Formats a size.
251//
252// This function is similar to g_format_size() but allows for flags
253// that modify the output. See #GFormatSizeFlags.
254func FormatSizeFull(SizeVar uint64, FlagsVar FormatSizeFlags) string {
255
256 cret := xFormatSizeFull(SizeVar, FlagsVar)
257
258 return cret
259}
260
261var xGetApplicationName func() string
262
263// Gets a human-readable name for the application, as set by
264// g_set_application_name(). This name should be localized if
265// possible, and is intended for display to the user. Contrast with
266// g_get_prgname(), which gets a non-localized name. If
267// g_set_application_name() has not been called, returns the result of
268// g_get_prgname() (which may be %NULL if g_set_prgname() has also not
269// been called).
270func GetApplicationName() string {
271
272 cret := xGetApplicationName()
273
274 return cret
275}
276
277var xGetHomeDir func() string
278
279// Gets the current user's home directory.
280//
281// As with most UNIX tools, this function will return the value of the
282// `HOME` environment variable if it is set to an existing absolute path
283// name, falling back to the `passwd` file in the case that it is unset.
284//
285// If the path given in `HOME` is non-absolute, does not exist, or is
286// not a directory, the result is undefined.
287//
288// Before version 2.36 this function would ignore the `HOME` environment
289// variable, taking the value from the `passwd` database instead. This was
290// changed to increase the compatibility of GLib with other programs (and
291// the XDG basedir specification) and to increase testability of programs
292// based on GLib (by making it easier to run them from test frameworks).
293//
294// If your program has a strong requirement for either the new or the
295// old behaviour (and if you don't wish to increase your GLib
296// dependency to ensure that the new behaviour is in effect) then you
297// should either directly check the `HOME` environment variable yourself
298// or unset it before calling any functions in GLib.
299func GetHomeDir() string {
300
301 cret := xGetHomeDir()
302
303 return cret
304}
305
306var xGetHostName func() string
307
308// Return a name for the machine.
309//
310// The returned name is not necessarily a fully-qualified domain name,
311// or even present in DNS or some other name service at all. It need
312// not even be unique on your local network or site, but usually it
313// is. Callers should not rely on the return value having any specific
314// properties like uniqueness for security purposes. Even if the name
315// of the machine is changed while an application is running, the
316// return value from this function does not change. The returned
317// string is owned by GLib and should not be modified or freed. If no
318// name can be determined, a default fixed string "localhost" is
319// returned.
320//
321// The encoding of the returned string is UTF-8.
322func GetHostName() string {
323
324 cret := xGetHostName()
325
326 return cret
327}
328
329var xGetOsInfo func(string) string
330
331// Get information about the operating system.
332//
333// On Linux this comes from the `/etc/os-release` file. On other systems, it may
334// come from a variety of sources. You can either use the standard key names
335// like %G_OS_INFO_KEY_NAME or pass any UTF-8 string key name. For example,
336// `/etc/os-release` provides a number of other less commonly used values that may
337// be useful. No key is guaranteed to be provided, so the caller should always
338// check if the result is %NULL.
339func GetOsInfo(KeyNameVar string) string {
340
341 cret := xGetOsInfo(KeyNameVar)
342
343 return cret
344}
345
346var xGetPrgname func() string
347
348// Gets the name of the program. This name should not be localized,
349// in contrast to g_get_application_name().
350//
351// If you are using #GApplication the program name is set in
352// g_application_run(). In case of GDK or GTK it is set in
353// gdk_init(), which is called by gtk_init() and the
354// #GtkApplication::startup handler. The program name is found by
355// taking the last component of @argv[0].
356func GetPrgname() string {
357
358 cret := xGetPrgname()
359
360 return cret
361}
362
363var xGetRealName func() string
364
365// Gets the real name of the user. This usually comes from the user's
366// entry in the `passwd` file. The encoding of the returned string is
367// system-defined. (On Windows, it is, however, always UTF-8.) If the
368// real user name cannot be determined, the string "Unknown" is
369// returned.
370func GetRealName() string {
371
372 cret := xGetRealName()
373
374 return cret
375}
376
377var xGetSystemConfigDirs func() []string
378
379// Returns an ordered list of base directories in which to access
380// system-wide configuration information.
381//
382// On UNIX platforms this is determined using the mechanisms described
383// in the
384// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
385// In this case the list of directories retrieved will be `XDG_CONFIG_DIRS`.
386//
387// On Windows it follows XDG Base Directory Specification if `XDG_CONFIG_DIRS` is defined.
388// If `XDG_CONFIG_DIRS` is undefined, the directory that contains application
389// data for all users is used instead. A typical path is
390// `C:\Documents and Settings\All Users\Application Data`.
391// This folder is used for application data
392// that is not user specific. For example, an application can store
393// a spell-check dictionary, a database of clip art, or a log file in the
394// FOLDERID_ProgramData folder. This information will not roam and is available
395// to anyone using the computer.
396//
397// The return value is cached and modifying it at runtime is not supported, as
398// it’s not thread-safe to modify environment variables at runtime.
399func GetSystemConfigDirs() []string {
400
401 cret := xGetSystemConfigDirs()
402
403 return cret
404}
405
406var xGetSystemDataDirs func() []string
407
408// Returns an ordered list of base directories in which to access
409// system-wide application data.
410//
411// On UNIX platforms this is determined using the mechanisms described
412// in the
413// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec)
414// In this case the list of directories retrieved will be `XDG_DATA_DIRS`.
415//
416// On Windows it follows XDG Base Directory Specification if `XDG_DATA_DIRS` is defined.
417// If `XDG_DATA_DIRS` is undefined,
418// the first elements in the list are the Application Data
419// and Documents folders for All Users. (These can be determined only
420// on Windows 2000 or later and are not present in the list on other
421// Windows versions.) See documentation for FOLDERID_ProgramData and
422// FOLDERID_PublicDocuments.
423//
424// Then follows the "share" subfolder in the installation folder for
425// the package containing the DLL that calls this function, if it can
426// be determined.
427//
428// Finally the list contains the "share" subfolder in the installation
429// folder for GLib, and in the installation folder for the package the
430// application's .exe file belongs to.
431//
432// The installation folders above are determined by looking up the
433// folder where the module (DLL or EXE) in question is located. If the
434// folder's name is "bin", its parent is used, otherwise the folder
435// itself.
436//
437// Note that on Windows the returned list can vary depending on where
438// this function is called.
439//
440// The return value is cached and modifying it at runtime is not supported, as
441// it’s not thread-safe to modify environment variables at runtime.
442func GetSystemDataDirs() []string {
443
444 cret := xGetSystemDataDirs()
445
446 return cret
447}
448
449var xGetTmpDir func() string
450
451// Gets the directory to use for temporary files.
452//
453// On UNIX, this is taken from the `TMPDIR` environment variable.
454// If the variable is not set, `P_tmpdir` is
455// used, as defined by the system C library. Failing that, a
456// hard-coded default of "/tmp" is returned.
457//
458// On Windows, the `TEMP` environment variable is used, with the
459// root directory of the Windows installation (eg: "C:\") used
460// as a default.
461//
462// The encoding of the returned string is system-defined. On Windows,
463// it is always UTF-8. The return value is never %NULL or the empty
464// string.
465func GetTmpDir() string {
466
467 cret := xGetTmpDir()
468
469 return cret
470}
471
472var xGetUserCacheDir func() string
473
474// Returns a base directory in which to store non-essential, cached
475// data specific to particular user.
476//
477// On UNIX platforms this is determined using the mechanisms described
478// in the
479// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
480// In this case the directory retrieved will be `XDG_CACHE_HOME`.
481//
482// On Windows it follows XDG Base Directory Specification if `XDG_CACHE_HOME` is defined.
483// If `XDG_CACHE_HOME` is undefined, the directory that serves as a common
484// repository for temporary Internet files is used instead. A typical path is
485// `C:\Documents and Settings\username\Local Settings\Temporary Internet Files`.
486// See the [documentation for `FOLDERID_InternetCache`](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
487//
488// The return value is cached and modifying it at runtime is not supported, as
489// it’s not thread-safe to modify environment variables at runtime.
490func GetUserCacheDir() string {
491
492 cret := xGetUserCacheDir()
493
494 return cret
495}
496
497var xGetUserConfigDir func() string
498
499// Returns a base directory in which to store user-specific application
500// configuration information such as user preferences and settings.
501//
502// On UNIX platforms this is determined using the mechanisms described
503// in the
504// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
505// In this case the directory retrieved will be `XDG_CONFIG_HOME`.
506//
507// On Windows it follows XDG Base Directory Specification if `XDG_CONFIG_HOME` is defined.
508// If `XDG_CONFIG_HOME` is undefined, the folder to use for local (as opposed
509// to roaming) application data is used instead. See the
510// [documentation for `FOLDERID_LocalAppData`](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
511// Note that in this case on Windows it will be the same
512// as what g_get_user_data_dir() returns.
513//
514// The return value is cached and modifying it at runtime is not supported, as
515// it’s not thread-safe to modify environment variables at runtime.
516func GetUserConfigDir() string {
517
518 cret := xGetUserConfigDir()
519
520 return cret
521}
522
523var xGetUserDataDir func() string
524
525// Returns a base directory in which to access application data such
526// as icons that is customized for a particular user.
527//
528// On UNIX platforms this is determined using the mechanisms described
529// in the
530// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
531// In this case the directory retrieved will be `XDG_DATA_HOME`.
532//
533// On Windows it follows XDG Base Directory Specification if `XDG_DATA_HOME`
534// is defined. If `XDG_DATA_HOME` is undefined, the folder to use for local (as
535// opposed to roaming) application data is used instead. See the
536// [documentation for `FOLDERID_LocalAppData`](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
537// Note that in this case on Windows it will be the same
538// as what g_get_user_config_dir() returns.
539//
540// The return value is cached and modifying it at runtime is not supported, as
541// it’s not thread-safe to modify environment variables at runtime.
542func GetUserDataDir() string {
543
544 cret := xGetUserDataDir()
545
546 return cret
547}
548
549var xGetUserName func() string
550
551// Gets the user name of the current user. The encoding of the returned
552// string is system-defined. On UNIX, it might be the preferred file name
553// encoding, or something else, and there is no guarantee that it is even
554// consistent on a machine. On Windows, it is always UTF-8.
555func GetUserName() string {
556
557 cret := xGetUserName()
558
559 return cret
560}
561
562var xGetUserRuntimeDir func() string
563
564// Returns a directory that is unique to the current user on the local
565// system.
566//
567// This is determined using the mechanisms described
568// in the
569// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
570// This is the directory
571// specified in the `XDG_RUNTIME_DIR` environment variable.
572// In the case that this variable is not set, we return the value of
573// g_get_user_cache_dir(), after verifying that it exists.
574//
575// The return value is cached and modifying it at runtime is not supported, as
576// it’s not thread-safe to modify environment variables at runtime.
577func GetUserRuntimeDir() string {
578
579 cret := xGetUserRuntimeDir()
580
581 return cret
582}
583
584var xGetUserSpecialDir func(UserDirectory) string
585
586// Returns the full path of a special directory using its logical id.
587//
588// On UNIX this is done using the XDG special user directories.
589// For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
590// falls back to `$HOME/Desktop` when XDG special user directories have
591// not been set up.
592//
593// Depending on the platform, the user might be able to change the path
594// of the special directory without requiring the session to restart; GLib
595// will not reflect any change once the special directories are loaded.
596func GetUserSpecialDir(DirectoryVar UserDirectory) string {
597
598 cret := xGetUserSpecialDir(DirectoryVar)
599
600 return cret
601}
602
603var xGetUserStateDir func() string
604
605// Returns a base directory in which to store state files specific to
606// particular user.
607//
608// On UNIX platforms this is determined using the mechanisms described
609// in the
610// [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
611// In this case the directory retrieved will be `XDG_STATE_HOME`.
612//
613// On Windows it follows XDG Base Directory Specification if `XDG_STATE_HOME` is defined.
614// If `XDG_STATE_HOME` is undefined, the folder to use for local (as opposed
615// to roaming) application data is used instead. See the
616// [documentation for `FOLDERID_LocalAppData`](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
617// Note that in this case on Windows it will be the same
618// as what g_get_user_data_dir() returns.
619//
620// The return value is cached and modifying it at runtime is not supported, as
621// it’s not thread-safe to modify environment variables at runtime.
622func GetUserStateDir() string {
623
624 cret := xGetUserStateDir()
625
626 return cret
627}
628
629var xNullifyPointer func(uintptr)
630
631// Set the pointer at the specified location to %NULL.
632func NullifyPointer(NullifyLocationVar uintptr) {
633
634 xNullifyPointer(NullifyLocationVar)
635
636}
637
638var xParseDebugString func(uintptr, []DebugKey, uint) uint
639
640// Parses a string containing debugging options
641// into a %guint containing bit flags. This is used
642// within GDK and GTK to parse the debug options passed on the
643// command line or through environment variables.
644//
645// If @string is equal to "all", all flags are set. Any flags
646// specified along with "all" in @string are inverted; thus,
647// "all,foo,bar" or "foo,bar,all" sets all flags except those
648// corresponding to "foo" and "bar".
649//
650// If @string is equal to "help", all the available keys in @keys
651// are printed out to standard error.
652func ParseDebugString(StringVar *string, KeysVar []DebugKey, NkeysVar uint) uint {
653
654 StringVarPtr := core.GStrdupNullable(StringVar)
655 defer core.GFreeNullable(StringVarPtr)
656
657 cret := xParseDebugString(StringVarPtr, KeysVar, NkeysVar)
658
659 return cret
660}
661
662var xReloadUserSpecialDirsCache func()
663
664// Resets the cache used for g_get_user_special_dir(), so
665// that the latest on-disk version is used. Call this only
666// if you just changed the data on disk yourself.
667//
668// Due to thread safety issues this may cause leaking of strings
669// that were previously returned from g_get_user_special_dir()
670// that can't be freed. We ensure to only leak the data for
671// the directories that actually changed value though.
672func ReloadUserSpecialDirsCache() {
673
674 xReloadUserSpecialDirsCache()
675
676}
677
678var xSetApplicationName func(string)
679
680// Sets a human-readable name for the application. This name should be
681// localized if possible, and is intended for display to the user.
682// Contrast with g_set_prgname(), which sets a non-localized name.
683// g_set_prgname() will be called automatically by gtk_init(),
684// but g_set_application_name() will not.
685//
686// Note that for thread safety reasons, this function can only
687// be called once.
688//
689// The application name will be used in contexts such as error messages,
690// or when displaying an application's name in the task list.
691func SetApplicationName(ApplicationNameVar string) {
692
693 xSetApplicationName(ApplicationNameVar)
694
695}
696
697var xSetPrgname func(string)
698
699// Sets the name of the program. This name should not be localized,
700// in contrast to g_set_application_name().
701//
702// If you are using #GApplication the program name is set in
703// g_application_run(). In case of GDK or GTK it is set in
704// gdk_init(), which is called by gtk_init() and the
705// #GtkApplication::startup handler. By default, the program name is
706// found by taking the last component of @argv[0].
707//
708// Since GLib 2.72, this function can be called multiple times
709// and is fully thread safe. Prior to GLib 2.72, this function
710// could only be called once per process.
711//
712// See the [GTK documentation](https://docs.gtk.org/gtk4/migrating-3to4.html#set-a-proper-application-id)
713// for requirements on integrating g_set_prgname() with GTK applications.
714func SetPrgname(PrgnameVar string) {
715
716 xSetPrgname(PrgnameVar)
717
718}
719
720var xSnprintf func(string, uint, string, ...interface{}) int
721
722// A safer form of the standard sprintf() function. The output is guaranteed
723// to not exceed @n characters (including the terminating nul character), so
724// it is easy to ensure that a buffer overflow cannot occur.
725//
726// See also [func@GLib.strdup_printf].
727//
728// In versions of GLib prior to 1.2.3, this function may return -1 if the
729// output was truncated, and the truncated string may not be nul-terminated.
730// In versions prior to 1.3.12, this function returns the length of the output
731// string.
732//
733// The return value of g_snprintf() conforms to the snprintf()
734// function as standardized in ISO C99. Note that this is different from
735// traditional `snprintf()`, which returns the length of the output string.
736//
737// The format string may contain positional parameters, as specified in
738// the Single Unix Specification.
739func Snprintf(StringVar string, NVar uint, FormatVar string, varArgs ...interface{}) int {
740
741 cret := xSnprintf(StringVar, NVar, FormatVar, varArgs...)
742
743 return cret
744}
745
746var xVsnprintf func(string, uint, string, []interface{}) int
747
748// A safer form of the standard `vsprintf()` function. The output is guaranteed
749// to not exceed @n characters (including the terminating nul character), so
750// it is easy to ensure that a buffer overflow cannot occur.
751//
752// See also [func@GLib.strdup_vprintf].
753//
754// In versions of GLib prior to 1.2.3, this function may return -1 if the
755// output was truncated, and the truncated string may not be nul-terminated.
756// In versions prior to 1.3.12, this function returns the length of the output
757// string.
758//
759// The return value of `g_vsnprintf()` conforms to the `vsnprintf()` function
760// as standardized in ISO C99. Note that this is different from traditional
761// `vsnprintf()`, which returns the length of the output string.
762//
763// The format string may contain positional parameters, as specified in
764// the Single Unix Specification.
765func Vsnprintf(StringVar string, NVar uint, FormatVar string, ArgsVar []interface{}) int {
766
767 cret := xVsnprintf(StringVar, NVar, FormatVar, ArgsVar)
768
769 return cret
770}
771
772func init() {
773 core.SetPackageName("GLIB", "glib-2.0")
774 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
775 var libs []uintptr
776 for _, libPath := range core.GetPaths("GLIB") {
777 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
778 if err != nil {
779 panic(err)
780 }
781 libs = append(libs, lib)
782 }
783
784 core.PuregoSafeRegister(&xAtexit, libs, "g_atexit")
785 core.PuregoSafeRegister(&xBitNthLsf, libs, "g_bit_nth_lsf")
786 core.PuregoSafeRegister(&xBitNthMsf, libs, "g_bit_nth_msf")
787 core.PuregoSafeRegister(&xBitStorage, libs, "g_bit_storage")
788 core.PuregoSafeRegister(&xFindProgramInPath, libs, "g_find_program_in_path")
789 core.PuregoSafeRegister(&xFormatSize, libs, "g_format_size")
790 core.PuregoSafeRegister(&xFormatSizeForDisplay, libs, "g_format_size_for_display")
791 core.PuregoSafeRegister(&xFormatSizeFull, libs, "g_format_size_full")
792 core.PuregoSafeRegister(&xGetApplicationName, libs, "g_get_application_name")
793 core.PuregoSafeRegister(&xGetHomeDir, libs, "g_get_home_dir")
794 core.PuregoSafeRegister(&xGetHostName, libs, "g_get_host_name")
795 core.PuregoSafeRegister(&xGetOsInfo, libs, "g_get_os_info")
796 core.PuregoSafeRegister(&xGetPrgname, libs, "g_get_prgname")
797 core.PuregoSafeRegister(&xGetRealName, libs, "g_get_real_name")
798 core.PuregoSafeRegister(&xGetSystemConfigDirs, libs, "g_get_system_config_dirs")
799 core.PuregoSafeRegister(&xGetSystemDataDirs, libs, "g_get_system_data_dirs")
800 core.PuregoSafeRegister(&xGetTmpDir, libs, "g_get_tmp_dir")
801 core.PuregoSafeRegister(&xGetUserCacheDir, libs, "g_get_user_cache_dir")
802 core.PuregoSafeRegister(&xGetUserConfigDir, libs, "g_get_user_config_dir")
803 core.PuregoSafeRegister(&xGetUserDataDir, libs, "g_get_user_data_dir")
804 core.PuregoSafeRegister(&xGetUserName, libs, "g_get_user_name")
805 core.PuregoSafeRegister(&xGetUserRuntimeDir, libs, "g_get_user_runtime_dir")
806 core.PuregoSafeRegister(&xGetUserSpecialDir, libs, "g_get_user_special_dir")
807 core.PuregoSafeRegister(&xGetUserStateDir, libs, "g_get_user_state_dir")
808 core.PuregoSafeRegister(&xNullifyPointer, libs, "g_nullify_pointer")
809 core.PuregoSafeRegister(&xParseDebugString, libs, "g_parse_debug_string")
810 core.PuregoSafeRegister(&xReloadUserSpecialDirsCache, libs, "g_reload_user_special_dirs_cache")
811 core.PuregoSafeRegister(&xSetApplicationName, libs, "g_set_application_name")
812 core.PuregoSafeRegister(&xSetPrgname, libs, "g_set_prgname")
813 core.PuregoSafeRegister(&xSnprintf, libs, "g_snprintf")
814 core.PuregoSafeRegister(&xVsnprintf, libs, "g_vsnprintf")
815
816}