Debian Codegraph @

gtk/gtkprivate.c

raw symbols SCIP
1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25 #include "config.h"cxx . . $ `<file>/build/config.h`/
26
27 #include <locale.h>
28 #include <stdlib.h>
29
30 #include "gdk/gdk.h"cxx . . $ `<file>/gdk/gdk.h`/
31
32 #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/
33 #include "gtkresources.h"cxx . . $ `<file>/build/gtk/gtkresources.h`/
34
35
36 #if !defined (G_OS_WIN32) && !(defined (GDK_WINDOWING_MACOS) && defined (QUARTZ_RELOCATION))
37
38 const char *
39 _gtk_get_datadircxx . . $ _gtk_get_datadir(33a1f659e94feb42). (void)
40 {
41 return GTK_DATADIRcxx . . $ `build/config.h:12:9`!;
42 }
43
44 const char *
45 _gtk_get_libdircxx . . $ _gtk_get_libdir(33a1f659e94feb42). (void)
46 {
47 return GTK_LIBDIRcxx . . $ `build/config.h:14:9`!;
48 }
49
50 const char *
51 _gtk_get_sysconfdircxx . . $ _gtk_get_sysconfdir(33a1f659e94feb42). (void)
52 {
53 return GTK_SYSCONFDIRcxx . . $ `build/config.h:20:9`!;
54 }
55
56 const char *
57 _gtk_get_localedircxx . . $ _gtk_get_localedir(33a1f659e94feb42). (void)
58 {
59 return GTK_LOCALEDIRcxx . . $ `build/config.h:16:9`!;
60 }
61
62 const char *
63 _gtk_get_data_prefixcxx . . $ _gtk_get_data_prefix(33a1f659e94feb42). (void)
64 {
65 return GTK_DATA_PREFIXcxx . . $ `<built-in>:424:9`!;
66 }
67
68 #endif
69
70 /* _gtk_get_lc_ctype:
71 *
72 * Return the Unix-style locale string for the language currently in
73 * effect. On Unix systems, this is the return value from
74 * `setlocale(LC_CTYPE, NULL)`, and the user can
75 * affect this through the environment variables LC_ALL, LC_CTYPE or
76 * LANG (checked in that order). The locale strings typically is in
77 * the form lang_COUNTRY, where lang is an ISO-639 language code, and
78 * COUNTRY is an ISO-3166 country code. For instance, sv_FI for
79 * Swedish as written in Finland or pt_BR for Portuguese as written in
80 * Brazil.
81 *
82 * On Windows, the C library doesn’t use any such environment
83 * variables, and setting them won’t affect the behaviour of functions
84 * like ctime(). The user sets the locale through the Regional Options
85 * in the Control Panel. The C library (in the setlocale() function)
86 * does not use country and language codes, but country and language
87 * names spelled out in English.
88 * However, this function does check the above environment
89 * variables, and does return a Unix-style locale string based on
90 * either said environment variables or the thread’s current locale.
91 *
92 * Returns: a dynamically allocated string, free with g_free().
93 */
94
95 char *
96 _gtk_get_lc_ctypecxx . . $ _gtk_get_lc_ctype(41208ce6ca65dd58). (void)
97 {
98 #ifdef G_OS_WIN32
99 /* Somebody might try to set the locale for this process using the
100 * LANG or LC_ environment variables. The Microsoft C library
101 * doesn't know anything about them. You set the locale in the
102 * Control Panel. Setting these env vars won't have any affect on
103 * locale-dependent C library functions like ctime(). But just for
104 * kicks, do obey LC_ALL, LC_CTYPE and LANG in GTK. (This also makes
105 * it easier to test GTK and Pango in various default languages, you
106 * don't have to clickety-click in the Control Panel, you can simply
107 * start the program with LC_ALL=something on the command line.)
108 */
109 char *p;
110
111 p = getenv ("LC_ALL");
112 if (p != NULL)
113 return g_strdup (p);
114
115 p = getenv ("LC_CTYPE");
116 if (p != NULL)
117 return g_strdup (p);
118
119 p = getenv ("LANG");
120 if (p != NULL)
121 return g_strdup (p);
122
123 return g_win32_getlocale ();
124 #else
125 return g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (setlocale (LC_CTYPEcxx . . $ `<external>/3736975272097309885/locale.h:35:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!));
126 #endif
127 }
128
129 gbooleancxx . . $ gboolean#
130 _gtk_boolean_handled_accumulatorcxx . . $ _gtk_boolean_handled_accumulator(76292f232a01f816). (GSignalInvocationHintcxx . . $ GSignalInvocationHint# *ihint,
131 GValuecxx . . $ GValue# *return_accu,
132 const GValuecxx . . $ GValue# *handler_return,
133 gpointercxx . . $ gpointer# dummy)
134 {
135 gbooleancxx . . $ gboolean# continue_emission;
136 gbooleancxx . . $ gboolean# signal_handled;
137
138 signal_handled = g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (handler_return);
139 g_value_set_booleancxx . . $ g_value_set_boolean(b698c61e8e30c4ea). (return_accu, signal_handled);
140 continue_emission = !signal_handled;
141
142 return continue_emission;
143 }
144
145 gbooleancxx . . $ gboolean#
146 _gtk_single_string_accumulatorcxx . . $ _gtk_single_string_accumulator(76292f232a01f816). (GSignalInvocationHintcxx . . $ GSignalInvocationHint# *ihint,
147 GValuecxx . . $ GValue# *return_accu,
148 const GValuecxx . . $ GValue# *handler_return,
149 gpointercxx . . $ gpointer# dummy)
150 {
151 gbooleancxx . . $ gboolean# continue_emission;
152 const char *str;
153
154 str = g_value_get_stringcxx . . $ g_value_get_string(cc0a2be2b8f7bdc8). (handler_return);
155 g_value_set_stringcxx . . $ g_value_set_string(65b9ea7708b82b9b). (return_accu, str);
156 continue_emission = str == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
157
158 return continue_emission;
159 }
160
161 static gpointercxx . . $ gpointer#
162 register_resourcescxx . . $ register_resources(9f162e79bfc6c74). (gpointercxx . . $ gpointer# data)
163 {
164 _gtk_register_resourcecxx . . $ _gtk_register_resource(49f6e7a06ebc5aa8). ();
165 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
166 }
167
168 void
169 _gtk_ensure_resourcescxx . . $ _gtk_ensure_resources(49f6e7a06ebc5aa8). (void)
170 {
171 static GOncecxx . . $ GOnce# register_resources_once = G_ONCE_INITcxx . . $ `<external>/457917468643292165/gthread.h:104:9`!;
172
173 g_oncecxx . . $ `<external>/457917468643292165/gthread.h:261:10`! (&register_resources_once, register_resources, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
174 }
175
176 /*
177 * gtk_get_portal_interface_version:
178 * @connection: a session `GDBusConnection`
179 * @interface_name: the interface name for the portal interface
180 * we're interested in.
181 *
182 * Returns: the version number of the portal, or 0 on error.
183 */
184 guintcxx . . $ guint#
185 gtk_get_portal_interface_versioncxx . . $ gtk_get_portal_interface_version(61db2a0e65eccd1a). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
186 const char *interface_name)
187 {
188 GDBusProxycxx . . $ GDBusProxy# *proxy = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
189 GErrorcxx . . $ GError# *error = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
190 GVariantcxx . . $ GVariant# *ret = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
191 char *owner = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
192 guintcxx . . $ guint# version = 0;
193
194 proxy = g_dbus_proxy_new_synccxx . . $ g_dbus_proxy_new_sync(f819688676c400fd). (connection,
195 0,
196 NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!,
197 "org.freedesktop.portal.Desktop",
198 "/org/freedesktop/portal/desktop",
199 interface_name,
200 NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!,
201 &error);
202 if (!proxy)
203 {
204 if (!g_error_matchescxx . . $ g_error_matches(604444fafc3e7b63). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_CANCELLEDcxx . . $ G_IO_ERROR_CANCELLED.))
205 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:340:9`! ("Could not query portal version on interface '%s': %s",
206 interface_name, error->message);
207 goto out;
208 }
209
210 owner = g_dbus_proxy_get_name_ownercxx . . $ g_dbus_proxy_get_name_owner(fc473134a76e7464). (proxy);
211 if (owner == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
212 {
213 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:346:9`! ("%s not provided by any service", interface_name);
214 goto out;
215 }
216
217 ret = g_dbus_proxy_get_cached_propertycxx . . $ g_dbus_proxy_get_cached_property(2997765c05144dbe). (proxy, "version");
218 if (ret)
219 version = g_variant_get_uint32cxx . . $ g_variant_get_uint32(59fb6aaaf011986f). (ret);
220
221 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:346:9`! ("Got version %u for portal interface '%s'",
222 version, interface_name);
223
224 out:
225 g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&proxy);
226 g_clear_errorcxx . . $ g_clear_error(19f343512d040fc2). (&error);
227 g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&ret, g_variant_unref);
228 g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&owner, g_free);
229
230 return version;
231 }
232
233 static char *
234 get_portal_pathcxx . . $ get_portal_path(e5a26d2e58cadc35). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
235 const char *kind,
236 char **token)
237 {
238 char *sender;
239 int i;
240 char *path;
241
242 *token = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("gtk%d", g_random_int_rangecxx . . $ g_random_int_range(9b79fb6aee4c0440). (0, G_MAXINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:39:9`!));
243 /* +1 to skip the leading : */
244 sender = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (g_dbus_connection_get_unique_name (connection) + 1);
245 for (i = 0; sender[i]; i++)
246 if (sender[i] == '.')
247 sender[i] = '_';
248
249 path = g_strconcatcxx . . $ g_strconcat(a849077ff1b8d812). (PORTAL_OBJECT_PATHcxx . . $ `gtk/gtkprivate.h:117:9`!, "/", kind, "/", sender, "/", *token, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
250
251 g_freecxx . . $ g_free(5d22bdacc48458e8). (sender);
252
253 return path;
254 }
255
256 char *
257 gtk_get_portal_request_pathcxx . . $ gtk_get_portal_request_path(498959a36124f452). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
258 char **token)
259 {
260 return get_portal_pathcxx . . $ get_portal_path(e5a26d2e58cadc35). (connection, "request", token);
261 }
262
263 char *
264 gtk_get_portal_session_pathcxx . . $ gtk_get_portal_session_path(498959a36124f452). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
265 char **token)
266 {
267 return get_portal_pathcxx . . $ get_portal_path(e5a26d2e58cadc35). (connection, "session", token);
268 }
269
270 char *
271 _gtk_elide_underscorescxx . . $ _gtk_elide_underscores(a8b8e32347182212). (const char *original)
272 {
273 char *q, *result;
274 const char *p, *end;
275 gsizecxx . . $ gsize# len;
276 gbooleancxx . . $ gboolean# last_underscore;
277
278 if (!original)
279 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
280
281 len = strlencxx . . $ strlen(751346f8406fd082). (original);
282 q = result = g_malloccxx . . $ g_malloc(bfcfa4d6b7f7ef64). (len + 1);
283 last_underscore = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
284
285 end = original + len;
286 for (p = original; p < end; p++)
287 {
288 if (!last_underscore && *p == '_')
289 last_underscore = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
290 else
291 {
292 last_underscore = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
293 if (original + 2 <= p && p + 1 <= end &&
294 p[-2] == '(' && p[-1] == '_' && p[0] != '_' && p[1] == ')')
295 {
296 q--;
297 *q = '\0';
298 p++;
299 }
300 else
301 *q++ = *p;
302 }
303 }
304
305 if (last_underscore)
306 *q++ = '_';
307
308 *q = '\0';
309
310 return result;
311 }