It is 'registered', not 'registred'
[glib.git] / gio / gnullsettingsbackend.c
blob523f07483736566fdc3dd0d4acb0727c750f59ec
1 /*
2 * Copyright © 2010 Codethink Limited
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.
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.
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.
19 * Author: Ryan Lortie <desrt@desrt.ca>
22 #include "config.h"
24 #include "gsettingsbackendinternal.h"
25 #include "giomodule.h"
26 #include "gsimplepermission.h"
29 #define G_TYPE_NULL_SETTINGS_BACKEND (g_null_settings_backend_get_type ())
30 #define G_NULL_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
31 G_TYPE_NULL_SETTINGS_BACKEND, \
32 GNullSettingsBackend))
35 typedef GSettingsBackendClass GNullSettingsBackendClass;
36 typedef GSettingsBackend GNullSettingsBackend;
38 G_DEFINE_TYPE_WITH_CODE (GNullSettingsBackend,
39 g_null_settings_backend,
40 G_TYPE_SETTINGS_BACKEND,
41 g_io_extension_point_implement (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME,
42 g_define_type_id, "null", 10))
44 static GVariant *
45 g_null_settings_backend_read (GSettingsBackend *backend,
46 const gchar *key,
47 const GVariantType *expected_type,
48 gboolean default_value)
50 return NULL;
53 static gboolean
54 g_null_settings_backend_write (GSettingsBackend *backend,
55 const gchar *key,
56 GVariant *value,
57 gpointer origin_tag)
59 if (value)
60 g_variant_unref (g_variant_ref_sink (value));
61 return FALSE;
64 static gboolean
65 g_null_settings_backend_write_one (gpointer key,
66 gpointer value,
67 gpointer data)
69 if (value)
70 g_variant_unref (g_variant_ref_sink (value));
71 return FALSE;
74 static gboolean
75 g_null_settings_backend_write_tree (GSettingsBackend *backend,
76 GTree *tree,
77 gpointer origin_tag)
79 g_tree_foreach (tree, g_null_settings_backend_write_one, backend);
80 return FALSE;
83 static void
84 g_null_settings_backend_reset (GSettingsBackend *backend,
85 const gchar *key,
86 gpointer origin_tag)
90 static gboolean
91 g_null_settings_backend_get_writable (GSettingsBackend *backend,
92 const gchar *name)
94 return FALSE;
97 static GPermission *
98 g_null_settings_backend_get_permission (GSettingsBackend *backend,
99 const gchar *path)
101 return g_simple_permission_new (FALSE);
104 static void
105 g_null_settings_backend_init (GNullSettingsBackend *memory)
109 static void
110 g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
112 GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
114 backend_class->read = g_null_settings_backend_read;
115 backend_class->write = g_null_settings_backend_write;
116 backend_class->write_tree = g_null_settings_backend_write_tree;
117 backend_class->reset = g_null_settings_backend_reset;
118 backend_class->get_writable = g_null_settings_backend_get_writable;
119 backend_class->get_permission = g_null_settings_backend_get_permission;
123 * g_null_settings_backend_new:
126 * Creates a readonly #GSettingsBackend.
128 * This backend does not allow changes to settings, so all settings
129 * will always have their default values.
131 * Returns: (transfer full): a newly created #GSettingsBackend
133 * Since: 2.28
135 GSettingsBackend *
136 g_null_settings_backend_new (void)
138 return g_object_new (G_TYPE_NULL_SETTINGS_BACKEND, NULL);