change GSettingsBackend.list() API
[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 #include <glib-object.h>
32
33 G_BEGIN_DECLS
34
35 #define G_TYPE_SETTINGS_BACKEND                             (g_settings_backend_get_type ())
36 #define G_SETTINGS_BACKEND(inst)                            (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
37                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackend))
38 #define G_SETTINGS_BACKEND_CLASS(class)                     (G_TYPE_CHECK_CLASS_CAST ((class),                       \
39                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
40 #define G_IS_SETTINGS_BACKEND(inst)                         (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
41                                                              G_TYPE_SETTINGS_BACKEND))
42 #define G_IS_SETTINGS_BACKEND_CLASS(class)                  (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
43                                                              G_TYPE_SETTINGS_BACKEND))
44 #define G_SETTINGS_BACKEND_GET_CLASS(inst)                  (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
45                                                              G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
46
47 /**
48  * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
49  *
50  * Extension point for #GSettingsBackend functionality.
51  **/
52 #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
53
54 /**
55  * GSettingsBackend:
56  *
57  * An implementation of a settings storage repository.
58  **/
59 typedef struct _GSettingsBackendPrivate                     GSettingsBackendPrivate;
60 typedef struct _GSettingsBackendClass                       GSettingsBackendClass;
61 typedef struct _GSettingsBackend                            GSettingsBackend;
62
63
64 struct _GSettingsBackendClass
65 {
66   GObjectClass parent_class;
67
68   gboolean    (*supports_context) (const gchar         *context);
69
70   GVariant *  (*read)             (GSettingsBackend    *backend,
71                                    const gchar         *key,
72                                    const GVariantType  *expected_type,
73                                    gboolean             default_value);
74   gchar **    (*list)             (GSettingsBackend    *backend,
75                                    const gchar         *path,
76                                    gchar              **resets,
77                                    gsize                n_resets,
78                                    gsize               *length);
79   gboolean    (*write)            (GSettingsBackend    *backend,
80                                    const gchar         *key,
81                                    GVariant            *value,
82                                    gpointer             origin_tag);
83   gboolean    (*write_keys)       (GSettingsBackend    *backend,
84                                    GTree               *tree,
85                                    gpointer             origin_tag);
86   void        (*reset)            (GSettingsBackend    *backend,
87                                    const gchar         *key,
88                                    gpointer             origin_tag);
89   void        (*reset_path)       (GSettingsBackend    *backend,
90                                    const gchar         *path,
91                                    gpointer             origin_tag);
92   gboolean    (*get_writable)     (GSettingsBackend    *backend,
93                                    const gchar         *key);
94   void        (*subscribe)        (GSettingsBackend    *backend,
95                                    const gchar         *name);
96   void        (*unsubscribe)      (GSettingsBackend    *backend,
97                                    const gchar         *name);
98   void        (*sync)             (GSettingsBackend    *backend);
99
100   gpointer padding[8];
101 };
102
103 struct _GSettingsBackend
104 {
105   GObject parent_instance;
106
107   /*< private >*/
108   GSettingsBackendPrivate *priv;
109 };
110
111 GType                           g_settings_backend_get_type             (void);
112
113 void                            g_settings_backend_setup                (const gchar         *context,
114                                                                          GSettingsBackend    *backend);
115 void                            g_settings_backend_setup_keyfile        (const gchar         *context,
116                                                                          const gchar         *filename);
117
118 void                            g_settings_backend_changed              (GSettingsBackend    *backend,
119                                                                          const gchar         *key,
120                                                                          gpointer             origin_tag);
121 void                            g_settings_backend_path_changed         (GSettingsBackend    *backend,
122                                                                          const gchar         *path,
123                                                                          gpointer             origin_tag);
124 void                            g_settings_backend_flatten_tree         (GTree               *tree,
125                                                                          gchar              **path,
126                                                                          const gchar       ***keys,
127                                                                          GVariant          ***values);
128 void                            g_settings_backend_keys_changed         (GSettingsBackend    *backend,
129                                                                          const gchar         *path,
130                                                                          gchar const * const *items,
131                                                                          gpointer             origin_tag);
132
133 void                            g_settings_backend_path_writable_changed(GSettingsBackend    *backend,
134                                                                          const gchar         *path);
135 void                            g_settings_backend_writable_changed     (GSettingsBackend    *backend,
136                                                                          const gchar         *key);
137 void                            g_settings_backend_changed_tree         (GSettingsBackend    *backend,
138                                                                          GTree               *tree,
139                                                                          gpointer             origin_tag);
140
141 G_END_DECLS
142
143 #endif /* __G_SETTINGS_BACKEND_H__ */