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