summaryrefslogtreecommitdiff
path: root/gconf/gconf.h
blob: 439f74d2f406800840c99c4d2e6364bc0c271a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/* GConf
 * Copyright (C) 1999, 2000 Red Hat Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef GCONF_GCONF_H
#define GCONF_GCONF_H

#include <glib.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <gconf/gconf-schema.h>
#include <gconf/gconf-engine.h>
#include <gconf/gconf-error.h>

gboolean     gconf_is_initialized  (void);

typedef void (*GConfNotifyFunc) (GConfEngine* conf,
                                 guint cnxn_id,
                                 const gchar* key,
                                 GConfValue* value,
                                 gboolean is_default,
                                 gpointer user_data);
  
/* Returns ID of the notification */
/* returns 0 on error, 0 is an invalid ID */
guint gconf_engine_notify_add    (GConfEngine      *conf,
                                  /* dir or key to listen to */
                                  const gchar      *namespace_section,
                                  GConfNotifyFunc   func,
                                  gpointer          user_data,
                                  GError      **err);

void  gconf_engine_notify_remove (GConfEngine      *conf,
                                  guint             cnxn);



/* Low-level interfaces */
GConfValue* gconf_engine_get                     (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  GError  **err);

GConfValue* gconf_engine_get_without_default     (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  GError  **err);

GConfValue* gconf_engine_get_full                (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  const gchar  *locale,
                                                  gboolean      use_schema_default,
                                                  gboolean     *value_is_default,
                                                  GError  **err);


/* Locale only matters if you are expecting to get a schema, or if you
   don't know what you are expecting and it might be a schema. Note
   that gconf_engine_get () automatically uses the current locale, which is
   normally what you want. */
GConfValue* gconf_engine_get_with_locale         (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  const gchar  *locale,
                                                  GError  **err);


/* Get the default value stored in the schema associated with this key */
GConfValue* gconf_engine_get_default_from_schema (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  GError  **err);
gboolean    gconf_engine_set                     (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  GConfValue   *value,
                                                  GError  **err);
gboolean    gconf_engine_unset                   (GConfEngine  *conf,
                                                  const gchar  *key,
                                                  GError  **err);


/*
 * schema_key should have a schema (if key stores a value) or a dir
 * full of schemas (if key stores a directory name)
 */

gboolean gconf_engine_associate_schema (GConfEngine  *conf,
                                        const gchar  *key,
                                        const gchar  *schema_key,
                                        GError  **err);
GSList*  gconf_engine_all_entries      (GConfEngine  *conf,
                                        const gchar  *dir,
                                        GError  **err);
GSList*  gconf_engine_all_dirs         (GConfEngine  *conf,
                                        const gchar  *dir,
                                        GError  **err);
void     gconf_engine_suggest_sync     (GConfEngine  *conf,
                                        GError  **err);
gboolean gconf_engine_dir_exists       (GConfEngine  *conf,
                                        const gchar  *dir,
                                        GError  **err);


/* if you pass non-NULL for why_invalid, it gives a user-readable
   explanation of the problem in g_malloc()'d memory
*/
gboolean gconf_valid_key          (const gchar  *key,
                                   gchar       **why_invalid);


/* return TRUE if the path "below" would be somewhere below the directory "above" */
gboolean gconf_key_is_below       (const gchar  *above,
                                   const gchar  *below);


/* Returns allocated concatenation of these two */
gchar*   gconf_concat_key_and_dir (const gchar  *dir,
                                   const gchar  *key);


/* Returns a different string every time (at least, the chances of
   getting a duplicate are like one in a zillion). The key is a
   legal gconf key name (a single element of one) */
gchar*   gconf_unique_key         (void);


/* 
 * Higher-level stuff 
 */


gdouble      gconf_engine_get_float  (GConfEngine     *conf,
                                      const gchar     *key,
                                      GError     **err);
gint         gconf_engine_get_int    (GConfEngine     *conf,
                                      const gchar     *key,
                                      GError     **err);


/* free the retval, retval can be NULL for "unset" */
gchar*       gconf_engine_get_string (GConfEngine     *conf,
                                      const gchar     *key,
                                      GError     **err);
