tests: Fix for non-GCC
[platform/upstream/glib.git] / gio / gsettingsbackend.h
1 /*
2  * Copyright © 2009, 2010 Codethink Limited
3  * Copyright © 2010 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 Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the licence, 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Authors: Ryan Lortie <desrt@desrt.ca>
21  *          Matthias Clasen <mclasen@redhat.com>
22  */
23
24 #ifndef __G_SETTINGS_BACKEND_H__
25 #define __G_SETTINGS_BACKEND_H__
26
27 #if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
28 #error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
29 #endif
30
31 #define __GIO_GIO_H_INSIDE__
32 #include <gio/giotypes.h>
33 #undef __GIO_GIO_H_INSIDE__
34
35 G_BEGIN_DECLS
36
37 #define G_TYPE_SETTINGS_BACKEND                             (g_settings_backend_get_type ())
38 #define G_SETTINGS_BACKEND(inst)                            (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
39                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackend))
40 #define G_SETTINGS_BACKEND_CLASS(class)                     (G_TYPE_CHECK_CLASS_CAST ((class),                       \
41                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
42 #define G_IS_SETTINGS_BACKEND(inst)                         (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
43                                                              G_TYPE_SETTINGS_BACKEND))
44 #define G_IS_SETTINGS_BACKEND_CLASS(class)                  (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
45                                                              G_TYPE_SETTINGS_BACKEND))
46 #define G_SETTINGS_BACKEND_GET_CLASS(inst)                  (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
47                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
48
49 /**
50  * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
51  *
52  * Extension point for #GSettingsBackend functionality.
53  **/
54 #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
55
56 /**
57  * GSettingsBackend:
58  *
59  * An implementation of a settings storage repository.
60  **/
61 typedef struct _GSettingsBackendPrivate                     GSettingsBackendPrivate;
62 typedef struct _GSettingsBackendClass                       GSettingsBackendClass;
63
64 struct _GSettingsBackendClass
65 {
66   GObjectClass parent_class;
67
68   GVariant *    (*read)             (GSettingsBackend    *backend,
69                                      const gchar         *key,
70                                      const GVariantType  *expected_type,
71                                      gboolean             default_value);
72
73   gboolean      (*get_writable)     (GSettingsBackend    *backend,
74                                      const gchar         *key);
75
76   gboolean      (*write)            (GSettingsBackend    *backend,
77                                      const gchar         *key,
78                                      GVariant            *value,
79                                      gpointer             origin_tag);
80   gboolean      (*write_tree)       (GSettingsBackend    *backend,
81                                      GTree               *tree,
82                                      gpointer             origin_tag);
83   void          (*reset)            (GSettingsBackend    *backend,
84                                      const gchar         *key,
85                                      gpointer             origin_tag);
86
87   void          (*subscribe)        (GSettingsBackend    *backend,
88                                      const gchar         *name);
89   void          (*unsubscribe)      (GSettingsBackend    *backend,
90                                      const gchar         *name);
91   void          (*sync)             (GSettingsBackend    *backend);
92
93   GPermission * (*get_permission)   (GSettingsBackend    *backend,
94                                      const gchar         *path);
95
96   GVariant *    (*read_user_value)  (GSettingsBackend    *backend,
97                                      const gchar         *key,
98                                      const GVariantType  *expected_type);
99
100   gpointer padding[23];
101 };
102
103 struct _GSettingsBackend
104 {
105   GObject parent_instance;
106
107   /*< private >*/
108   GSettingsBackendPrivate *priv;
109 };
110
111 GLIB_AVAILABLE_IN_ALL
112 GType                   g_settings_backend_get_type                     (void);
113
114 GLIB_AVAILABLE_IN_ALL
115 void                    g_settings_backend_changed                      (GSettingsBackend    *backend,
116                                                                          const gchar         *key,
117                                                                          gpointer             origin_tag);
118 GLIB_AVAILABLE_IN_ALL
119 void                    g_settings_backend_path_changed                 (GSettingsBackend    *backend,
120                                                                          const gchar         *path,
121                                                                          gpointer             origin_tag);
122 GLIB_AVAILABLE_IN_ALL
123 void                    g_settings_backend_flatten_tree                 (GTree               *tree,
124                                                                          gchar              **path,
125                                                                          const gchar       ***keys,
126                                                                          GVariant          ***values);
127 GLIB_AVAILABLE_IN_ALL
128 void                    g_settings_backend_keys_changed                 (GSettingsBackend    *backend,
129                                                                          const gchar         *path,
130                                                                          gchar const * const *items,
131                                                                          gpointer             origin_tag);
132
133 GLIB_AVAILABLE_IN_ALL
134 void                    g_settings_backend_path_writable_changed        (GSettingsBackend    *backend,
135                                                                          const gchar         *path);
136 GLIB_AVAILABLE_IN_ALL
137 void                    g_settings_backend_writable_changed             (GSettingsBackend    *backend,
138                                                                          const gchar         *key);
139 GLIB_AVAILABLE_IN_ALL
140 void                    g_settings_backend_changed_tree                 (GSettingsBackend    *backend,
141                                                                          GTree               *tree,
142                                                                          gpointer             origin_tag);
143
144 GLIB_AVAILABLE_IN_ALL
145 GSettingsBackend *      g_settings_backend_get_default                  (void);
146
147 GLIB_AVAILABLE_IN_ALL
148 GSettingsBackend *      g_keyfile_settings_backend_new                  (const gchar         *filename,
149                                                                          const gchar         *root_path,
150                                                                          const gchar         *root_group);
151
152 GLIB_AVAILABLE_IN_ALL
153 GSettingsBackend *      g_null_settings_backend_new                     (void);
154
155 GLIB_AVAILABLE_IN_ALL
156 GSettingsBackend *      g_memory_settings_backend_new                   (void);
157
158 G_END_DECLS
159
160 #endif /* __G_SETTINGS_BACKEND_H__ */