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.1 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 * 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, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Ryan Lortie <desrt@desrt.ca>
19 * Matthias Clasen <mclasen@redhat.com>
20 */
21
22#ifndef __G_SETTINGS_BACKEND_H__
23#define __G_SETTINGS_BACKEND_H__
24
25#if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
26#error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
27#endif
28
29#define __GIO_GIO_H_INSIDE__
30#include <gio/giotypes.h>
31#undef __GIO_GIO_H_INSIDE__
32
33G_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 **/
59typedef struct _GSettingsBackendPrivate GSettingsBackendPrivate;
60typedef struct _GSettingsBackendClass GSettingsBackendClass;
61
62/**
63 * GSettingsBackendClass:
64 * @read: virtual method to read a key's value
65 * @get_writable: virtual method to get if a key is writable
66 * @write: virtual method to change key's value
67 * @write_tree: virtual method to change a tree of keys
68 * @reset: virtual method to reset state
69 * @subscribe: virtual method to subscribe to key changes
70 * @unsubscribe: virtual method to unsubscribe to key changes
71 * @sync: virtual method to sync state
72 * @get_permission: virtual method to get permission of a key
73 * @read_user_value: virtual method to read user's key value
74 *
75 * Class structure for #GSettingsBackend.
76 */
77struct _GSettingsBackendClass
78{
79 GObjectClass parent_class;
80
81 GVariant * (*read) (GSettingsBackend *backend,
82 const gchar *key,
83 const GVariantType *expected_type,
84 gboolean default_value);
85
86 gboolean (*get_writable) (GSettingsBackend *backend,
87 const gchar *key);
88
89 gboolean (*write) (GSettingsBackend *backend,
90 const gchar *key,
91 GVariant *value,
92 gpointer origin_tag);
93 gboolean (*write_tree) (GSettingsBackend *backend,
94 GTree *tree,
95 gpointer origin_tag);
96 void (*reset) (GSettingsBackend *backend,
97 const gchar *key,
98 gpointer origin_tag);
99
100 void (*subscribe) (GSettingsBackend *backend,
101 const gchar *name);
102 void (*unsubscribe) (GSettingsBackend *backend,
103 const gchar *name);
104 void (*sync) (GSettingsBackend *backend);
105
106 GPermission * (*get_permission) (GSettingsBackend *backend,
107 const gchar *path);
108
109 GVariant * (*read_user_value) (GSettingsBackend *backend,
110 const gchar *key,
111 const GVariantType *expected_type);
112
113 /*< private >*/
114 gpointer padding[23];
115};
116
117struct _GSettingsBackend
118{
119 GObject parent_instance;
120
121 /*< private >*/
122 GSettingsBackendPrivate *priv;
123};
124
125GLIB_AVAILABLE_IN_ALL
126GType g_settings_backend_get_type (void);
127
128GLIB_AVAILABLE_IN_ALL
129void g_settings_backend_changed (GSettingsBackend *backend,
130 const gchar *key,
131 gpointer origin_tag);
132GLIB_AVAILABLE_IN_ALL
133void g_settings_backend_path_changed (GSettingsBackend *backend,
134 const gchar *path,
135 gpointer origin_tag);
136GLIB_AVAILABLE_IN_ALL
137void g_settings_backend_flatten_tree (GTree *tree,
138 gchar **path,
139 const gchar ***keys,
140 GVariant ***values);
141GLIB_AVAILABLE_IN_ALL
142void g_settings_backend_keys_changed (GSettingsBackend *backend,
143 const gchar *path,
144 gchar const * const *items,
145 gpointer origin_tag);
146
147GLIB_AVAILABLE_IN_ALL
148void g_settings_backend_path_writable_changed (GSettingsBackend *backend,
149 const gchar *path);
150GLIB_AVAILABLE_IN_ALL
151void g_settings_backend_writable_changed (GSettingsBackend *backend,
152 const gchar *key);
153GLIB_AVAILABLE_IN_ALL
154void g_settings_backend_changed_tree (GSettingsBackend *backend,
155 GTree *tree,
156 gpointer origin_tag);
157
158GLIB_AVAILABLE_IN_ALL
159GSettingsBackend * g_settings_backend_get_default (void);
160
161GLIB_AVAILABLE_IN_ALL
162GSettingsBackend * g_keyfile_settings_backend_new (const gchar *filename,
163 const gchar *root_path,
164 const gchar *root_group);
165
166GLIB_AVAILABLE_IN_ALL
167GSettingsBackend * g_null_settings_backend_new (void);
168
169GLIB_AVAILABLE_IN_ALL
170GSettingsBackend * g_memory_settings_backend_new (void);
171
172G_END_DECLS
173
174#endif /* __G_SETTINGS_BACKEND_H__ */
175

source code of gtk/subprojects/glib/gio/gsettingsbackend.h