mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
add get_permission API to GSettingsBackend
implement it in the various in-tree backends also, lots of whitespace changes to realign the vtable members
This commit is contained in:
parent
95c564cabe
commit
61f3f45cb9
@ -202,6 +202,16 @@ g_delayed_settings_backend_unsubscribe (GSettingsBackend *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 */
|
||||
gboolean
|
||||
g_delayed_settings_backend_get_has_unapplied (GDelayedSettingsBackend *delayed)
|
||||
@ -419,6 +429,7 @@ g_delayed_settings_backend_class_init (GDelayedSettingsBackendClass *class)
|
||||
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;
|
||||
|
||||
object_class->finalize = g_delayed_settings_backend_finalize;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "gfile.h"
|
||||
#include "gfileinfo.h"
|
||||
#include "gfilemonitor.h"
|
||||
#include "gsimplepermission.h"
|
||||
|
||||
#include "gioalias.h"
|
||||
|
||||
@ -244,6 +245,13 @@ g_keyfile_settings_backend_get_writable (GSettingsBackend *backend,
|
||||
return kf_backend->priv->writable;
|
||||
}
|
||||
|
||||
static GPermission *
|
||||
g_keyfile_settings_backend_get_permission (GSettingsBackend *backend,
|
||||
const gchar *path)
|
||||
{
|
||||
return g_simple_permission_new (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
g_keyfile_settings_backend_keyfile_reload (GKeyfileSettingsBackend *kf_backend)
|
||||
{
|
||||
@ -499,6 +507,7 @@ g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class)
|
||||
backend_class->reset = g_keyfile_settings_backend_reset;
|
||||
backend_class->reset_path = g_keyfile_settings_backend_reset_path;
|
||||
backend_class->get_writable = g_keyfile_settings_backend_get_writable;
|
||||
backend_class->get_permission = g_keyfile_settings_backend_get_permission;
|
||||
/* No need to implement subscribed/unsubscribe: the only point would be to
|
||||
* stop monitoring the file when there's no GSettings anymore, which is no
|
||||
* big win. */
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gmemorysettingsbackend.h"
|
||||
#include "gsimplepermission.h"
|
||||
#include "gsettingsbackend.h"
|
||||
#include "giomodule.h"
|
||||
|
||||
@ -118,6 +119,13 @@ g_memory_settings_backend_get_writable (GSettingsBackend *backend,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GPermission *
|
||||
g_memory_settings_backend_get_permission (GSettingsBackend *backend,
|
||||
const gchar *path)
|
||||
{
|
||||
return g_simple_permission_new (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
g_memory_settings_backend_finalize (GObject *object)
|
||||
{
|
||||
@ -146,5 +154,6 @@ g_memory_settings_backend_class_init (GMemorySettingsBackendClass *class)
|
||||
backend_class->write = g_memory_settings_backend_write;
|
||||
backend_class->write_keys = g_memory_settings_backend_write_keys;
|
||||
backend_class->get_writable = g_memory_settings_backend_get_writable;
|
||||
backend_class->get_permission = g_memory_settings_backend_get_permission;
|
||||
object_class->finalize = g_memory_settings_backend_finalize;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gnullsettingsbackend.h"
|
||||
#include "gsimplepermission.h"
|
||||
|
||||
#include "gioalias.h"
|
||||
|
||||
@ -81,11 +82,18 @@ g_null_settings_backend_reset_path (GSettingsBackend *backend,
|
||||
|
||||
static gboolean
|
||||
g_null_settings_backend_get_writable (GSettingsBackend *backend,
|
||||
const gchar *name)
|
||||
const gchar *name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GPermission *
|
||||
g_null_settings_backend_get_permission (GSettingsBackend *backend,
|
||||
const gchar *path)
|
||||
{
|
||||
return g_simple_permission_new (FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
g_null_settings_backend_init (GNullSettingsBackend *memory)
|
||||
{
|
||||
@ -102,6 +110,7 @@ g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
|
||||
backend_class->reset = g_null_settings_backend_reset;
|
||||
backend_class->reset_path = g_null_settings_backend_reset_path;
|
||||
backend_class->get_writable = g_null_settings_backend_get_writable;
|
||||
backend_class->get_permission = g_null_settings_backend_get_permission;
|
||||
}
|
||||
|
||||
GSettingsBackend *
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "gsettingsbackendinternal.h"
|
||||
#include "gnullsettingsbackend.h"
|
||||
#include "gsimplepermission.h"
|
||||
#include "giomodule-priv.h"
|
||||
#include "gio-marshal.h"
|
||||
|
||||
@ -1156,6 +1157,30 @@ g_settings_backend_supports_context (const gchar *context)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* g_settings_backend_get_permission:
|
||||
* @backend: a #GSettingsBackend
|
||||
* @path: a path
|
||||
* @returns: a non-%NULL #GPermission
|
||||
*
|
||||
* Gets the permission object associated with writing to keys below
|
||||
* @path on @backend.
|
||||
*
|
||||
* If this is not implemented in the backend, then a %TRUE
|
||||
* #GSimplePermission is returned.
|
||||
*/
|
||||
GPermission *
|
||||
g_settings_backend_get_permission (GSettingsBackend *backend,
|
||||
const gchar *path)
|
||||
{
|
||||
GSettingsBackendClass *class = G_SETTINGS_BACKEND_GET_CLASS (backend);
|
||||
|
||||
if (class->get_permission)
|
||||
return class->get_permission (backend, path);
|
||||
|
||||
return g_simple_permission_new (TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_settings_backend_setup:
|
||||
* @context: a context string (not %NULL or "")
|
||||
|
@ -67,39 +67,42 @@ struct _GSettingsBackendClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
gboolean (*supports_context) (const gchar *context);
|
||||
gboolean (*supports_context) (const gchar *context);
|
||||
|
||||
GVariant * (*read) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
const GVariantType *expected_type,
|
||||
gboolean default_value);
|
||||
gchar ** (*list) (GSettingsBackend *backend,
|
||||
const gchar *path,
|
||||
gchar **resets,
|
||||
gsize n_resets,
|
||||
gsize *length);
|
||||
gboolean (*write) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
GVariant *value,
|
||||
gpointer origin_tag);
|
||||
gboolean (*write_keys) (GSettingsBackend *backend,
|
||||
GTree *tree,
|
||||
gpointer origin_tag);
|
||||
void (*reset) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
gpointer origin_tag);
|
||||
void (*reset_path) (GSettingsBackend *backend,
|
||||
const gchar *path,
|
||||
gpointer origin_tag);
|
||||
gboolean (*get_writable) (GSettingsBackend *backend,
|
||||
const gchar *key);
|
||||
void (*subscribe) (GSettingsBackend *backend,
|
||||
const gchar *name);
|
||||
void (*unsubscribe) (GSettingsBackend *backend,
|
||||
const gchar *name);
|
||||
void (*sync) (GSettingsBackend *backend);
|
||||
GVariant * (*read) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
const GVariantType *expected_type,
|
||||
gboolean default_value);
|
||||
gchar ** (*list) (GSettingsBackend *backend,
|
||||
const gchar *path,
|
||||
gchar **resets,
|
||||
gsize n_resets,
|
||||
gsize *length);
|
||||
gboolean (*write) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
GVariant *value,
|
||||
gpointer origin_tag);
|
||||
gboolean (*write_keys) (GSettingsBackend *backend,
|
||||
GTree *tree,
|
||||
gpointer origin_tag);
|
||||
void (*reset) (GSettingsBackend *backend,
|
||||
const gchar *key,
|
||||
gpointer origin_tag);
|
||||
void (*reset_path) (GSettingsBackend *backend,
|
||||
const gchar *path,
|
||||
gpointer origin_tag);
|
||||
gboolean (*get_writable) (GSettingsBackend *backend,
|
||||
const gchar *key);
|
||||
void (*subscribe) (GSettingsBackend *backend,
|
||||
const gchar *name);
|
||||
void (*unsubscribe) (GSettingsBackend *backend,
|
||||
const gchar *name);
|
||||
void (*sync) (GSettingsBackend *backend);
|
||||
|
||||
gpointer padding[8];
|
||||
GPermission * (*get_permission) (GSettingsBackend *backend,
|
||||
const gchar *path);
|
||||
|
||||
gpointer padding[7];
|
||||
};
|
||||
|
||||
struct _GSettingsBackend
|
||||
|
@ -99,6 +99,9 @@ G_GNUC_INTERNAL
|
||||
void g_settings_backend_subscribe (GSettingsBackend *backend,
|
||||
const char *name);
|
||||
G_GNUC_INTERNAL
|
||||
GPermission * g_settings_backend_get_permission (GSettingsBackend *backend,
|
||||
const gchar *path);
|
||||
G_GNUC_INTERNAL
|
||||
GMainContext * g_settings_backend_get_active_context (void);
|
||||
|
||||
#endif /* __G_SETTINGS_BACKEND_INTERNAL_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user