mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 22:52:09 +01:00
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
This commit is contained in:
parent
62206576c3
commit
698970f1f7
@ -306,8 +306,8 @@ static void
|
|||||||
delayed_backend_keys_changed (GObject *target,
|
delayed_backend_keys_changed (GObject *target,
|
||||||
GSettingsBackend *backend,
|
GSettingsBackend *backend,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar * const *items,
|
gpointer origin_tag,
|
||||||
gpointer origin_tag)
|
const gchar * const *items)
|
||||||
{
|
{
|
||||||
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (target);
|
GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (target);
|
||||||
|
|
||||||
|
@ -357,8 +357,8 @@ static void
|
|||||||
settings_backend_keys_changed (GObject *target,
|
settings_backend_keys_changed (GObject *target,
|
||||||
GSettingsBackend *backend,
|
GSettingsBackend *backend,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar * const *items,
|
gpointer origin_tag,
|
||||||
gpointer origin_tag)
|
const gchar * const *items)
|
||||||
{
|
{
|
||||||
GSettings *settings = G_SETTINGS (target);
|
GSettings *settings = G_SETTINGS (target);
|
||||||
gboolean ignore_this;
|
gboolean ignore_this;
|
||||||
|
@ -133,15 +133,14 @@ struct _GSettingsBackendClosure
|
|||||||
void (*function) (GObject *target,
|
void (*function) (GObject *target,
|
||||||
GSettingsBackend *backend,
|
GSettingsBackend *backend,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer data1,
|
gpointer origin_tag,
|
||||||
gpointer data2);
|
gchar **names);
|
||||||
|
|
||||||
GSettingsBackend *backend;
|
|
||||||
GObject *target;
|
GObject *target;
|
||||||
|
GSettingsBackend *backend;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gpointer data1;
|
gpointer origin_tag;
|
||||||
GBoxedFreeFunc data1_free;
|
gchar **names;
|
||||||
gpointer data2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -265,11 +264,11 @@ g_settings_backend_invoke_closure (gpointer user_data)
|
|||||||
GSettingsBackendClosure *closure = user_data;
|
GSettingsBackendClosure *closure = user_data;
|
||||||
|
|
||||||
closure->function (closure->target, closure->backend, closure->name,
|
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->backend);
|
||||||
g_object_unref (closure->target);
|
g_object_unref (closure->target);
|
||||||
|
g_strfreev (closure->names);
|
||||||
g_free (closure->name);
|
g_free (closure->name);
|
||||||
|
|
||||||
g_slice_free (GSettingsBackendClosure, closure);
|
g_slice_free (GSettingsBackendClosure, closure);
|
||||||
@ -277,34 +276,15 @@ g_settings_backend_invoke_closure (gpointer user_data)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
|
||||||
pointer_id (gpointer a)
|
|
||||||
{
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pointer_ignore (gpointer a)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_settings_backend_dispatch_signal (GSettingsBackend *backend,
|
g_settings_backend_dispatch_signal (GSettingsBackend *backend,
|
||||||
gsize function_offset,
|
gsize function_offset,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer data1,
|
gpointer origin_tag,
|
||||||
GBoxedCopyFunc data1_copy,
|
const gchar * const *names)
|
||||||
GBoxedFreeFunc data1_free,
|
|
||||||
gpointer data2)
|
|
||||||
{
|
{
|
||||||
GSettingsBackendWatch *suffix, *watch, *next;
|
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
|
/* 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
|
* a lock while traversing the list, but we don't want to hold the
|
||||||
* lock while calling back into user code.
|
* lock while calling back into user code.
|
||||||
@ -336,9 +316,8 @@ g_settings_backend_dispatch_signal (GSettingsBackend *backend,
|
|||||||
closure->function = G_STRUCT_MEMBER (void *, watch->vtable,
|
closure->function = G_STRUCT_MEMBER (void *, watch->vtable,
|
||||||
function_offset);
|
function_offset);
|
||||||
closure->name = g_strdup (name);
|
closure->name = g_strdup (name);
|
||||||
closure->data1 = data1_copy (data1);
|
closure->origin_tag = origin_tag;
|
||||||
closure->data1_free = data1_free;
|
closure->names = g_strdupv ((gchar **) names);
|
||||||
closure->data2 = data2;
|
|
||||||
|
|
||||||
/* we do this here because 'watch' may not live to the end of this
|
/* 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).
|
* iteration of the loop (since we may unref the target below).
|
||||||
@ -396,7 +375,7 @@ g_settings_backend_changed (GSettingsBackend *backend,
|
|||||||
g_settings_backend_dispatch_signal (backend,
|
g_settings_backend_dispatch_signal (backend,
|
||||||
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
||||||
changed),
|
changed),
|
||||||
key, origin_tag, NULL, NULL, NULL);
|
key, origin_tag, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,10 +424,7 @@ g_settings_backend_keys_changed (GSettingsBackend *backend,
|
|||||||
g_settings_backend_dispatch_signal (backend,
|
g_settings_backend_dispatch_signal (backend,
|
||||||
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
||||||
keys_changed),
|
keys_changed),
|
||||||
path, (gpointer) items,
|
path, origin_tag, items);
|
||||||
(GBoxedCopyFunc) g_strdupv,
|
|
||||||
(GBoxedFreeFunc) g_strfreev,
|
|
||||||
origin_tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,7 +468,7 @@ g_settings_backend_path_changed (GSettingsBackend *backend,
|
|||||||
g_settings_backend_dispatch_signal (backend,
|
g_settings_backend_dispatch_signal (backend,
|
||||||
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
||||||
path_changed),
|
path_changed),
|
||||||
path, origin_tag, NULL, NULL, NULL);
|
path, origin_tag, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -517,7 +493,7 @@ g_settings_backend_writable_changed (GSettingsBackend *backend,
|
|||||||
g_settings_backend_dispatch_signal (backend,
|
g_settings_backend_dispatch_signal (backend,
|
||||||
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
||||||
writable_changed),
|
writable_changed),
|
||||||
key, NULL, NULL, NULL, NULL);
|
key, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -543,7 +519,7 @@ g_settings_backend_path_writable_changed (GSettingsBackend *backend,
|
|||||||
g_settings_backend_dispatch_signal (backend,
|
g_settings_backend_dispatch_signal (backend,
|
||||||
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
G_STRUCT_OFFSET (GSettingsListenerVTable,
|
||||||
path_writable_changed),
|
path_writable_changed),
|
||||||
path, NULL, NULL, NULL, NULL);
|
path, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -37,8 +37,8 @@ typedef struct
|
|||||||
void (* keys_changed) (GObject *target,
|
void (* keys_changed) (GObject *target,
|
||||||
GSettingsBackend *backend,
|
GSettingsBackend *backend,
|
||||||
const gchar *prefix,
|
const gchar *prefix,
|
||||||
const gchar * const *names,
|
gpointer origin_tag,
|
||||||
gpointer origin_tag);
|
const gchar * const *names);
|
||||||
void (* writable_changed) (GObject *target,
|
void (* writable_changed) (GObject *target,
|
||||||
GSettingsBackend *backend,
|
GSettingsBackend *backend,
|
||||||
const gchar *key);
|
const gchar *key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user