2 * Copyright © 2009, 2010 Codethink Limited
3 * Copyright © 2010 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Authors: Ryan Lortie <desrt@desrt.ca>
21 * Matthias Clasen <mclasen@redhat.com>
24 #ifndef __G_SETTINGS_BACKEND_H__
25 #define __G_SETTINGS_BACKEND_H__
27 #if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
28 #error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
31 #define __GIO_GIO_H_INSIDE__
32 #include <gio/giotypes.h>
33 #undef __GIO_GIO_H_INSIDE__
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))
50 * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
52 * Extension point for #GSettingsBackend functionality.
54 #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
59 * An implementation of a settings storage repository.
61 typedef struct _GSettingsBackendPrivate GSettingsBackendPrivate;
62 typedef struct _GSettingsBackendClass GSettingsBackendClass;
65 * GSettingsBackendClass:
66 * @read: virtual method to read a key's value
67 * @get_writable: virtual method to get if a key is writable
68 * @write: virtual method to change key's value
69 * @write_tree: virtual method to change a tree of keys
70 * @reset: virtual method to reset state
71 * @subscribe: virtual method to subscribe to key changes
72 * @unsubscribe: virtual method to unsubscribe to key changes
73 * @sync: virtual method to sync state
74 * @get_permission: virtual method to get permission of a key
75 * @read_user_value: virtual method to read user's key value
77 * Class structure for #GSettingsBackend.
79 struct _GSettingsBackendClass
81 GObjectClass parent_class;
83 GVariant * (*read) (GSettingsBackend *backend,
85 const GVariantType *expected_type,
86 gboolean default_value);
88 gboolean (*get_writable) (GSettingsBackend *backend,
91 gboolean (*write) (GSettingsBackend *backend,
95 gboolean (*write_tree) (GSettingsBackend *backend,
98 void (*reset) (GSettingsBackend *backend,
100 gpointer origin_tag);
102 void (*subscribe) (GSettingsBackend *backend,
104 void (*unsubscribe) (GSettingsBackend *backend,
106 void (*sync) (GSettingsBackend *backend);
108 GPermission * (*get_permission) (GSettingsBackend *backend,
111 GVariant * (*read_user_value) (GSettingsBackend *backend,
113 const GVariantType *expected_type);
116 gpointer padding[23];
119 struct _GSettingsBackend
121 GObject parent_instance;
124 GSettingsBackendPrivate *priv;
128 GType g_settings_backend_get_type (void);
131 void g_settings_backend_changed (GSettingsBackend *backend,
133 gpointer origin_tag);
135 void g_settings_backend_path_changed (GSettingsBackend *backend,
137 gpointer origin_tag);
139 void g_settings_backend_flatten_tree (GTree *tree,
144 void g_settings_backend_keys_changed (GSettingsBackend *backend,
146 gchar const * const *items,
147 gpointer origin_tag);
150 void g_settings_backend_path_writable_changed (GSettingsBackend *backend,
153 void g_settings_backend_writable_changed (GSettingsBackend *backend,
156 void g_settings_backend_changed_tree (GSettingsBackend *backend,
158 gpointer origin_tag);
161 GSettingsBackend * g_settings_backend_get_default (void);
164 GSettingsBackend * g_keyfile_settings_backend_new (const gchar *filename,
165 const gchar *root_path,
166 const gchar *root_group);
169 GSettingsBackend * g_null_settings_backend_new (void);
172 GSettingsBackend * g_memory_settings_backend_new (void);
176 #endif /* __G_SETTINGS_BACKEND_H__ */