Implement the Desktop Action specification
[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  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  *   Boston, MA 02111-1307, USA.
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/gerror.h>
31
32 G_BEGIN_DECLS
33
34 typedef enum
35 {
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
42 } GKeyFileError;
43
44 #define G_KEY_FILE_ERROR g_key_file_error_quark()
45
46 GLIB_AVAILABLE_IN_ALL
47 GQuark g_key_file_error_quark (void);
48
49 typedef struct _GKeyFile GKeyFile;
50
51 typedef enum
52 {
53   G_KEY_FILE_NONE              = 0,
54   G_KEY_FILE_KEEP_COMMENTS     = 1 << 0,
55   G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
56 } GKeyFileFlags;
57
58 GLIB_AVAILABLE_IN_ALL
59 GKeyFile *g_key_file_new                    (void);
60 GLIB_AVAILABLE_IN_ALL
61 GKeyFile *g_key_file_ref                    (GKeyFile             *key_file);
62 GLIB_AVAILABLE_IN_ALL
63 void      g_key_file_unref                  (GKeyFile             *key_file);
64 GLIB_AVAILABLE_IN_ALL
65 void      g_key_file_free                   (GKeyFile             *key_file);
66 GLIB_AVAILABLE_IN_ALL
67 void      g_key_file_set_list_separator     (GKeyFile             *key_file,
68                                              gchar                 separator);
69 GLIB_AVAILABLE_IN_ALL
70 gboolean  g_key_file_load_from_file         (GKeyFile             *key_file,
71                                              const gchar          *file,
72                                              GKeyFileFlags         flags,
73                                              GError              **error);
74 GLIB_AVAILABLE_IN_ALL
75 gboolean  g_key_file_load_from_data         (GKeyFile             *key_file,
76                                              const gchar          *data,
77                                              gsize                 length,
78                                              GKeyFileFlags         flags,
79                                              GError              **error);
80 GLIB_AVAILABLE_IN_ALL
81 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
82                                              const gchar          *file,
83                                              const gchar         **search_dirs,
84                                              gchar               **full_path,
85                                              GKeyFileFlags         flags,
86                                              GError              **error);
87 GLIB_AVAILABLE_IN_ALL
88 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
89                                              const gchar          *file,
90                                              gchar               **full_path,
91                                              GKeyFileFlags         flags,
92                                              GError              **error);
93 GLIB_AVAILABLE_IN_ALL
94 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
95                                              gsize                *length,
96                                              GError              **error) G_GNUC_MALLOC;
97 GLIB_AVAILABLE_IN_ALL
98 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
99 GLIB_AVAILABLE_IN_ALL
100 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
101                                              gsize                *length) G_GNUC_MALLOC;
102 GLIB_AVAILABLE_IN_ALL
103 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
104                                              const gchar          *group_name,
105                                              gsize                *length,
106                                              GError              **error) G_GNUC_MALLOC;
107 GLIB_AVAILABLE_IN_ALL
108 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
109                                              const gchar          *group_name);
110 GLIB_AVAILABLE_IN_ALL
111 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
112                                              const gchar          *group_name,
113                                              const gchar          *key,
114                                              GError              **error);
115 GLIB_AVAILABLE_IN_ALL
116 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
117                                              const gchar          *group_name,
118                                              const gchar          *key,
119                                              GError              **error) G_GNUC_MALLOC;
120 GLIB_AVAILABLE_IN_ALL
121 void      g_key_file_set_value              (GKeyFile             *key_file,
122                                              const gchar          *group_name,
123                                              const gchar          *key,
124                                              const gchar          *value);
125 GLIB_AVAILABLE_IN_ALL
126 gchar    *g_key_file_get_string             (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_string             (GKeyFile             *key_file,
132                                              const gchar          *group_name,
133                                              const gchar          *key,
134                                              const gchar          *string);
135 GLIB_AVAILABLE_IN_ALL
136 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
137                                              const gchar          *group_name,
138                                              const gchar          *key,
139                                              const gchar          *locale,
140                                              GError              **error) G_GNUC_MALLOC;
141 GLIB_AVAILABLE_IN_ALL
142 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
143                                              const gchar          *group_name,
144                                              const gchar          *key,
145                                              const gchar          *locale,
146                                              const gchar          *string);
147 GLIB_AVAILABLE_IN_ALL
148 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
149                                              const gchar          *group_name,
150                                              const gchar          *key,
151                                              GError              **error);
152 GLIB_AVAILABLE_IN_ALL
153 void      g_key_file_set_boolean            (GKeyFile             *key_file,
154                                              const gchar          *group_name,
155                                              const gchar          *key,
156                                              gboolean              value);
157 GLIB_AVAILABLE_IN_ALL
158 gint      g_key_file_get_integer            (GKeyFile             *key_file,
159                                              const gchar          *group_name,
160                                              const gchar          *key,
161                                              GError              **error);
162 GLIB_AVAILABLE_IN_ALL
163 void      g_key_file_set_integer            (GKeyFile             *key_file,
164                                              const gchar          *group_name,
165                                              const gchar          *key,
166                                              gint                  value);
167 GLIB_AVAILABLE_IN_ALL
168 gint64    g_key_file_get_int64              (GKeyFile             *key_file,
169                                              const gchar          *group_name,
170                                              const gchar          *key,
171                                              GError              **error);
172 GLIB_AVAILABLE_IN_ALL
173 void      g_key_file_set_int64              (GKeyFile             *key_file,
174                                              const gchar          *group_name,
175                                              const gchar          *key,
176                                              gint64                value);
177 GLIB_AVAILABLE_IN_ALL
178 guint64   g_key_file_get_uint64             (GKeyFile             *key_file,
179                                              const gchar          *group_name,
180                                              const gchar          *key,
181                                              GError              **error);
182 GLIB_AVAILABLE_IN_ALL
183 void      g_key_file_set_uint64             (GKeyFile             *key_file,
184                                              const gchar          *group_name,
185                                              const gchar          *key,
186                                              guint64               value);
187 GLIB_AVAILABLE_IN_ALL
188 gdouble   g_key_file_get_double             (GKeyFile             *key_file,
189                                              const gchar          *group_name,
190                                              const gchar          *key,
191                                              GError              **error);
192 GLIB_AVAILABLE_IN_ALL
193 void      g_key_file_set_double             (GKeyFile             *key_file,
194                                              const gchar          *group_name,
195                                              const gchar          *key,
196                                              gdouble               value);
197 GLIB_AVAILABLE_IN_ALL
198 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
199                                              const gchar          *group_name,
200                                              const gchar          *key,
201                                              gsize                *length,
202                                              GError              **error) G_GNUC_MALLOC;
203 GLIB_AVAILABLE_IN_ALL
204 void      g_key_file_set_string_list        (GKeyFile             *key_file,
205                                              const gchar          *group_name,
206                                              const gchar          *key,
207                                              const gchar * const   list[],
208                                              gsize                 length);
209 GLIB_AVAILABLE_IN_ALL
210 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
211                                              const gchar          *group_name,
212                                              const gchar          *key,
213                                              const gchar          *locale,
214                                              gsize                *length,
215                                              GError              **error) G_GNUC_MALLOC;
216 GLIB_AVAILABLE_IN_ALL
217 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
218                                              const gchar          *group_name,
219                                              const gchar          *key,
220                                              const gchar          *locale,
221                                              const gchar * const   list[],
222                                              gsize                 length);
223 GLIB_AVAILABLE_IN_ALL
224 gboolean *g_key_file_get_boolean_list       (GKeyFile             *key_file,
225                                              const gchar          *group_name,
226                                              const gchar          *key,
227                                              gsize                *length,
228                                              GError              **error) G_GNUC_MALLOC;
229 GLIB_AVAILABLE_IN_ALL
230 void      g_key_file_set_boolean_list       (GKeyFile             *key_file,
231                                              const gchar          *group_name,
232                                              const gchar          *key,
233                                              gboolean              list[],
234                                              gsize                 length);
235 GLIB_AVAILABLE_IN_ALL
236 gint     *g_key_file_get_integer_list       (GKeyFile             *key_file,
237                                              const gchar          *group_name,
238                                              const gchar          *key,
239                                              gsize                *length,
240                                              GError              **error) G_GNUC_MALLOC;
241 GLIB_AVAILABLE_IN_ALL
242 void      g_key_file_set_double_list        (GKeyFile             *key_file,
243                                              const gchar          *group_name,
244                                              const gchar          *key,
245                                              gdouble               list[],
246                                              gsize                 length);
247 GLIB_AVAILABLE_IN_ALL
248 gdouble  *g_key_file_get_double_list        (GKeyFile             *key_file,
249                                              const gchar          *group_name,
250                                              const gchar          *key,
251                                              gsize                *length,
252                                              GError              **error) G_GNUC_MALLOC;
253 GLIB_AVAILABLE_IN_ALL
254 void      g_key_file_set_integer_list       (GKeyFile             *key_file,
255                                              const gchar          *group_name,
256                                              const gchar          *key,
257                                              gint                  list[],
258                                              gsize                 length);
259 GLIB_AVAILABLE_IN_ALL
260 gboolean  g_key_file_set_comment            (GKeyFile             *key_file,
261                                              const gchar          *group_name,
262                                              const gchar          *key,
263                                              const gchar          *comment,
264                                              GError              **error);
265 GLIB_AVAILABLE_IN_ALL
266 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
267                                              const gchar          *group_name,
268                                              const gchar          *key,
269                                              GError              **error) G_GNUC_MALLOC;
270
271 GLIB_AVAILABLE_IN_ALL
272 gboolean  g_key_file_remove_comment         (GKeyFile             *key_file,
273                                              const gchar          *group_name,
274                                              const gchar          *key,
275                                              GError              **error);
276 GLIB_AVAILABLE_IN_ALL
277 gboolean  g_key_file_remove_key             (GKeyFile             *key_file,
278                                              const gchar          *group_name,
279                                              const gchar          *key,
280                                              GError              **error);
281 GLIB_AVAILABLE_IN_ALL
282 gboolean  g_key_file_remove_group           (GKeyFile             *key_file,
283                                              const gchar          *group_name,
284                                              GError              **error);
285
286 /* Defines for handling freedesktop.org Desktop files */
287 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
288
289 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
290 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
291 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
292 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
293 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
294 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
295 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
296 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
297 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
298 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
299 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
300 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
301 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
302 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
303 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
304 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
305 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
306 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
307 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
308 #define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
309 #define G_KEY_FILE_DESKTOP_KEY_ACTIONS          "Actions"
310
311 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
312 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
313 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
314
315 G_END_DECLS
316
317 #endif /* __G_KEY_FILE_H__ */