1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8)
9
10var xGetCharset func(*string) bool
11
12// Obtains the character set for the [current locale](running.html#locale);
13// you might use this character set as an argument to g_convert(), to convert
14// from the current locale's encoding to some other encoding. (Frequently
15// g_locale_to_utf8() and g_locale_from_utf8() are nice shortcuts, though.)
16//
17// On Windows the character set returned by this function is the
18// so-called system default ANSI code-page. That is the character set
19// used by the "narrow" versions of C library and Win32 functions that
20// handle file names. It might be different from the character set
21// used by the C library's current locale.
22//
23// On Linux, the character set is found by consulting nl_langinfo() if
24// available. If not, the environment variables `LC_ALL`, `LC_CTYPE`, `LANG`
25// and `CHARSET` are queried in order. nl_langinfo() returns the C locale if
26// no locale has been loaded by setlocale().
27//
28// The return value is %TRUE if the locale's encoding is UTF-8, in that
29// case you can perhaps avoid calling g_convert().
30//
31// The string returned in @charset is not allocated, and should not be
32// freed.
33func GetCharset(CharsetVar *string) bool {
34
35 cret := xGetCharset(CharsetVar)
36
37 return cret
38}
39
40var xGetCodeset func() string
41
42// Gets the character set for the current locale.
43func GetCodeset() string {
44
45 cret := xGetCodeset()
46
47 return cret
48}
49
50var xGetConsoleCharset func(*string) bool
51
52// Obtains the character set used by the console attached to the process,
53// which is suitable for printing output to the terminal.
54//
55// Usually this matches the result returned by g_get_charset(), but in
56// environments where the locale's character set does not match the encoding
57// of the console this function tries to guess a more suitable value instead.
58//
59// On Windows the character set returned by this function is the
60// output code page used by the console associated with the calling process.
61// If the codepage can't be determined (for example because there is no
62// console attached) UTF-8 is assumed.
63//
64// The return value is %TRUE if the locale's encoding is UTF-8, in that
65// case you can perhaps avoid calling g_convert().
66//
67// The string returned in @charset is not allocated, and should not be
68// freed.
69func GetConsoleCharset(CharsetVar *string) bool {
70
71 cret := xGetConsoleCharset(CharsetVar)
72
73 return cret
74}
75
76var xGetLanguageNames func() []string
77
78// Computes a list of applicable locale names, which can be used to
79// e.g. construct locale-dependent filenames or search paths. The returned
80// list is sorted from most desirable to least desirable and always contains
81// the default locale "C".
82//
83// For example, if LANGUAGE=de:en_US, then the returned list is
84// "de", "en_US", "en", "C".
85//
86// This function consults the environment variables `LANGUAGE`, `LC_ALL`,
87// `LC_MESSAGES` and `LANG` to find the list of locales specified by the
88// user.
89func GetLanguageNames() []string {
90
91 cret := xGetLanguageNames()
92
93 return cret
94}
95
96var xGetLanguageNamesWithCategory func(string) []string
97
98// Computes a list of applicable locale names with a locale category name,
99// which can be used to construct the fallback locale-dependent filenames
100// or search paths. The returned list is sorted from most desirable to
101// least desirable and always contains the default locale "C".
102//
103// This function consults the environment variables `LANGUAGE`, `LC_ALL`,
104// @category_name, and `LANG` to find the list of locales specified by the
105// user.
106//
107// g_get_language_names() returns g_get_language_names_with_category("LC_MESSAGES").
108func GetLanguageNamesWithCategory(CategoryNameVar string) []string {
109
110 cret := xGetLanguageNamesWithCategory(CategoryNameVar)
111
112 return cret
113}
114
115var xGetLocaleVariants func(string) []string
116
117// Returns a list of derived variants of @locale, which can be used to
118// e.g. construct locale-dependent filenames or search paths. The returned
119// list is sorted from most desirable to least desirable.
120// This function handles territory, charset and extra locale modifiers. See
121// [`setlocale(3)`](man:setlocale) for information about locales and their format.
122//
123// @locale itself is guaranteed to be returned in the output.
124//
125// For example, if @locale is `fr_BE`, then the returned list
126// is `fr_BE`, `fr`. If @locale is `en_GB.UTF-8@euro`, then the returned list
127// is `en_GB.UTF-8@euro`, `en_GB.UTF-8`, `en_GB@euro`, `en_GB`, `en.UTF-8@euro`,
128// `en.UTF-8`, `en@euro`, `en`.
129//
130// If you need the list of variants for the current locale,
131// use g_get_language_names().
132func GetLocaleVariants(LocaleVar string) []string {
133
134 cret := xGetLocaleVariants(LocaleVar)
135
136 return cret
137}
138
139func init() {
140 core.SetPackageName("GLIB", "glib-2.0")
141 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
142 var libs []uintptr
143 for _, libPath := range core.GetPaths("GLIB") {
144 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
145 if err != nil {
146 panic(err)
147 }
148 libs = append(libs, lib)
149 }
150
151 core.PuregoSafeRegister(&xGetCharset, libs, "g_get_charset")
152 core.PuregoSafeRegister(&xGetCodeset, libs, "g_get_codeset")
153 core.PuregoSafeRegister(&xGetConsoleCharset, libs, "g_get_console_charset")
154 core.PuregoSafeRegister(&xGetLanguageNames, libs, "g_get_language_names")
155 core.PuregoSafeRegister(&xGetLanguageNamesWithCategory, libs, "g_get_language_names_with_category")
156 core.PuregoSafeRegister(&xGetLocaleVariants, libs, "g_get_locale_variants")
157
158}