add 'null' GSettings backend
[platform/upstream/glib.git] / gio / gnullsettingsbackend.c
1 /*
2  * Copyright © 2010 Codethink Limited
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the licence, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #include "config.h"
23
24 #include "gnullsettingsbackend.h"
25
26 #define G_TYPE_NULL_SETTINGS_BACKEND    (g_null_settings_backend_get_type ())
27 #define G_NULL_SETTINGS_BACKEND(inst)   (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
28                                          G_TYPE_NULL_SETTINGS_BACKEND,       \
29                                          GNullSettingsBackend))
30
31
32 typedef GSettingsBackendClass GNullSettingsBackendClass;
33 typedef GSettingsBackend      GNullSettingsBackend;
34
35 G_DEFINE_TYPE (GNullSettingsBackend,
36                g_null_settings_backend,
37                G_TYPE_SETTINGS_BACKEND)
38
39 static GVariant *
40 g_null_settings_backend_read (GSettingsBackend   *backend,
41                               const gchar        *key,
42                               const GVariantType *expected_type)
43 {
44   return NULL;
45 }
46
47 static gboolean
48 g_null_settings_backend_write (GSettingsBackend *backend,
49                                const gchar      *key,
50                                GVariant         *value,
51                                gpointer          origin_tag)
52 {
53   return FALSE;
54 }
55
56 static gboolean
57 g_null_settings_backend_write_keys (GSettingsBackend *backend,
58                                     GTree            *tree,
59                                     gpointer          origin_tag)
60 {
61   return FALSE;
62 }
63
64 static void
65 g_null_settings_backend_reset (GSettingsBackend *backend,
66                                const gchar      *key,
67                                gpointer          origin_tag)
68 {
69 }
70
71 static void
72 g_null_settings_backend_reset_path (GSettingsBackend *backend,
73                                     const gchar      *path,
74                                     gpointer          origin_tag)
75 {
76 }
77
78 static gboolean
79 g_null_settings_backend_get_writable (GSettingsBackend *backend,
80                                         const gchar      *name)
81 {
82   return FALSE;
83 }
84
85 static void
86 g_null_settings_backend_init (GNullSettingsBackend *memory)
87 {
88 }
89
90 static void
91 g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
92 {
93   GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
94
95   backend_class->read = g_null_settings_backend_read;
96   backend_class->write = g_null_settings_backend_write;
97   backend_class->write_keys = g_null_settings_backend_write_keys;
98   backend_class->reset = g_null_settings_backend_reset;
99   backend_class->reset_path = g_null_settings_backend_reset_path;
100   backend_class->get_writable = g_null_settings_backend_get_writable;
101 }
102
103 GSettingsBackend *
104 g_null_settings_backend_new (void)
105 {
106   return g_object_new (G_TYPE_NULL_SETTINGS_BACKEND, NULL);
107 }