mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 11:12:11 +01:00
drop GDelayedSettingsBackend
This breaks the tests, but will be added back in another form soon.
This commit is contained in:
parent
c16ab82d7b
commit
fec18bb76a
@ -118,8 +118,6 @@ settings_sources = \
|
|||||||
gvdb/gvdb-format.h \
|
gvdb/gvdb-format.h \
|
||||||
gvdb/gvdb-reader.h \
|
gvdb/gvdb-reader.h \
|
||||||
gvdb/gvdb-reader.c \
|
gvdb/gvdb-reader.c \
|
||||||
gdelayedsettingsbackend.h \
|
|
||||||
gdelayedsettingsbackend.c \
|
|
||||||
gkeyfilesettingsbackend.c \
|
gkeyfilesettingsbackend.c \
|
||||||
gmemorysettingsbackend.c \
|
gmemorysettingsbackend.c \
|
||||||
gnullsettingsbackend.c \
|
gnullsettingsbackend.c \
|
||||||
|
@ -1,284 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2009, 2010 Codethink Limited
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the licence, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*
|
|
||||||
* Author: Ryan Lortie <desrt@desrt.ca>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "gdelayedsettingsbackend.h"
|
|
||||||
#include "gsettingsbackendinternal.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
struct _GDelayedSettingsBackendPrivate
|
|
||||||
{
|
|
||||||
GSettingsBackend *backend;
|
|
||||||
GMutex lock;
|
|
||||||
GTree *delayed;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GDelayedSettingsBackend,
|
|
||||||
g_delayed_settings_backend,
|
|
||||||
G_TYPE_SETTINGS_BACKEND)
|
|
||||||
|
|
||||||
static GVariant *
|
|
||||||
g_delayed_settings_backend_read (GSettingsBackend *backend,
|
|
||||||
const gchar *key,
|
|
||||||
const GVariantType *expected_type,
|
|
||||||
gboolean default_value)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
gpointer result = NULL;
|
|
||||||
|
|
||||||
if (!default_value)
|
|
||||||
{
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
if (g_tree_lookup_extended (delayed->priv->delayed, key, NULL, &result))
|
|
||||||
{
|
|
||||||
/* NULL in the tree means we should consult the default value */
|
|
||||||
if (result != NULL)
|
|
||||||
g_variant_ref (result);
|
|
||||||
else
|
|
||||||
default_value = TRUE;
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == NULL)
|
|
||||||
result = g_settings_backend_read (delayed->priv->backend, key,
|
|
||||||
expected_type, default_value);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
g_delayed_settings_backend_write (GSettingsBackend *backend,
|
|
||||||
const gchar *key,
|
|
||||||
GVariant *value,
|
|
||||||
gpointer origin_tag)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
g_tree_insert (delayed->priv->delayed, g_strdup (key), g_variant_ref_sink (value));
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
|
|
||||||
g_settings_backend_changed (backend, key, origin_tag);
|
|
||||||
g_settings_backend_set_has_unapplied (backend, TRUE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
add_to_tree (gpointer key,
|
|
||||||
gpointer value,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
g_tree_insert (user_data, g_strdup (key), g_variant_ref (value));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
g_delayed_settings_backend_write_tree (GSettingsBackend *backend,
|
|
||||||
GTree *tree,
|
|
||||||
gpointer origin_tag)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
g_tree_foreach (tree, add_to_tree, delayed->priv->delayed);
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
|
|
||||||
g_settings_backend_changed_tree (backend, tree, origin_tag);
|
|
||||||
g_settings_backend_set_has_unapplied (backend, TRUE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
g_delayed_settings_backend_get_writable (GSettingsBackend *backend,
|
|
||||||
const gchar *name)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
return g_settings_backend_get_writable (delayed->priv->backend, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_reset (GSettingsBackend *backend,
|
|
||||||
const gchar *key,
|
|
||||||
gpointer origin_tag)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
g_tree_insert (delayed->priv->delayed, g_strdup (key), NULL);
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
|
|
||||||
g_settings_backend_changed (backend, key, origin_tag);
|
|
||||||
g_settings_backend_set_has_unapplied (backend, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_subscribe (GSettingsBackend *backend,
|
|
||||||
const char *name)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
g_settings_backend_subscribe (delayed->priv->backend, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_unsubscribe (GSettingsBackend *backend,
|
|
||||||
const char *name)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
g_settings_backend_unsubscribe (delayed->priv->backend, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GPermission *
|
|
||||||
g_delayed_settings_backend_get_permission (GSettingsBackend *backend,
|
|
||||||
const gchar *path)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
return g_settings_backend_get_permission (delayed->priv->backend, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* method calls */
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_apply (GSettingsBackend *backend)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
if (g_tree_nnodes (delayed->priv->delayed) > 0)
|
|
||||||
{
|
|
||||||
gboolean success;
|
|
||||||
GTree *tmp;
|
|
||||||
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
tmp = delayed->priv->delayed;
|
|
||||||
delayed->priv->delayed = g_settings_backend_create_tree ();
|
|
||||||
success = g_settings_backend_write_tree (delayed->priv->backend,
|
|
||||||
tmp, delayed->priv);
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
|
|
||||||
if (!success)
|
|
||||||
g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed),
|
|
||||||
tmp, NULL);
|
|
||||||
|
|
||||||
g_tree_unref (tmp);
|
|
||||||
|
|
||||||
g_settings_backend_set_has_unapplied (G_SETTINGS_BACKEND (delayed), FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_revert (GSettingsBackend *backend)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
|
|
||||||
|
|
||||||
if (g_tree_nnodes (delayed->priv->delayed) > 0)
|
|
||||||
{
|
|
||||||
GTree *tmp;
|
|
||||||
|
|
||||||
g_mutex_lock (&delayed->priv->lock);
|
|
||||||
tmp = delayed->priv->delayed;
|
|
||||||
delayed->priv->delayed = g_settings_backend_create_tree ();
|
|
||||||
g_mutex_unlock (&delayed->priv->lock);
|
|
||||||
g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed), tmp, NULL);
|
|
||||||
g_tree_unref (tmp);
|
|
||||||
|
|
||||||
g_settings_backend_set_has_unapplied (G_SETTINGS_BACKEND (delayed), FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_got_event (GSettingsBackend *backend,
|
|
||||||
const GSettingsEvent *event,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = user_data;
|
|
||||||
|
|
||||||
if (event->origin_tag != delayed->priv)
|
|
||||||
g_settings_backend_event (G_SETTINGS_BACKEND (delayed), event);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (object);
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (delayed->priv->backend, g_delayed_settings_got_event, delayed);
|
|
||||||
g_mutex_clear (&delayed->priv->lock);
|
|
||||||
g_object_unref (delayed->priv->backend);
|
|
||||||
g_tree_unref (delayed->priv->delayed);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_delayed_settings_backend_parent_class)
|
|
||||||
->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_class_init (GDelayedSettingsBackendClass *class)
|
|
||||||
{
|
|
||||||
GSettingsBackendClass *backend_class = G_SETTINGS_BACKEND_CLASS (class);
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
||||||
|
|
||||||
g_type_class_add_private (class, sizeof (GDelayedSettingsBackendPrivate));
|
|
||||||
|
|
||||||
backend_class->read = g_delayed_settings_backend_read;
|
|
||||||
backend_class->write = g_delayed_settings_backend_write;
|
|
||||||
backend_class->write_tree = g_delayed_settings_backend_write_tree;
|
|
||||||
backend_class->reset = g_delayed_settings_backend_reset;
|
|
||||||
backend_class->get_writable = g_delayed_settings_backend_get_writable;
|
|
||||||
backend_class->subscribe = g_delayed_settings_backend_subscribe;
|
|
||||||
backend_class->unsubscribe = g_delayed_settings_backend_unsubscribe;
|
|
||||||
backend_class->get_permission = g_delayed_settings_backend_get_permission;
|
|
||||||
backend_class->apply = g_delayed_settings_backend_apply;
|
|
||||||
backend_class->revert = g_delayed_settings_backend_revert;
|
|
||||||
|
|
||||||
object_class->finalize = g_delayed_settings_backend_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_delayed_settings_backend_init (GDelayedSettingsBackend *delayed)
|
|
||||||
{
|
|
||||||
delayed->priv =
|
|
||||||
G_TYPE_INSTANCE_GET_PRIVATE (delayed, G_TYPE_DELAYED_SETTINGS_BACKEND,
|
|
||||||
GDelayedSettingsBackendPrivate);
|
|
||||||
|
|
||||||
delayed->priv->delayed = g_settings_backend_create_tree ();
|
|
||||||
g_mutex_init (&delayed->priv->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
GSettingsBackend *
|
|
||||||
g_delayed_settings_backend_new (GSettingsBackend *backend)
|
|
||||||
{
|
|
||||||
GDelayedSettingsBackend *delayed;
|
|
||||||
|
|
||||||
delayed = g_object_new (G_TYPE_DELAYED_SETTINGS_BACKEND, NULL);
|
|
||||||
delayed->priv->backend = g_object_ref (backend);
|
|
||||||
|
|
||||||
g_signal_connect_object (delayed->priv->backend, "event", G_CALLBACK (g_delayed_settings_got_event), delayed, 0);
|
|
||||||
|
|
||||||
return G_SETTINGS_BACKEND (delayed);
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2009, 2010 Codethink Limited
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the licence, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*
|
|
||||||
* Author: Ryan Lortie <desrt@desrt.ca>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __G_DELAYED_SETTINGS_BACKEND_H__
|
|
||||||
#define __G_DELAYED_SETTINGS_BACKEND_H__
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
#include <gio/gsettingsbackend.h>
|
|
||||||
|
|
||||||
#define G_TYPE_DELAYED_SETTINGS_BACKEND (g_delayed_settings_backend_get_type ())
|
|
||||||
#define G_DELAYED_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
|
|
||||||
G_TYPE_DELAYED_SETTINGS_BACKEND, \
|
|
||||||
GDelayedSettingsBackend))
|
|
||||||
#define G_DELAYED_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
|
|
||||||
G_TYPE_DELAYED_SETTINGS_BACKEND, \
|
|
||||||
GDelayedSettingsBackendClass))
|
|
||||||
#define G_IS_DELAYED_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
|
|
||||||
G_TYPE_DELAYED_SETTINGS_BACKEND))
|
|
||||||
#define G_IS_DELAYED_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
|
|
||||||
G_TYPE_DELAYED_SETTINGS_BACKEND))
|
|
||||||
#define G_DELAYED_SETTINGS_BACKEND_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
|
|
||||||
G_TYPE_DELAYED_SETTINGS_BACKEND, \
|
|
||||||
GDelayedSettingsBackendClass))
|
|
||||||
|
|
||||||
typedef struct _GDelayedSettingsBackendPrivate GDelayedSettingsBackendPrivate;
|
|
||||||
typedef struct _GDelayedSettingsBackendClass GDelayedSettingsBackendClass;
|
|
||||||
typedef struct _GDelayedSettingsBackend GDelayedSettingsBackend;
|
|
||||||
|
|
||||||
struct _GDelayedSettingsBackendClass
|
|
||||||
{
|
|
||||||
GSettingsBackendClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GDelayedSettingsBackend
|
|
||||||
{
|
|
||||||
GSettingsBackend parent_instance;
|
|
||||||
GDelayedSettingsBackendPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GType g_delayed_settings_backend_get_type (void);
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GSettingsBackend * g_delayed_settings_backend_new (GSettingsBackend *backend);
|
|
||||||
|
|
||||||
#endif /* __G_DELAYED_SETTINGS_BACKEND_H__ */
|
|
@ -24,7 +24,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gsettingsbackendinternal.h"
|
#include "gsettingsbackendinternal.h"
|
||||||
#include "gdelayedsettingsbackend.h"
|
|
||||||
#include "gsimplepermission.h"
|
#include "gsimplepermission.h"
|
||||||
#include "giomodule-priv.h"
|
#include "giomodule-priv.h"
|
||||||
|
|
||||||
@ -712,7 +711,7 @@ ignore_subscription (GSettingsBackend *backend,
|
|||||||
static GSettingsBackend *
|
static GSettingsBackend *
|
||||||
g_settings_backend_real_delay (GSettingsBackend *backend)
|
g_settings_backend_real_delay (GSettingsBackend *backend)
|
||||||
{
|
{
|
||||||
return g_delayed_settings_backend_new (backend);
|
return g_null_settings_backend_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user