[glib/glib-2-38] gsettingsbackend: a minor simplification
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-38] gsettingsbackend: a minor simplification
- Date: Sat, 5 Apr 2014 08:39:19 +0000 (UTC)
commit 512a1a63be56c1fde8533f092ff36028a134716a
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Feb 26 17:09:59 2014 -0500
gsettingsbackend: a minor simplification
Change the order of the arguments on the (internal) keys_changed callback in
GSettingsListenerVTable.
This means that all functions in the table now fit the following signature:
void (* f) (GObject *target,
GSettingsBackend *backend,
const gchar *name_or_path,
gpointer origin_tag,
const gchar * const *names);
allowing the possibility of arguments ignored at the end.
This allows us to simplify our dispatch-to-thread code in GSettingsBackend,
making it a bit less generic.
So far, this should be a straight refactor.
https://bugzilla.gnome.org/show_bug.cgi?id=710367
gio/gdelayedsettingsbackend.c | 4 +-
gio/gsettings.c | 4 +-
gio/gsettingsbackend.c | 74 +++++++++++++--------------------------
gio/gsettingsbackendinternal.h | 4 +-
4 files changed, 31 insertions(+), 55 deletions(-)
---
diff --git a/gio/gdelayedsettingsbackend.c b/gio/gdelayedsettingsbackend.c
index 6c1866b..78a9c5e 100644
--- a/gio/gdelayedsettingsbackend.c
+++ b/gio/gdelayedsettingsbackend.c
@@ -282,8 +282,8 @@ static void
delayed_backend_keys_changed (GObject *target,
GSettingsBackend *backend,
const gchar *path,
- const gchar * const *items,
- gpointer origin_tag)
+ gpointer origin_tag,
+ const gchar * const *items)
{
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (target);
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 2f23f09..c7d2764 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -368,8 +368,8 @@ static void
settings_backend_keys_changed (GObject *target,
GSettingsBackend *backend,
const gchar *path,
- const gchar * const *items,
- gpointer origin_tag)
+ gpointer origin_tag,
+ const gchar * const *items)
{
GSettings *settings = G_SETTINGS (target);
gboolean ignore_this;
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 608a452..315d722 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -134,18 +134,17 @@ struct _GSettingsBackendWatch
struct _GSettingsBackendClosure
{
- void (*function) (GObject *target,
- GSettingsBackend *backend,
- const gchar *name,
- gpointer data1,
- gpointer data2);
-
- GSettingsBackend *backend;
- GObject *target;
- gchar *name;
- gpointer data1;
- GBoxedFreeFunc data1_free;
- gpointer data2;
+ void (*function) (GObject *target,
+ GSettingsBackend *backend,
+ const gchar *name,
+ gpointer origin_tag,
+ gchar **names);
+
+ GObject *target;
+ GSettingsBackend *backend;
+ gchar *name;
+ gpointer origin_tag;
+ gchar **names;
};
static void
@@ -269,11 +268,11 @@ g_settings_backend_invoke_closure (gpointer user_data)
GSettingsBackendClosure *closure = user_data;
closure->function (closure->target, closure->backend, closure->name,
- closure->data1, closure->data2);
+ closure->origin_tag, closure->names);
- closure->data1_free (closure->data1);
g_object_unref (closure->backend);
g_object_unref (closure->target);
+ g_strfreev (closure->names);
g_free (closure->name);
g_slice_free (GSettingsBackendClosure, closure);
@@ -281,34 +280,15 @@ g_settings_backend_invoke_closure (gpointer user_data)
return FALSE;
}
-static gpointer
-pointer_id (gpointer a)
-{
- return a;
-}
-
static void
-pointer_ignore (gpointer a)
-{
-}
-
-static void
-g_settings_backend_dispatch_signal (GSettingsBackend *backend,
- gsize function_offset,
- const gchar *name,
- gpointer data1,
- GBoxedCopyFunc data1_copy,
- GBoxedFreeFunc data1_free,
- gpointer data2)
+g_settings_backend_dispatch_signal (GSettingsBackend *backend,
+ gsize function_offset,
+ const gchar *name,
+ gpointer origin_tag,
+ const gchar * const *names)
{
GSettingsBackendWatch *suffix, *watch, *next;
- if (data1_copy == NULL)
- data1_copy = pointer_id;
-
- if (data1_free == NULL)
- data1_free = pointer_ignore;
-
/* We're in a little bit of a tricky situation here. We need to hold
* a lock while traversing the list, but we don't want to hold the
* lock while calling back into user code.
@@ -340,9 +320,8 @@ g_settings_backend_dispatch_signal (GSettingsBackend *backend,
closure->function = G_STRUCT_MEMBER (void *, watch->vtable,
function_offset);
closure->name = g_strdup (name);
- closure->data1 = data1_copy (data1);
- closure->data1_free = data1_free;
- closure->data2 = data2;
+ closure->origin_tag = origin_tag;
+ closure->names = g_strdupv ((gchar **) names);
/* we do this here because 'watch' may not live to the end of this
* iteration of the loop (since we may unref the target below).
@@ -400,7 +379,7 @@ g_settings_backend_changed (GSettingsBackend *backend,
g_settings_backend_dispatch_signal (backend,
G_STRUCT_OFFSET (GSettingsListenerVTable,
changed),
- key, origin_tag, NULL, NULL, NULL);
+ key, origin_tag, NULL);
}
/**
@@ -449,10 +428,7 @@ g_settings_backend_keys_changed (GSettingsBackend *backend,
g_settings_backend_dispatch_signal (backend,
G_STRUCT_OFFSET (GSettingsListenerVTable,
keys_changed),
- path, (gpointer) items,
- (GBoxedCopyFunc) g_strdupv,
- (GBoxedFreeFunc) g_strfreev,
- origin_tag);
+ path, origin_tag, items);
}
/**
@@ -496,7 +472,7 @@ g_settings_backend_path_changed (GSettingsBackend *backend,
g_settings_backend_dispatch_signal (backend,
G_STRUCT_OFFSET (GSettingsListenerVTable,
path_changed),
- path, origin_tag, NULL, NULL, NULL);
+ path, origin_tag, NULL);
}
/**
@@ -521,7 +497,7 @@ g_settings_backend_writable_changed (GSettingsBackend *backend,
g_settings_backend_dispatch_signal (backend,
G_STRUCT_OFFSET (GSettingsListenerVTable,
writable_changed),
- key, NULL, NULL, NULL, NULL);
+ key, NULL, NULL);
}
/**
@@ -547,7 +523,7 @@ g_settings_backend_path_writable_changed (GSettingsBackend *backend,
g_settings_backend_dispatch_signal (backend,
G_STRUCT_OFFSET (GSettingsListenerVTable,
path_writable_changed),
- path, NULL, NULL, NULL, NULL);
+ path, NULL, NULL);
}
typedef struct
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index f782c7c..82b2cd0 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -39,8 +39,8 @@ typedef struct
void (* keys_changed) (GObject *target,
GSettingsBackend *backend,
const gchar *prefix,
- const gchar * const *names,
- gpointer origin_tag);
+ gpointer origin_tag,
+ const gchar * const *names);
void (* writable_changed) (GObject *target,
GSettingsBackend *backend,
const gchar *key);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]