more atomic ops pointer cast fixes. this time it'll work with atomic op
[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 #include <glib/gerror.h>
27
28 G_BEGIN_DECLS
29
30 typedef enum
31 {
32   G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
33   G_KEY_FILE_ERROR_PARSE,
34   G_KEY_FILE_ERROR_NOT_FOUND,
35   G_KEY_FILE_ERROR_KEY_NOT_FOUND,
36   G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
37   G_KEY_FILE_ERROR_INVALID_VALUE
38 } GKeyFileError;
39
40 #define G_KEY_FILE_ERROR g_key_file_error_quark()
41
42 GQuark g_key_file_error_quark (void);
43
44 typedef struct _GKeyFile GKeyFile;
45
46 typedef enum
47 {
48   G_KEY_FILE_NONE              = 0,
49   G_KEY_FILE_KEEP_COMMENTS     = 1 << 0,
50   G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
51 } GKeyFileFlags;
52
53 GKeyFile *g_key_file_new                    (void);
54 void      g_key_file_free                   (GKeyFile             *key_file);
55 void      g_key_file_set_list_separator     (GKeyFile             *key_file,
56                                              gchar                 separator);
57 gboolean  g_key_file_load_from_file         (GKeyFile             *key_file,
58                                              const gchar          *file,
59                                              GKeyFileFlags         flags,
60                                              GError              **error);
61 gboolean  g_key_file_load_from_data         (GKeyFile             *key_file,
62                                              const gchar          *data,
63                                              gsize                 length,
64                                              GKeyFileFlags         flags,
65                                              GError              **error);
66 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
67                                              const gchar          *file,
68                                              const gchar         **search_dirs,
69                                              gchar               **full_path,
70                                              GKeyFileFlags         flags,
71                                              GError              **error);
72 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
73                                              const gchar          *file,
74                                              gchar               **full_path,
75                                              GKeyFileFlags         flags,
76                                              GError              **error);
77 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
78                                              gsize                *length,
79                                              GError              **error) G_GNUC_MALLOC;
80 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
81 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
82                                              gsize                *length) G_GNUC_MALLOC;
83 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
84                                              const gchar          *group_name,
85                                              gsize                *length,
86                                              GError              **error) G_GNUC_MALLOC;
87 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
88                                              const gchar          *group_name);
89 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
90                                              const gchar          *group_name,
91                                              const gchar          *key,
92                                              GError              **error);
93 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
94                                              const gchar          *group_name,
95                                              const gchar          *key,
96                                              GError              **error) G_GNUC_MALLOC;
97 void      g_key_file_set_value              (GKeyFile             *key_file,
98                                              const gchar          *group_name,
99                                              const gchar          *key,
100                                              const gchar          *value);
101 gchar    *g_key_file_get_string             (GKeyFile             *key_file,
102                                              const gchar          *group_name,
103                                              const gchar          *key,
104                                              GError              **error) G_GNUC_MALLOC;
105 void      g_key_file_set_string             (GKeyFile             *key_file,
106                                              const gchar          *group_name,
107                                              const gchar          *key,
108                                              const gchar          *string);
109 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
110                                              const gchar          *group_name,
111                                              const gchar          *key,
112                                              const gchar          *locale,
113                                              GError              **error) G_GNUC_MALLOC;
114 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
115                                              const gchar          *group_name,
116                                              const gchar          *key,
117                                              const gchar          *locale,
118                                              const gchar          *string);
119 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
120                                              const gchar          *group_name,
121                                              const gchar          *key,
122                                              GError              **error);
123 void      g_key_file_set_boolean            (GKeyFile             *key_file,
124                                              const gchar          *group_name,
125                                              const gchar          *key,
126                                              gboolean              value);
127 gint      g_key_file_get_integer            (GKeyFile             *key_file,
128                                              const gchar          *group_name,
129                                              const gchar          *key,
130                                              GError              **error);
131 void      g_key_file_set_integer            (GKeyFile             *key_file,
132                                              const gchar          *group_name,
133                                              const gchar          *key,
134                                              gint                  value);
135 gdouble   g_key_file_get_double             (GKeyFile             *key_file,
136                                              const gchar          *group_name,
137                                              const gchar          *key,
138                                              GError              **error);
139 void      g_key_file_set_double             (GKeyFile             *key_file,
140                                              const gchar          *group_name,
141                                              const gchar          *key,
142                                              gdouble               value);
143 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
144                                              const gchar          *group_name,
145                                              const gchar          *key,
146                                              gsize                *length,
147                                              GError              **error) G_GNUC_MALLOC;
148 void      g_key_file_set_string_list        (GKeyFile             *key_file,
149                                              const gchar          *group_name,
150                                              const gchar          *key,
151                                              const gchar * const   list[],
152                                              gsize                 length);
153 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
154                                              const gchar          *group_name,
155                                              const gchar          *key,
156                                              const gchar          *locale,
157                                              gsize                *length,
158                                              GError              **error) G_GNUC_MALLOC;
159 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
160                                              const gchar          *group_name,
161                                              const gchar          *key,
162                                              const gchar          *locale,
163                                              const gchar * const   list[],
164                                              gsize                 length);
165 gboolean *g_key_file_get_boolean_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_boolean_list       (GKeyFile             *key_file,
171                                              const gchar          *group_name,
172                                              const gchar          *key,
173                                              gboolean              list[],
174                                              gsize                 length);
175 gint     *g_key_file_get_integer_list       (GKeyFile             *key_file,
176                                              const gchar          *group_name,
177                                              const gchar          *key,
178                                              gsize                *length,
179                                              GError              **error) G_GNUC_MALLOC;
180 void      g_key_file_set_double_list        (GKeyFile             *key_file,
181                                              const gchar          *group_name,
182                                              const gchar          *key,
183                                              gdouble               list[],
184                                              gsize                 length);
185 gdouble  *g_key_file_get_double_list        (GKeyFile             *key_file,
186                                              const gchar          *group_name,
187                                              const gchar          *key,
188                                              gsize                *length,
189                                              GError              **error) G_GNUC_MALLOC;
190 void      g_key_file_set_integer_list       (GKeyFile             *key_file,
191                                              const gchar          *group_name,
192                                              const gchar          *key,
193                                              gint                  list[],
194                                              gsize                 length);
195 void      g_key_file_set_comment            (GKeyFile             *key_file,
196                                              const gchar          *group_name,
197                                              const gchar          *key,
198                                              const gchar          *comment,
199                                              GError              **error);
200 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
201                                              const gchar          *group_name,
202                                              const gchar          *key,
203                                              GError              **error) G_GNUC_MALLOC;
204
205 void      g_key_file_remove_comment         (GKeyFile             *key_file,
206                                              const gchar          *group_name,
207                                              const gchar          *key,
208                                              GError              **error);
209 void      g_key_file_remove_key             (GKeyFile             *key_file,
210                                              const gchar          *group_name,
211                                              const gchar          *key,
212                                              GError              **error);
213 void      g_key_file_remove_group           (GKeyFile             *key_file,
214                                              const gchar          *group_name,
215                                              GError              **error);
216
217 /* Defines for handling freedesktop.org Desktop files */
218 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
219
220 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
221 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
222 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
223 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
224 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
225 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
226 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
227 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
228 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
229 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
230 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
231 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
232 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
233 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
234 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
235 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
236 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
237 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
238 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
239
240 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
241 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
242 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
243
244 G_END_DECLS
245
246 #endif /* __G_KEY_FILE_H__ */