gsettingsbackend.h: pretend to be gio.h
[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 typedef struct _GSettingsBackend                            GSettingsBackend;
64
65
66 struct _GSettingsBackendClass
67 {
68   GObjectClass parent_class;
69
70   gboolean    (*supports_context) (const gchar         *context);
71
72   GVariant *  (*read)             (GSettingsBackend    *backend,
73                                    const gchar         *key,
74                                    const GVariantType  *expected_type,
75                                    gboolean             default_value);
76   gchar **    (*list)             (GSettingsBackend    *backend,
77                                    const gchar         *path,
78                                    gchar              **resets,
79                                    gsize                n_resets,
80                                    gsize               *length);
81   gboolean    (*write)            (GSettingsBackend    *backend,
82                                    const gchar         *key,
83                                    GVariant            *value,
84                                    gpointer             origin_tag);
85   gboolean    (*write_keys)       (GSettingsBackend    *backend,
86                                    GTree               *tree,
87                                    gpointer             origin_tag);
88   void        (*reset)            (GSettingsBackend    *backend,
89                                    const gchar         *key,
90                                    gpointer             origin_tag);
91   void        (*reset_path)       (GSettingsBackend    *backend,
92                                    const gchar         *path,
93                                    gpointer             origin_tag);
94   gboolean    (*get_writable)     (GSettingsBackend    *backend,
95                                    const gchar         *key);
96   void        (*subscribe)        (GSettingsBackend    *backend,
97                                    const gchar         *name);
98   void        (*unsubscribe)      (GSettingsBackend    *backend,
99                                    const gchar         *name);
100   void        (*sync)             (GSettingsBackend    *backend);
101
102   gpointer padding[8];
103 };
104
105 struct _GSettingsBackend
106 {
107   GObject parent_instance;
108
109   /*< private >*/
110   GSettingsBackendPrivate *priv;
111 };
112
113 GType                           g_settings_backend_get_type             (void);
114
115 void                            g_settings_backend_setup                (const gchar         *context,
116                                                                          GSettingsBackend    *backend);
117 void                            g_settings_backend_setup_keyfile        (const gchar         *context,
118                                                                          const gchar         *filename);
119
120 void                            g_settings_backend_changed              (GSettingsBackend    *backend,
121                                                                          const gchar         *key,
122                                                                          gpointer             origin_tag);
123 void                            g_settings_backend_path_changed         (GSettingsBackend    *backend,
124                                                                          const gchar         *path,
125                                                                          gpointer             origin_tag);
126 void                            g_settings_backend_flatten_tree         (GTree               *tree,
127                                                                          gchar              **path,
128                                                                          const gchar       ***keys,
129                                                                          GVariant          ***values);
130 void                            g_settings_backend_keys_changed         (GSettingsBackend    *backend,
131                                                                          const gchar         *path,
132                                                                          gchar const * const *items,
133                                                                          gpointer             origin_tag);
134
135 void                            g_settings_backend_path_writable_changed(GSettingsBackend    *backend,
136                                                                          const gchar         *path);
137 void                            g_settings_backend_writable_changed     (GSettingsBackend    *backend,
138                                                                          const gchar         *key);
139 void                            g_settings_backend_changed_tree         (GSettingsBackend    *backend,
140                                                                          GTree               *tree,
141                                                                          gpointer             origin_tag);
142
143 G_END_DECLS
144
145 #endif /* __G_SETTINGS_BACKEND_H__ */