1 /* gkeyfile.h - desktop entry file parser
3 * Copyright 2004 Red Hat, Inc.
5 * Ray Strode <halfline@hawaii.rr.com>
7 * GLib is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * GLib 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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with GLib; see the file COPYING.LIB. If not,
19 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef __G_KEY_FILE_H__
24 #define __G_KEY_FILE_H__
26 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
27 #error "Only <glib.h> can be included directly."
30 #include <glib/gerror.h>
36 G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
37 G_KEY_FILE_ERROR_PARSE,
38 G_KEY_FILE_ERROR_NOT_FOUND,
39 G_KEY_FILE_ERROR_KEY_NOT_FOUND,
40 G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
41 G_KEY_FILE_ERROR_INVALID_VALUE
44 #define G_KEY_FILE_ERROR g_key_file_error_quark()
47 GQuark g_key_file_error_quark (void);
49 typedef struct _GKeyFile GKeyFile;
54 G_KEY_FILE_KEEP_COMMENTS = 1 << 0,
55 G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
59 GKeyFile *g_key_file_new (void);
61 GKeyFile *g_key_file_ref (GKeyFile *key_file);
63 void g_key_file_unref (GKeyFile *key_file);
65 void g_key_file_free (GKeyFile *key_file);
67 void g_key_file_set_list_separator (GKeyFile *key_file,
70 gboolean g_key_file_load_from_file (GKeyFile *key_file,
75 gboolean g_key_file_load_from_data (GKeyFile *key_file,
81 gboolean g_key_file_load_from_dirs (GKeyFile *key_file,
83 const gchar **search_dirs,
88 gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file,
94 gchar *g_key_file_to_data (GKeyFile *key_file,
96 GError **error) G_GNUC_MALLOC;
97 GLIB_AVAILABLE_IN_2_40
98 gboolean g_key_file_save_to_file (GKeyFile *key_file,
99 const gchar *filename,
101 GLIB_AVAILABLE_IN_ALL
102 gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC;
103 GLIB_AVAILABLE_IN_ALL
104 gchar **g_key_file_get_groups (GKeyFile *key_file,
105 gsize *length) G_GNUC_MALLOC;
106 GLIB_AVAILABLE_IN_ALL
107 gchar **g_key_file_get_keys (GKeyFile *key_file,
108 const gchar *group_name,
110 GError **error) G_GNUC_MALLOC;
111 GLIB_AVAILABLE_IN_ALL
112 gboolean g_key_file_has_group (GKeyFile *key_file,
113 const gchar *group_name);
114 GLIB_AVAILABLE_IN_ALL
115 gboolean g_key_file_has_key (GKeyFile *key_file,
116 const gchar *group_name,
119 GLIB_AVAILABLE_IN_ALL
120 gchar *g_key_file_get_value (GKeyFile *key_file,
121 const gchar *group_name,
123 GError **error) G_GNUC_MALLOC;
124 GLIB_AVAILABLE_IN_ALL
125 void g_key_file_set_value (GKeyFile *key_file,
126 const gchar *group_name,
129 GLIB_AVAILABLE_IN_ALL
130 gchar *g_key_file_get_string (GKeyFile *key_file,
131 const gchar *group_name,
133 GError **error) G_GNUC_MALLOC;
134 GLIB_AVAILABLE_IN_ALL
135 void g_key_file_set_string (GKeyFile *key_file,
136 const gchar *group_name,
138 const gchar *string);
139 GLIB_AVAILABLE_IN_ALL
140 gchar *g_key_file_get_locale_string (GKeyFile *key_file,
141 const gchar *group_name,
144 GError **error) G_GNUC_MALLOC;
145 GLIB_AVAILABLE_IN_ALL
146 void g_key_file_set_locale_string (GKeyFile *key_file,
147 const gchar *group_name,
150 const gchar *string);
151 GLIB_AVAILABLE_IN_ALL
152 gboolean g_key_file_get_boolean (GKeyFile *key_file,
153 const gchar *group_name,
156 GLIB_AVAILABLE_IN_ALL
157 void g_key_file_set_boolean (GKeyFile *key_file,
158 const gchar *group_name,
161 GLIB_AVAILABLE_IN_ALL
162 gint g_key_file_get_integer (GKeyFile *key_file,
163 const gchar *group_name,
166 GLIB_AVAILABLE_IN_ALL
167 void g_key_file_set_integer (GKeyFile *key_file,
168 const gchar *group_name,
171 GLIB_AVAILABLE_IN_ALL
172 gint64 g_key_file_get_int64 (GKeyFile *key_file,
173 const gchar *group_name,
176 GLIB_AVAILABLE_IN_ALL
177 void g_key_file_set_int64 (GKeyFile *key_file,
178 const gchar *group_name,
181 GLIB_AVAILABLE_IN_ALL
182 guint64 g_key_file_get_uint64 (GKeyFile *key_file,
183 const gchar *group_name,
186 GLIB_AVAILABLE_IN_ALL
187 void g_key_file_set_uint64 (GKeyFile *key_file,
188 const gchar *group_name,
191 GLIB_AVAILABLE_IN_ALL
192 gdouble g_key_file_get_double (GKeyFile *key_file,
193 const gchar *group_name,
196 GLIB_AVAILABLE_IN_ALL
197 void g_key_file_set_double (GKeyFile *key_file,
198 const gchar *group_name,
201 GLIB_AVAILABLE_IN_ALL
202 gchar **g_key_file_get_string_list (GKeyFile *key_file,
203 const gchar *group_name,
206 GError **error) G_GNUC_MALLOC;
207 GLIB_AVAILABLE_IN_ALL
208 void g_key_file_set_string_list (GKeyFile *key_file,
209 const gchar *group_name,
211 const gchar * const list[],
213 GLIB_AVAILABLE_IN_ALL
214 gchar **g_key_file_get_locale_string_list (GKeyFile *key_file,
215 const gchar *group_name,
219 GError **error) G_GNUC_MALLOC;
220 GLIB_AVAILABLE_IN_ALL
221 void g_key_file_set_locale_string_list (GKeyFile *key_file,
222 const gchar *group_name,
225 const gchar * const list[],
227 GLIB_AVAILABLE_IN_ALL
228 gboolean *g_key_file_get_boolean_list (GKeyFile *key_file,
229 const gchar *group_name,
232 GError **error) G_GNUC_MALLOC;
233 GLIB_AVAILABLE_IN_ALL
234 void g_key_file_set_boolean_list (GKeyFile *key_file,
235 const gchar *group_name,
239 GLIB_AVAILABLE_IN_ALL
240 gint *g_key_file_get_integer_list (GKeyFile *key_file,
241 const gchar *group_name,
244 GError **error) G_GNUC_MALLOC;
245 GLIB_AVAILABLE_IN_ALL
246 void g_key_file_set_double_list (GKeyFile *key_file,
247 const gchar *group_name,
251 GLIB_AVAILABLE_IN_ALL
252 gdouble *g_key_file_get_double_list (GKeyFile *key_file,
253 const gchar *group_name,
256 GError **error) G_GNUC_MALLOC;
257 GLIB_AVAILABLE_IN_ALL
258 void g_key_file_set_integer_list (GKeyFile *key_file,
259 const gchar *group_name,
263 GLIB_AVAILABLE_IN_ALL
264 gboolean g_key_file_set_comment (GKeyFile *key_file,
265 const gchar *group_name,
267 const gchar *comment,
269 GLIB_AVAILABLE_IN_ALL
270 gchar *g_key_file_get_comment (GKeyFile *key_file,
271 const gchar *group_name,
273 GError **error) G_GNUC_MALLOC;
275 GLIB_AVAILABLE_IN_ALL
276 gboolean g_key_file_remove_comment (GKeyFile *key_file,
277 const gchar *group_name,
280 GLIB_AVAILABLE_IN_ALL
281 gboolean g_key_file_remove_key (GKeyFile *key_file,
282 const gchar *group_name,
285 GLIB_AVAILABLE_IN_ALL
286 gboolean g_key_file_remove_group (GKeyFile *key_file,
287 const gchar *group_name,
290 /* Defines for handling freedesktop.org Desktop files */
291 #define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry"
293 #define G_KEY_FILE_DESKTOP_KEY_TYPE "Type"
294 #define G_KEY_FILE_DESKTOP_KEY_VERSION "Version"
295 #define G_KEY_FILE_DESKTOP_KEY_NAME "Name"
296 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName"
297 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay"
298 #define G_KEY_FILE_DESKTOP_KEY_COMMENT "Comment"
299 #define G_KEY_FILE_DESKTOP_KEY_ICON "Icon"
300 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden"
301 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn"
302 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn"
303 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec"
304 #define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec"
305 #define G_KEY_FILE_DESKTOP_KEY_PATH "Path"
306 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal"
307 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType"
308 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories"
309 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify"
310 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
311 #define G_KEY_FILE_DESKTOP_KEY_URL "URL"
312 #define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
313 #define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions"
315 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application"
316 #define G_KEY_FILE_DESKTOP_TYPE_LINK "Link"
317 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory"
321 #endif /* __G_KEY_FILE_H__ */