gboolean     gconf_engine_get_bool   (GConfEngine     *conf,
                                      const gchar     *key,
                                      GError     **err);


/* this one has no default since it would be expensive and make little
   sense; it returns NULL as a default, to indicate unset or error */
/* free the retval */
/* Note that this returns the schema stored at key, NOT
   the schema associated with the key. */
GConfSchema* gconf_engine_get_schema (GConfEngine     *conf,
                                      const gchar     *key,
                                      GError     **err);


/*
  This automatically converts the list to the given list type;
  a list of int or bool stores values in the list->data field
  using GPOINTER_TO_INT(), a list of strings stores the gchar*
  in list->data, a list of float contains pointers to allocated
  gdouble (gotta love C!).
*/
GSList*      gconf_engine_get_list   (GConfEngine     *conf,
                                      const gchar     *key,
                                      GConfValueType   list_type,
                                      GError     **err);

/*
  The car_retloc and cdr_retloc args should be the address of the appropriate
  type:
  bool    gboolean*
  int     gint*
  string  gchar**
  float   gdouble*
  schema  GConfSchema**
*/
gboolean     gconf_engine_get_pair   (GConfEngine     *conf,
                                      const gchar     *key,
                                      GConfValueType   car_type,
                                      GConfValueType   cdr_type,
                                      gpointer         car_retloc,
                                      gpointer         cdr_retloc,
                                      GError     **err);


/* setters return TRUE on success; note that you still should suggest a sync */
gboolean gconf_engine_set_float  (GConfEngine     *conf,
                                  const gchar     *key,
                                  gdouble          val,
                                  GError     **err);
gboolean gconf_engine_set_int    (GConfEngine     *conf,
                                  const gchar     *key,
                                  gint             val,
                                  GError     **err);
gboolean gconf_engine_set_string (GConfEngine     *conf,
                                  const gchar     *key,
                                  const gchar     *val,
                                  GError     **err);
gboolean gconf_engine_set_bool   (GConfEngine     *conf,
                                  const gchar     *key,
                                  gboolean         val,
                                  GError     **err);
gboolean gconf_engine_set_schema (GConfEngine     *conf,
                                  const gchar     *key,
                                  GConfSchema     *val,
                                  GError     **err);


/* List should be the same as the one gconf_engine_get_list() would return */
gboolean gconf_engine_set_list   (GConfEngine     *conf,
                                  const gchar     *key,
                                  GConfValueType   list_type,
                                  GSList          *list,
                                  GError     **err);
gboolean gconf_engine_set_pair   (GConfEngine     *conf,
                                  const gchar     *key,
                                  GConfValueType   car_type,
                                  GConfValueType   cdr_type,
                                  gconstpointer    address_of_car,
                                  gconstpointer    address_of_cdr,
                                  GError     **err);


/* Utility function converts enumerations to and from strings */
typedef struct _GConfEnumStringPair GConfEnumStringPair;

struct _GConfEnumStringPair {
  gint enum_value;
  const gchar* str;
};

gboolean     gconf_string_to_enum (GConfEnumStringPair  lookup_table[],
                                   const gchar         *str,
                                   gint                *enum_value_retloc);
const gchar* gconf_enum_to_string (GConfEnumStringPair  lookup_table[],
                                   gint                 enum_value);

gboolean     gconf_init        (int argc, char **argv, GError** err);

/* No, you can't use this stuff. Bad application developer. Bad. */
#ifdef GCONF_ENABLE_INTERNALS

/* This stuff is only useful in GNOME 2.0, so isn't in this GConf
 * release.
 */

/* For use by the Gnome module system */
void gconf_preinit(gpointer app, gpointer mod_info);
void gconf_postinit(gpointer app, gpointer mod_info);

extern const char gconf_version[];

#ifdef HAVE_POPT_H
#include <popt.h>
#endif

#ifdef POPT_AUTOHELP
/* If people are using popt, then make the table available to them */
extern struct poptOption gconf_options[];
#endif

void gconf_clear_cache(GConfEngine* conf, GError** err);
void gconf_synchronous_sync(GConfEngine* conf, GError** err);
#endif

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif