cleanup
[platform/upstream/glib.git] / glib / gkeyfile.h
1 /* gkeyfile.h - desktop entry file parser
2  *
3  *  Copyright 2004 Red Hat, Inc.
4  *
5  *  Ray Strode <halfline@hawaii.rr.com>
6  *
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.
11  *
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.
16  *
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  * see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef __G_KEY_FILE_H__
23 #define __G_KEY_FILE_H__
24
25 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
26 #error "Only <glib.h> can be included directly."
27 #endif
28
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   G_KEY_FILE_KEEP_COMMENTS     = 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_ALL
80 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
81                                              const gchar          *file,
82                                              const gchar         **search_dirs,
83                                              gchar               **full_path,
84                                              GKeyFileFlags         flags,
85                                              GError              **error);
86 GLIB_AVAILABLE_IN_ALL
87 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
88                                              const gchar          *file,
89                                              gchar               **full_path,
90                                              GKeyFileFlags         flags,
91                                              GError              **error);
92 GLIB_AVAILABLE_IN_ALL
93 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
94                                              gsize                *length,
95                                              GError              **error) G_GNUC_MALLOC;
96 GLIB_AVAILABLE_IN_2_40
97 gboolean  g_key_file_save_to_file           (GKeyFile             *key_file,
98                                              const gchar          *filename,
99                                              GError              **error);
100 GLIB_AVAILABLE_IN_ALL
101 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
102 GLIB_AVAILABLE_IN_ALL
103 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
104                                              gsize                *length) G_GNUC_MALLOC;
105 GLIB_AVAILABLE_IN_ALL
106 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
107                                              const gchar          *group_name,
108                                              gsize                *length,
109                                              GError              **error) G_GNUC_MALLOC;
110 GLIB_AVAILABLE_IN_ALL
111 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
112                                              const gchar          *group_name);
113 GLIB_AVAILABLE_IN_ALL
114 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
115                                              const gchar          *group_name,
116                                              const gchar          *key,
117                                              GError              **error);
118 GLIB_AVAILABLE_IN_ALL
119 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
120                                              const gchar          *group_name,
121                                              const gchar          *key,
122                                              GError              **error) G_GNUC_MALLOC;
123 GLIB_AVAILABLE_IN_ALL
124 void      g_key_file_set_value              (GKeyFile             *key_file,
125                                              const gchar          *group_name,
126                                              const gchar          *key,
127                                              const gchar          *value);
128 GLIB_AVAILABLE_IN_ALL
129 gchar    *g_key_file_get_string             (GKeyFile             *key_file,
130                                              const gchar          *group_name,
131                                              const gchar          *key,
132                                              GError              **error) G_GNUC_MALLOC;
133 GLIB_AVAILABLE_IN_ALL
134 void      g_key_file_set_string             (GKeyFile             *key_file,
135                                              const gchar          *group_name,
136                                              const gchar          *key,
137                                              const gchar          *string);
138 GLIB_AVAILABLE_IN_ALL
139 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
140                                              const gchar          *group_name,
141                                              const gchar          *key,
142                                              const gchar          *locale,
143                                              GError              **error) G_GNUC_MALLOC;
144 GLIB_AVAILABLE_IN_ALL
145 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
146                                              const gchar          *group_name,
147                                              const gchar          *key,
148                                              const gchar          *locale,
149                                              const gchar          *string);
150 GLIB_AVAILABLE_IN_ALL
151 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
152                                              const gchar          *group_name,
153                                              const gchar          *key,
154                                              GError              **error);
155 GLIB_AVAILABLE_IN_ALL
156 void      g_key_file_set_boolean            (GKeyFile             *key_file,
157                                              const gchar          *group_name,
158                                              const gchar          *key,
159                                              gboolean              value);
160 GLIB_AVAILABLE_IN_ALL
161 gint      g_key_file_get_integer            (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_integer            (GKeyFile             *key_file,
167                                              const gchar          *group_name,
168                                              const gchar          *key,
169                                              gint                  value);
170 GLIB_AVAILABLE_IN_ALL
171 gint64    g_key_file_get_int64              (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_int64              (GKeyFile             *key_file,
177                                              const gchar          *group_name,
178                                              const gchar          *key,
179                                              gint64                value);
180 GLIB_AVAILABLE_IN_ALL
181 guint64   g_key_file_get_uint64             (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_uint64             (GKeyFile             *key_file,
187                                              const gchar          *group_name,
188                                              const gchar          *key,
189                                              guint64               value);
190 GLIB_AVAILABLE_IN_ALL
191 gdouble   g_key_file_get_double             (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_double             (GKeyFile             *key_file,
197                                              const gchar          *group_name,
198                                              const gchar          *key,
199                                              gdouble               value);
200 GLIB_AVAILABLE_IN_ALL
201 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
202                                              const gchar          *group_name,
203                                              const gchar          *key,
204                                              gsize                *length,
205                                              GError              **error) G_GNUC_MALLOC;
206 GLIB_AVAILABLE_IN_ALL
207 void      g_key_file_set_string_list        (GKeyFile             *key_file,
208                                              const gchar          *group_name,
209                                              const gchar          *key,
210                                              const gchar * const   list[],
211                                              gsize                 length);
212 GLIB_AVAILABLE_IN_ALL
213 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
214                                              const gchar          *group_name,
215                                              const gchar          *key,
216                                              const gchar          *locale,
217                                              gsize                *length,
218                                              GError              **error) G_GNUC_MALLOC;
219 GLIB_AVAILABLE_IN_ALL
220 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
221                                              const gchar          *group_name,
222                                              const gchar          *key,
223                                              const gchar          *locale,
224                                              const gchar * const   list[],
225                                              gsize                 length);
226 GLIB_AVAILABLE_IN_ALL
227 gboolean *g_key_file_get_boolean_list       (GKeyFile             *key_file,
228                                              const gchar          *group_name,
229                                              const gchar          *key,
230                                              gsize                *length,
231                                              GError              **error) G_GNUC_MALLOC;
232 GLIB_AVAILABLE_IN_ALL
233 void      g_key_file_set_boolean_list       (GKeyFile             *key_file,
234                                              const gchar          *group_name,
235                                              const gchar          *key,
236                                              gboolean              list[],
237                                              gsize                 length);
238 GLIB_AVAILABLE_IN_ALL
239 gint     *g_key_file_get_integer_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_double_list        (GKeyFile             *key_file,
246                                              const gchar          *group_name,
247                                              const gchar          *key,
248                                              gdouble               list[],
249                                              gsize                 length);
250 GLIB_AVAILABLE_IN_ALL
251 gdouble  *g_key_file_get_double_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_integer_list       (GKeyFile             *key_file,
258                                              const gchar          *group_name,
259                                              const gchar          *key,
260                                              gint                  list[],
261                                              gsize                 length);
262 GLIB_AVAILABLE_IN_ALL
263 gboolean  g_key_file_set_comment            (GKeyFile             *key_file,
264                                              const gchar          *group_name,
265                                              const gchar          *key,
266                                              const gchar          *comment,
267                                              GError              **error);
268 GLIB_AVAILABLE_IN_ALL
269 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
270                                              const gchar          *group_name,
271                                              const gchar          *key,
272                                              GError              **error) G_GNUC_MALLOC;
273
274 GLIB_AVAILABLE_IN_ALL
275 gboolean  g_key_file_remove_comment         (GKeyFile             *key_file,
276                                              const gchar          *group_name,
277                                              const gchar          *key,
278                                              GError              **error);
279 GLIB_AVAILABLE_IN_ALL
280 gboolean  g_key_file_remove_key             (GKeyFile             *key_file,
281                                              const gchar          *group_name,
282                                              const gchar          *key,
283                                              GError              **error);
284 GLIB_AVAILABLE_IN_ALL
285 gboolean  g_key_file_remove_group           (GKeyFile             *key_file,
286                                              const gchar          *group_name,
287                                              GError              **error);
288
289 /* Defines for handling freedesktop.org Desktop files */
290 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
291
292 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
293 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
294 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
295 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
296 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
297 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
298 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
299 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
300 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
301 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
302 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
303 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
304 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
305 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
306 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
307 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
308 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
309 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
310 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
311 #define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
312 #define G_KEY_FILE_DESKTOP_KEY_ACTIONS          "Actions"
313
314 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
315 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
316 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
317
318 G_END_DECLS
319
320 #endif /* __G_KEY_FILE_H__ */