1 | /* gkeyfile.h - desktop entry file parser |
2 | * |
3 | * Copyright 2004 Red Hat, Inc. |
4 | * |
5 | * Ray Strode <halfline@hawaii.rr.com> |
6 | * |
7 | * SPDX-License-Identifier: LGPL-2.1-or-later |
8 | * |
9 | * This library is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU Lesser General Public |
11 | * License as published by the Free Software Foundation; either |
12 | * version 2.1 of the License, or (at your option) any later version. |
13 | * |
14 | * This library is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | * Lesser General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU Lesser General Public License |
20 | * along with this library; if not, see <http://www.gnu.org/licenses/>. |
21 | */ |
22 | |
23 | #ifndef __G_KEY_FILE_H__ |
24 | #define __G_KEY_FILE_H__ |
25 | |
26 | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) |
27 | #error "Only <glib.h> can be included directly." |
28 | #endif |
29 | |
30 | #include <glib/gbytes.h> |
31 | #include <glib/gerror.h> |
32 | |
33 | G_BEGIN_DECLS |
34 | |
35 | typedef enum |
36 | { |
37 | G_KEY_FILE_ERROR_UNKNOWN_ENCODING, |
38 | G_KEY_FILE_ERROR_PARSE, |
39 | G_KEY_FILE_ERROR_NOT_FOUND, |
40 | G_KEY_FILE_ERROR_KEY_NOT_FOUND, |
41 | G_KEY_FILE_ERROR_GROUP_NOT_FOUND, |
42 | G_KEY_FILE_ERROR_INVALID_VALUE |
43 | } GKeyFileError; |
44 | |
45 | #define G_KEY_FILE_ERROR g_key_file_error_quark() |
46 | |
47 | GLIB_AVAILABLE_IN_ALL |
48 | GQuark g_key_file_error_quark (void); |
49 | |
50 | typedef struct _GKeyFile GKeyFile; |
51 | |
52 | typedef enum |
53 | { |
54 | G_KEY_FILE_NONE = 0, |
55 | = 1 << 0, |
56 | G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1 |
57 | } GKeyFileFlags; |
58 | |
59 | GLIB_AVAILABLE_IN_ALL |
60 | GKeyFile *g_key_file_new (void); |
61 | GLIB_AVAILABLE_IN_ALL |
62 | GKeyFile *g_key_file_ref (GKeyFile *key_file); |
63 | GLIB_AVAILABLE_IN_ALL |
64 | void g_key_file_unref (GKeyFile *key_file); |
65 | GLIB_AVAILABLE_IN_ALL |
66 | void g_key_file_free (GKeyFile *key_file); |
67 | GLIB_AVAILABLE_IN_ALL |
68 | void g_key_file_set_list_separator (GKeyFile *key_file, |
69 | gchar separator); |
70 | GLIB_AVAILABLE_IN_ALL |
71 | gboolean g_key_file_load_from_file (GKeyFile *key_file, |
72 | const gchar *file, |
73 | GKeyFileFlags flags, |
74 | GError **error); |
75 | GLIB_AVAILABLE_IN_ALL |
76 | gboolean g_key_file_load_from_data (GKeyFile *key_file, |
77 | const gchar *data, |
78 | gsize length, |
79 | GKeyFileFlags flags, |
80 | GError **error); |
81 | GLIB_AVAILABLE_IN_2_50 |
82 | gboolean g_key_file_load_from_bytes (GKeyFile *key_file, |
83 | GBytes *bytes, |
84 | GKeyFileFlags flags, |
85 | GError **error); |
86 | GLIB_AVAILABLE_IN_ALL |
87 | gboolean g_key_file_load_from_dirs (GKeyFile *key_file, |
88 | const gchar *file, |
89 | const gchar **search_dirs, |
90 | gchar **full_path, |
91 | GKeyFileFlags flags, |
92 | GError **error); |
93 | GLIB_AVAILABLE_IN_ALL |
94 | gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file, |
95 | const gchar *file, |
96 | gchar **full_path, |
97 | GKeyFileFlags flags, |
98 | GError **error); |
99 | GLIB_AVAILABLE_IN_ALL |
100 | gchar *g_key_file_to_data (GKeyFile *key_file, |
101 | gsize *length, |
102 | GError **error) G_GNUC_MALLOC; |
103 | GLIB_AVAILABLE_IN_2_40 |
104 | gboolean g_key_file_save_to_file (GKeyFile *key_file, |
105 | const gchar *filename, |
106 | GError **error); |
107 | GLIB_AVAILABLE_IN_ALL |
108 | gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC; |
109 | GLIB_AVAILABLE_IN_ALL |
110 | gchar **g_key_file_get_groups (GKeyFile *key_file, |
111 | gsize *length); |
112 | GLIB_AVAILABLE_IN_ALL |
113 | gchar **g_key_file_get_keys (GKeyFile *key_file, |
114 | const gchar *group_name, |
115 | gsize *length, |
116 | GError **error); |
117 | GLIB_AVAILABLE_IN_ALL |
118 | gboolean g_key_file_has_group (GKeyFile *key_file, |
119 | const gchar *group_name); |
120 | GLIB_AVAILABLE_IN_ALL |
121 | gboolean g_key_file_has_key (GKeyFile *key_file, |
122 | const gchar *group_name, |
123 | const gchar *key, |
124 | GError **error); |
125 | GLIB_AVAILABLE_IN_ALL |
126 | gchar *g_key_file_get_value (GKeyFile *key_file, |
127 | const gchar *group_name, |
128 | const gchar *key, |
129 | GError **error) G_GNUC_MALLOC; |
130 | GLIB_AVAILABLE_IN_ALL |
131 | void g_key_file_set_value (GKeyFile *key_file, |
132 | const gchar *group_name, |
133 | const gchar *key, |
134 | const gchar *value); |
135 | GLIB_AVAILABLE_IN_ALL |
136 | gchar *g_key_file_get_string (GKeyFile *key_file, |
137 | const gchar *group_name, |
138 | const gchar *key, |
139 | GError **error) G_GNUC_MALLOC; |
140 | GLIB_AVAILABLE_IN_ALL |
141 | void g_key_file_set_string (GKeyFile *key_file, |
142 | const gchar *group_name, |
143 | const gchar *key, |
144 | const gchar *string); |
145 | GLIB_AVAILABLE_IN_ALL |
146 | gchar *g_key_file_get_locale_string (GKeyFile *key_file, |
147 | const gchar *group_name, |
148 | const gchar *key, |
149 | const gchar *locale, |
150 | GError **error) G_GNUC_MALLOC; |
151 | GLIB_AVAILABLE_IN_2_56 |
152 | gchar *g_key_file_get_locale_for_key (GKeyFile *key_file, |
153 | const gchar *group_name, |
154 | const gchar *key, |
155 | const gchar *locale) G_GNUC_MALLOC; |
156 | GLIB_AVAILABLE_IN_ALL |
157 | void g_key_file_set_locale_string (GKeyFile *key_file, |
158 | const gchar *group_name, |
159 | const gchar *key, |
160 | const gchar *locale, |
161 | const gchar *string); |
162 | GLIB_AVAILABLE_IN_ALL |
163 | gboolean g_key_file_get_boolean (GKeyFile *key_file, |
164 | const gchar *group_name, |
165 | const gchar *key, |
166 | GError **error); |
167 | GLIB_AVAILABLE_IN_ALL |
168 | void g_key_file_set_boolean (GKeyFile *key_file, |
169 | const gchar *group_name, |
170 | const gchar *key, |
171 | gboolean value); |
172 | GLIB_AVAILABLE_IN_ALL |
173 | gint g_key_file_get_integer (GKeyFile *key_file, |
174 | const gchar *group_name, |
175 | const gchar *key, |
176 | GError **error); |
177 | GLIB_AVAILABLE_IN_ALL |
178 | void g_key_file_set_integer (GKeyFile *key_file, |
179 | const gchar *group_name, |
180 | const gchar *key, |
181 | gint value); |
182 | GLIB_AVAILABLE_IN_ALL |
183 | gint64 g_key_file_get_int64 (GKeyFile *key_file, |
184 | const gchar *group_name, |
185 | const gchar *key, |
186 | GError **error); |
187 | GLIB_AVAILABLE_IN_ALL |
188 | void g_key_file_set_int64 (GKeyFile *key_file, |
189 | const gchar *group_name, |
190 | const gchar *key, |
191 | gint64 value); |
192 | GLIB_AVAILABLE_IN_ALL |
193 | guint64 g_key_file_get_uint64 (GKeyFile *key_file, |
194 | const gchar *group_name, |
195 | const gchar *key, |
196 | GError **error); |
197 | GLIB_AVAILABLE_IN_ALL |
198 | void g_key_file_set_uint64 (GKeyFile *key_file, |
199 | const gchar *group_name, |
200 | const gchar *key, |
201 | guint64 value); |
202 | GLIB_AVAILABLE_IN_ALL |
203 | gdouble g_key_file_get_double (GKeyFile *key_file, |
204 | const gchar *group_name, |
205 | const gchar *key, |
206 | GError **error); |
207 | GLIB_AVAILABLE_IN_ALL |
208 | void g_key_file_set_double (GKeyFile *key_file, |
209 | const gchar *group_name, |
210 | const gchar *key, |
211 | gdouble value); |
212 | GLIB_AVAILABLE_IN_ALL |
213 | gchar **g_key_file_get_string_list (GKeyFile *key_file, |
214 | const gchar *group_name, |
215 | const gchar *key, |
216 | gsize *length, |
217 | GError **error); |
218 | GLIB_AVAILABLE_IN_ALL |
219 | void g_key_file_set_string_list (GKeyFile *key_file, |
220 | const gchar *group_name, |
221 | const gchar *key, |
222 | const gchar * const list[], |
223 | gsize length); |
224 | GLIB_AVAILABLE_IN_ALL |
225 | gchar **g_key_file_get_locale_string_list (GKeyFile *key_file, |
226 | const gchar *group_name, |
227 | const gchar *key, |
228 | const gchar *locale, |
229 | gsize *length, |
230 | GError **error); |
231 | GLIB_AVAILABLE_IN_ALL |
232 | void g_key_file_set_locale_string_list (GKeyFile *key_file, |
233 | const gchar *group_name, |
234 | const gchar *key, |
235 | const gchar *locale, |
236 | const gchar * const list[], |
237 | gsize length); |
238 | GLIB_AVAILABLE_IN_ALL |
239 | gboolean *g_key_file_get_boolean_list (GKeyFile *key_file, |
240 | const gchar *group_name, |
241 | const gchar *key, |
242 | gsize *length, |
243 | GError **error) G_GNUC_MALLOC; |
244 | GLIB_AVAILABLE_IN_ALL |
245 | void g_key_file_set_boolean_list (GKeyFile *key_file, |
246 | const gchar *group_name, |
247 | const gchar *key, |
248 | gboolean list[], |
249 | gsize length); |
250 | GLIB_AVAILABLE_IN_ALL |
251 | gint *g_key_file_get_integer_list (GKeyFile *key_file, |
252 | const gchar *group_name, |
253 | const gchar *key, |
254 | gsize *length, |
255 | GError **error) G_GNUC_MALLOC; |
256 | GLIB_AVAILABLE_IN_ALL |
257 | void g_key_file_set_double_list (GKeyFile *key_file, |
258 | const gchar *group_name, |
259 | const gchar *key, |
260 | gdouble list[], |
261 | gsize length); |
262 | GLIB_AVAILABLE_IN_ALL |
263 | gdouble *g_key_file_get_double_list (GKeyFile *key_file, |
264 | const gchar *group_name, |
265 | const gchar *key, |
266 | gsize *length, |
267 | GError **error) G_GNUC_MALLOC; |
268 | GLIB_AVAILABLE_IN_ALL |
269 | void g_key_file_set_integer_list (GKeyFile *key_file, |
270 | const gchar *group_name, |
271 | const gchar *key, |
272 | gint list[], |
273 | gsize length); |
274 | GLIB_AVAILABLE_IN_ALL |
275 | gboolean (GKeyFile *key_file, |
276 | const gchar *group_name, |
277 | const gchar *key, |
278 | const gchar *, |
279 | GError **error); |
280 | GLIB_AVAILABLE_IN_ALL |
281 | gchar * (GKeyFile *key_file, |
282 | const gchar *group_name, |
283 | const gchar *key, |
284 | GError **error) G_GNUC_MALLOC; |
285 | |
286 | GLIB_AVAILABLE_IN_ALL |
287 | gboolean (GKeyFile *key_file, |
288 | const gchar *group_name, |
289 | const gchar *key, |
290 | GError **error); |
291 | GLIB_AVAILABLE_IN_ALL |
292 | gboolean g_key_file_remove_key (GKeyFile *key_file, |
293 | const gchar *group_name, |
294 | const gchar *key, |
295 | GError **error); |
296 | GLIB_AVAILABLE_IN_ALL |
297 | gboolean g_key_file_remove_group (GKeyFile *key_file, |
298 | const gchar *group_name, |
299 | GError **error); |
300 | |
301 | /* Defines for handling freedesktop.org Desktop files */ |
302 | #define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry" |
303 | |
304 | #define G_KEY_FILE_DESKTOP_KEY_TYPE "Type" |
305 | #define G_KEY_FILE_DESKTOP_KEY_VERSION "Version" |
306 | #define G_KEY_FILE_DESKTOP_KEY_NAME "Name" |
307 | #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName" |
308 | #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay" |
309 | #define "Comment" |
310 | #define G_KEY_FILE_DESKTOP_KEY_ICON "Icon" |
311 | #define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden" |
312 | #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn" |
313 | #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn" |
314 | #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec" |
315 | #define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec" |
316 | #define G_KEY_FILE_DESKTOP_KEY_PATH "Path" |
317 | #define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal" |
318 | #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType" |
319 | #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories" |
320 | #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify" |
321 | #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass" |
322 | #define G_KEY_FILE_DESKTOP_KEY_URL "URL" |
323 | #define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable" |
324 | #define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions" |
325 | |
326 | #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application" |
327 | #define G_KEY_FILE_DESKTOP_TYPE_LINK "Link" |
328 | #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory" |
329 | |
330 | G_END_DECLS |
331 | |
332 | #endif /* __G_KEY_FILE_H__ */ |
333 | |