[Xfce4-commits] [xfce/xfconf] 06/10: Use string type for properties that do not map to xfconf.
noreply at xfce.org
noreply at xfce.org
Sun Oct 21 12:05:13 CEST 2018
This is an automated email from the git hooks/post-receive script.
a l i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfconf.
commit a4b35157ac9661d40b7d9a384a12dd3b3751fe58
Author: Ali Abdallah <ali at xfce.org>
Date: Sat Jul 14 01:53:20 2018 +0200
Use string type for properties that do not map to xfconf.
---
gsettings-backend/xfconf-gsettings-backend.c | 57 +++++++++++++++++++++-------
1 file changed, 43 insertions(+), 14 deletions(-)
diff --git a/gsettings-backend/xfconf-gsettings-backend.c b/gsettings-backend/xfconf-gsettings-backend.c
index ff7d664..15746ea 100644
--- a/gsettings-backend/xfconf-gsettings-backend.c
+++ b/gsettings-backend/xfconf-gsettings-backend.c
@@ -25,6 +25,8 @@
#include <glib.h>
#include "xfconf/xfconf.h"
+#include "xfconf/xfconf-private.h"
+
#include "common/xfconf-gvaluefuncs.h"
#include "xfconf-gsettings-backend.h"
@@ -102,19 +104,27 @@ xfconf_gsettings_backend_read (GSettingsBackend *backend,
return NULL;
variant = xfconf_gvalue_to_gvariant (&value);
- g_value_unset (&value);
+ /* Set it as a string type */
if (!g_variant_is_of_type (variant, expected_type)) {
+ GError *error = NULL;
gchar *type_str;
type_str = g_variant_type_dup_string (expected_type);
- g_critical ("Property '%s' expected type is '%s' => '%s' found!",
- key, type_str, g_variant_get_type_string(variant) );
- g_free(type_str);
+
g_variant_unref(variant);
- return NULL;
+ variant = g_variant_parse (expected_type, g_value_get_string(&value), NULL, NULL, &error);
+
+ if (error) {
+ g_critical ("Failed to handle property '%s' with expected type '%s' => %s",
+ key, type_str, error->message);
+ g_error_free (error);
+ return (NULL);
+ }
+ g_free(type_str);
}
+ g_value_unset (&value);
return variant;
}
@@ -152,23 +162,33 @@ xfconf_gsettings_backend_write_full (GSettingsBackend *backend,
{
XfconfGsettingsBackend *self;
GValue *value;
+ gchar *var_str;
gboolean ret_val;
self = XFCONF_GSETTINGS_BACKEND(backend);
- value = xfconf_gvariant_to_gvalue (variant);
+ g_debug("Writing property %s variant %s\n", key, g_variant_get_type_string(variant));
- if (value) {
- if (add_sig_changed)
- g_hash_table_replace (self->changed_prop, g_strdup(key), origin_tag);
+ value = xfconf_gvariant_to_gvalue (variant);
- ret_val = xfconf_channel_set_property (self->channel, key, value);
- if (ret_val == FALSE && add_sig_changed)
- g_hash_table_remove (self->changed_prop, key);
+ if (value == NULL) {
+ value = g_new0 (GValue, 1);
+ var_str = g_variant_print(variant, FALSE);
- g_value_unset (value);
- g_free (value);
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, var_str);
}
+
+ if (add_sig_changed)
+ g_hash_table_replace (self->changed_prop, g_strdup(key), origin_tag);
+
+ ret_val = xfconf_channel_set_property (self->channel, key, value);
+ if (ret_val == FALSE && add_sig_changed)
+ g_hash_table_remove (self->changed_prop, key);
+
+ g_value_unset (value);
+ g_free (value);
+
return FALSE;
}
@@ -244,6 +264,14 @@ xfconf_gsettings_backend_unsubscribe (GSettingsBackend *backend,
}
+static void
+xfconf_gsettings_backend_sync (GSettingsBackend *backend)
+{
+ GDBusConnection *bus;
+ bus = _xfconf_get_gdbus_connection ();
+ g_dbus_connection_flush_sync (bus, NULL, NULL);
+}
+
static gboolean
xfconf_gsettings_backend_has_prefix (gconstpointer v1,
gconstpointer v2)
@@ -297,6 +325,7 @@ xfconf_gsettings_backend_class_init (XfconfGsettingsBackendClass *klass)
gsettings_class->write = xfconf_gsettings_backend_write;
gsettings_class->subscribe = xfconf_gsettings_backend_subscribe;
gsettings_class->unsubscribe = xfconf_gsettings_backend_unsubscribe;
+ gsettings_class->sync = xfconf_gsettings_backend_sync;
object_class->finalize = (void (*) (GObject *object)) xfconf_gsettings_backend_finalize;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list