Tizen 2.1 base
[platform/upstream/glib2.0.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 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24 #error "Only <glib.h> can be included directly."
25 #endif
26
27 #ifndef __G_KEY_FILE_H__
28 #define __G_KEY_FILE_H__
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 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 GKeyFile *g_key_file_new                    (void);
58 GKeyFile *g_key_file_ref                    (GKeyFile             *key_file);
59 void      g_key_file_unref                  (GKeyFile             *key_file);
60 void      g_key_file_free                   (GKeyFile             *key_file);
61 void      g_key_file_set_list_separator     (GKeyFile             *key_file,
62                                              gchar                 separator);
63 gboolean  g_key_file_load_from_file         (GKeyFile             *key_file,
64                                              const gchar          *file,
65                                              GKeyFileFlags         flags,
66                                              GError              **error);
67 gboolean  g_key_file_load_from_data         (GKeyFile             *key_file,
68                                              const gchar          *data,
69                                              gsize                 length,
70                                              GKeyFileFlags         flags,
71                                              GError              **error);
72 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
73                                              const gchar          *file,
74                                              const gchar         **search_dirs,
75                                              gchar               **full_path,
76                                              GKeyFileFlags         flags,
77                                              GError              **error);
78 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
79                                              const gchar          *file,
80                                              gchar               **full_path,
81                                              GKeyFileFlags         flags,
82                                              GError              **error);
83 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
84                                              gsize                *length,
85                                              GError              **error) G_GNUC_MALLOC;
86 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
87 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
88                                              gsize                *length) G_GNUC_MALLOC;
89 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
90                                              const gchar          *group_name,
91                                              gsize                *length,
92                                              GError              **error) G_GNUC_MALLOC;
93 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
94                                              const gchar          *group_name);
95 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
96                                              const gchar          *group_name,
97                                              const gchar          *key,
98                                              GError              **error);
99 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
100                                              const gchar          *group_name,
101                                              const gchar          *key,
102                                              GError              **error) G_GNUC_MALLOC;
103 void      g_key_file_set_value              (GKeyFile             *key_file,
104                                              const gchar          *group_name,
105                                              const gchar          *key,
106                                              const gchar          *value);
107 gchar    *g_key_file_get_string             (GKeyFile             *key_file,
108                                              const gchar          *group_name,
109                                              const gchar          *key,
110                                              GError              **error) G_GNUC_MALLOC;
111 void      g_key_file_set_string             (GKeyFile             *key_file,
112                                              const gchar          *group_name,
113                                              const gchar          *key,
114                                              const gchar          *string);
115 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
116                                              const gchar          *group_name,
117                                              const gchar          *key,
118                                              const gchar          *locale,
119                                              GError              **error) G_GNUC_MALLOC;
120 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
121                                              const gchar          *group_name,
122                                              const gchar          *key,
123                                              const gchar          *locale,
124                                              const gchar          *string);
125 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
126                                              const gchar          *group_name,
127                                              const gchar          *key,
128                                              GError              **error);
129 void      g_key_file_set_boolean            (GKeyFile             *key_file,
130                                              const gchar          *group_name,
131                                              const gchar          *key,
132                                              gboolean              value);
133 gint      g_key_file_get_integer            (GKeyFile             *key_file,
134                                              const gchar          *group_name,
135                                              const gchar          *key,
136                                              GError              **error);
137 void      g_key_file_set_integer            (GKeyFile             *key_file,
138                                              const gchar          *group_name,
139                                              const gchar          *key,
140                                              gint                  value);
141 gint64    g_key_file_get_int64              (GKeyFile             *key_file,
142                                              const gchar          *group_name,
143                                              const gchar          *key,
144                                              GError              **error);
145 void      g_key_file_set_int64              (GKeyFile             *key_file,
146                                              const gchar          *group_name,
147                                              const gchar          *key,
148                                              gint64                value);
149 guint64   g_key_file_get_uint64             (GKeyFile             *key_file,
150                                              const gchar          *group_name,
151                                              const gchar          *key,
152                                              GError              **error);
153 void      g_key_file_set_uint64             (GKeyFile             *key_file,
154                                              const gchar          *group_name,
155                                              const gchar          *key,
156                                              guint64               value);
157 gdouble   g_key_file_get_double             (GKeyFile             *key_file,
158                                              const gchar          *group_name,
159                                              const gchar          *key,
160                                              GError              **error);
161 void      g_key_file_set_double             (GKeyFile             *key_file,
162                                              const gchar          *group_name,
163                                              const gchar          *key,
164                                              gdouble               value);
165 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
166                                              const gchar          *group_name,
167                                              const gchar          *key,
168                                              gsize                *length,
169                                              GError              **error) G_GNUC_MALLOC;
170 void      g_key_file_set_string_list        (GKeyFile             *key_file,
171                                              const gchar          *group_name,
172                                              const gchar          *key,
173                                              const gchar * const   list[],
174                                              gsize                 length);
175 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
176                                              const gchar          *group_name,
177                                              const gchar          *key,
178                                              const gchar          *locale,
179                                              gsize                *length,
180                                              GError              **error) G_GNUC_MALLOC;
181 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
182                                              const gchar          *group_name,
183                                              const gchar          *key,
184                                              const gchar          *locale,
185                                              const gchar * const   list[],
186                                              gsize                 length);
187 gboolean *g_key_file_get_boolean_list       (GKeyFile             *key_file,
188                                              const gchar          *group_name,
189                                              const gchar          *key,
190                                              gsize                *length,
191                                              GError              **error) G_GNUC_MALLOC;
192 void      g_key_file_set_boolean_list       (GKeyFile             *key_file,
193                                              const gchar          *group_name,
194                                              const gchar          *key,
195                                              gboolean              list[],
196                                              gsize                 length);
197 gint     *g_key_file_get_integer_list       (GKeyFile             *key_file,
198                                              const gchar          *group_name,
199                                              const gchar          *key,
200                                              gsize                *length,
201                                              GError              **error) G_GNUC_MALLOC;
202 void      g_key_file_set_double_list        (GKeyFile             *key_file,
203                                              const gchar          *group_name,
204                                              const gchar          *key,
205                                              gdouble               list[],
206                                              gsize                 length);
207 gdouble  *g_key_file_get_double_list        (GKeyFile             *key_file,
208                                              const gchar          *group_name,
209                                              const gchar          *key,
210                                              gsize                *length,
211                                              GError              **error) G_GNUC_MALLOC;
212 void      g_key_file_set_integer_list       (GKeyFile             *key_file,
213                                              const gchar          *group_name,
214                                              const gchar          *key,
215                                              gint                  list[],
216                                              gsize                 length);
217 gboolean  g_key_file_set_comment            (GKeyFile             *key_file,
218                                              const gchar          *group_name,
219                                              const gchar          *key,
220                                              const gchar          *comment,
221                                              GError              **error);
222 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
223                                              const gchar          *group_name,
224                                              const gchar          *key,
225                                              GError              **error) G_GNUC_MALLOC;
226
227 gboolean  g_key_file_remove_comment         (GKeyFile             *key_file,
228                                              const gchar          *group_name,
229                                              const gchar          *key,
230                                              GError              **error);
231 gboolean  g_key_file_remove_key             (GKeyFile             *key_file,
232                                              const gchar          *group_name,
233                                              const gchar          *key,
234                                              GError              **error);
235 gboolean  g_key_file_remove_group           (GKeyFile             *key_file,
236                                              const gchar          *group_name,
237                                              GError              **error);
238
239 /* Defines for handling freedesktop.org Desktop files */
240 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
241
242 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
243 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
244 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
245 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
246 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
247 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
248 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
249 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
250 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
251 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
252 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
253 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
254 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
255 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
256 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
257 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
258 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
259 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
260 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
261
262 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
263 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
264 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
265
266 G_END_DECLS
267
268 #endif /* __G_KEY_FILE_H__ */