1 
2 /* GConf
3  * Copyright (C) 1999, 2000 Red Hat Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef GCONF_GCONF_VALUE_H
22 #define GCONF_GCONF_VALUE_H
23 
24 #include <glib.h>
25 #include <glib-object.h>
26 #include "gconf-error.h"
27 
28 G_BEGIN_DECLS
29 
30 /*
31  * A GConfValue is used to pass configuration values around
32  */
33 
34 typedef enum {
35   GCONF_VALUE_INVALID,
36   GCONF_VALUE_STRING,
37   GCONF_VALUE_INT,
38   GCONF_VALUE_FLOAT,
39   GCONF_VALUE_BOOL,
40   GCONF_VALUE_SCHEMA,
41 
42   /* unfortunately these aren't really types; we want list_of_string,
43      list_of_int, etc.  but it's just too complicated to implement.
44      instead we'll complain in various places if you do something
45      moronic like mix types in a list or treat pair<string,int> and
46      pair<float,bool> as the same type. */
47   GCONF_VALUE_LIST,
48   GCONF_VALUE_PAIR
49 
50 } GConfValueType;
51 
52 #define GCONF_VALUE_TYPE_VALID(x) (((x) > GCONF_VALUE_INVALID) && ((x) <= GCONF_VALUE_PAIR))
53 
54 /* Forward declaration */
55 typedef struct _GConfSchema GConfSchema;
56 
57 typedef struct _GConfValue GConfValue;
58 
59 struct _GConfValue {
60   GConfValueType type;
61 };
62 
63 const char*    gconf_value_get_string    (const GConfValue *value);
64 int            gconf_value_get_int       (const GConfValue *value);
65 double         gconf_value_get_float     (const GConfValue *value);
66 GConfValueType gconf_value_get_list_type (const GConfValue *value);
67 GSList*        gconf_value_get_list      (const GConfValue *value);
68 GConfValue*    gconf_value_get_car       (const GConfValue *value);
69 GConfValue*    gconf_value_get_cdr       (const GConfValue *value);
70 gboolean       gconf_value_get_bool      (const GConfValue *value);
71 GConfSchema*   gconf_value_get_schema    (const GConfValue *value);
72 
73 GConfValue* gconf_value_new                  (GConfValueType type);
74 
75 /* doesn't work on complicated types (only string, int, bool, float) */
76 GConfValue* gconf_value_new_from_string      (GConfValueType type,
77                                               const gchar* str,
78                                               GError** err);
79 
80 GType       gconf_value_get_type             (void) G_GNUC_CONST;
81 GConfValue* gconf_value_copy                 (const GConfValue* src);
82 void        gconf_value_free                 (GConfValue* value);
83 
84 void        gconf_value_set_int              (GConfValue* value,
85                                               gint the_int);
86 void        gconf_value_set_string           (GConfValue* value,
87                                               const gchar* the_str);
88 void        gconf_value_set_float            (GConfValue* value,
89                                               gdouble the_float);
90 void        gconf_value_set_bool             (GConfValue* value,
91                                               gboolean the_bool);
92 void        gconf_value_set_schema           (GConfValue* value,
93                                               const GConfSchema* sc);
94 void        gconf_value_set_schema_nocopy    (GConfValue* value,
95                                               GConfSchema* sc);
96 void        gconf_value_set_car              (GConfValue* value,
97                                               const GConfValue* car);
98 void        gconf_value_set_car_nocopy       (GConfValue* value,
99                                               GConfValue* car);
100 void        gconf_value_set_cdr              (GConfValue* value,
101                                               const GConfValue* cdr);
102 void        gconf_value_set_cdr_nocopy       (GConfValue* value,
103                                               GConfValue* cdr);
104 /* Set a list of GConfValue, NOT lists or pairs */
105 void        gconf_value_set_list_type        (GConfValue* value,
106                                               GConfValueType type);
107 void        gconf_value_set_list_nocopy      (GConfValue* value,
108                                               GSList* list);
109 void        gconf_value_set_list             (GConfValue* value,
110                                               GSList* list);
111 
112 gchar*      gconf_value_to_string            (const GConfValue* value);
113 
114 int         gconf_value_compare              (const GConfValue* value_a,
115                                               const GConfValue* value_b);
116 
117 GConfValue* gconf_value_decode               (const gchar *encoded);
118 gchar*      gconf_value_encode               (GConfValue  *val);
119 
120 /* Meta-information about a key. Not the same as a schema; this is
121  * information stored on the key, the schema is a specification
122  * that may apply to this key.
123  */
124 
125 /* FIXME GConfMetaInfo is basically deprecated in favor of stuffing this
126  * info into GConfEntry, though the transition isn't complete.
127  */
128 
129 /* Skipped from introspection because it's not registered as boxed */
130 /**
131  * GConfMetaInfo: (skip)
132  *
133  */
134 typedef struct _GConfMetaInfo GConfMetaInfo;
135 
136 struct _GConfMetaInfo {
137   gchar* schema;
138   gchar* mod_user; /* user owning the daemon that made the last modification */
139   GTime  mod_time; /* time of the modification */
140 };
141 
142 const char* gconf_meta_info_get_schema   (GConfMetaInfo *gcmi);
143 const char* gconf_meta_info_get_mod_user (GConfMetaInfo *gcmi);
144 GTime       gconf_meta_info_mod_time     (GConfMetaInfo *gcmi);
145 
146 GConfMetaInfo* gconf_meta_info_new          (void);
147 void           gconf_meta_info_free         (GConfMetaInfo *gcmi);
148 void           gconf_meta_info_set_schema   (GConfMetaInfo *gcmi,
149                                              const gchar   *schema_name);
150 void           gconf_meta_info_set_mod_user (GConfMetaInfo *gcmi,
151                                              const gchar   *mod_user);
152 void           gconf_meta_info_set_mod_time (GConfMetaInfo *gcmi,
153                                              GTime          mod_time);
154 
155 
156 
157 /* Key-value pairs; used to list the contents of
158  *  a directory
159  */
160 
161 typedef enum
162 {
163   GCONF_UNSET_INCLUDING_SCHEMA_NAMES = 1 << 0
164 } GConfUnsetFlags;
165 
166 typedef struct _GConfEntry GConfEntry;
167 
168 struct _GConfEntry {
169   char *key;
170   GConfValue *value;
171 };
172 
173 GType       gconf_entry_get_type        (void) G_GNUC_CONST;
174 const char* gconf_entry_get_key         (const GConfEntry *entry);
175 GConfValue* gconf_entry_get_value       (const GConfEntry *entry);
176 const char* gconf_entry_get_schema_name (const GConfEntry *entry);
177 gboolean    gconf_entry_get_is_default  (const GConfEntry *entry);
178 gboolean    gconf_entry_get_is_writable (const GConfEntry *entry);
179 
180 GConfEntry* gconf_entry_new              (const gchar *key,
181                                           const GConfValue  *val);
182 GConfEntry* gconf_entry_new_nocopy       (gchar       *key,
183                                           GConfValue  *val);
184 
185 GConfEntry* gconf_entry_copy             (const GConfEntry *src);
186 #ifndef GCONF_DISABLE_DEPRECATED
187 void        gconf_entry_free             (GConfEntry  *entry);
188 #endif
189 GConfEntry* gconf_entry_ref   (GConfEntry *entry);
190 void        gconf_entry_unref (GConfEntry *entry);
191 
192 /* Transfer ownership of value to the caller. */
193 GConfValue* gconf_entry_steal_value      (GConfEntry  *entry);
194 void        gconf_entry_set_value        (GConfEntry  *entry,
195                                           const GConfValue  *val);
196 void        gconf_entry_set_value_nocopy (GConfEntry  *entry,
197                                           GConfValue  *val);
198 void        gconf_entry_set_schema_name  (GConfEntry  *entry,
199                                           const gchar *name);
200 void        gconf_entry_set_is_default   (GConfEntry  *entry,
201                                           gboolean     is_default);
202 void        gconf_entry_set_is_writable  (GConfEntry  *entry,
203                                           gboolean     is_writable);
204 
205 gboolean    gconf_entry_equal            (const GConfEntry *a,
206                                           const GConfEntry *b);
207 
208 G_END_DECLS
209 
210 #endif
211 
212 
213