mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-21 19:54:51 +02: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);
|
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 */
|
/* method calls */
|
||||||
gboolean
|
gboolean
|
||||||
g_delayed_settings_backend_get_has_unapplied (GDelayedSettingsBackend *delayed)
|
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->get_writable = g_delayed_settings_backend_get_writable;
|
||||||
backend_class->subscribe = g_delayed_settings_backend_subscribe;
|
backend_class->subscribe = g_delayed_settings_backend_subscribe;
|
||||||
backend_class->unsubscribe = g_delayed_settings_backend_unsubscribe;
|
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;
|
object_class->finalize = g_delayed_settings_backend_finalize;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "gfile.h"
|
#include "gfile.h"
|
||||||
#include "gfileinfo.h"
|
#include "gfileinfo.h"
|
||||||
#include "gfilemonitor.h"
|
#include "gfilemonitor.h"
|
||||||
|
#include "gsimplepermission.h"
|
||||||
|
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
@ -244,6 +245,13 @@ g_keyfile_settings_backend_get_writable (GSettingsBackend *backend,
|
|||||||
return kf_backend->priv->writable;
|
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
|
static void
|
||||||
g_keyfile_settings_backend_keyfile_reload (GKeyfileSettingsBackend *kf_backend)
|
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 = g_keyfile_settings_backend_reset;
|
||||||
backend_class->reset_path = g_keyfile_settings_backend_reset_path;
|
backend_class->reset_path = g_keyfile_settings_backend_reset_path;
|
||||||
backend_class->get_writable = g_keyfile_settings_backend_get_writable;
|
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
|
/* 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
|
* stop monitoring the file when there's no GSettings anymore, which is no
|
||||||
* big win. */
|
* big win. */
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gmemorysettingsbackend.h"
|
#include "gmemorysettingsbackend.h"
|
||||||
|
#include "gsimplepermission.h"
|
||||||
#include "gsettingsbackend.h"
|
#include "gsettingsbackend.h"
|
||||||
#include "giomodule.h"
|
#include "giomodule.h"
|
||||||
|
|
||||||
@ -118,6 +119,13 @@ g_memory_settings_backend_get_writable (GSettingsBackend *backend,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GPermission *
|
||||||
|
g_memory_settings_backend_get_permission (GSettingsBackend *backend,
|
||||||
|
const gchar *path)
|
||||||
|
{
|
||||||
|
return g_simple_permission_new (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_memory_settings_backend_finalize (GObject *object)
|
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 = g_memory_settings_backend_write;
|
||||||
backend_class->write_keys = g_memory_settings_backend_write_keys;
|
backend_class->write_keys = g_memory_settings_backend_write_keys;
|
||||||
backend_class->get_writable = g_memory_settings_backend_get_writable;
|
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;
|
object_class->finalize = g_memory_settings_backend_finalize;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gnullsettingsbackend.h"
|
#include "gnullsettingsbackend.h"
|
||||||
|
#include "gsimplepermission.h"
|
||||||
|
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
@ -81,11 +82,18 @@ g_null_settings_backend_reset_path (GSettingsBackend *backend,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_null_settings_backend_get_writable (GSettingsBackend *backend,
|
g_null_settings_backend_get_writable (GSettingsBackend *backend,
|
||||||
const gchar *name)
|
const gchar *name)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GPermission *
|
||||||
|
g_null_settings_backend_get_permission (GSettingsBackend *backend,
|
||||||
|
const gchar *path)
|
||||||
|
{
|
||||||
|
return g_simple_permission_new (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_null_settings_backend_init (GNullSettingsBackend *memory)
|
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 = g_null_settings_backend_reset;
|
||||||
backend_class->reset_path = g_null_settings_backend_reset_path;
|
backend_class->reset_path = g_null_settings_backend_reset_path;
|
||||||
backend_class->get_writable = g_null_settings_backend_get_writable;
|
backend_class->get_writable = g_null_settings_backend_get_writable;
|
||||||
|
backend_class->get_permission = g_null_settings_backend_get_permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSettingsBackend *
|
GSettingsBackend *
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "gsettingsbackendinternal.h"
|
#include "gsettingsbackendinternal.h"
|
||||||
#include "gnullsettingsbackend.h"
|
#include "gnullsettingsbackend.h"
|
||||||
|
#include "gsimplepermission.h"
|
||||||
#include "giomodule-priv.h"
|
#include "giomodule-priv.h"
|
||||||
#include "gio-marshal.h"
|
#include "gio-marshal.h"
|
||||||
|
|
||||||
@ -1156,6 +1157,30 @@ g_settings_backend_supports_context (const gchar *context)
|
|||||||
return FALSE;
|
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:
|
* g_settings_backend_setup:
|
||||||
* @context: a context string (not %NULL or "")
|
* @context: a context string (not %NULL or "")
|
||||||
|
@ -67,39 +67,42 @@ struct _GSettingsBackendClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
gboolean (*supports_context) (const gchar *context);
|
gboolean (*supports_context) (const gchar *context);
|
||||||
|
|
||||||
GVariant * (*read) (GSettingsBackend *backend,
|
GVariant * (*read) (GSettingsBackend *backend,
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
const GVariantType *expected_type,
|
const GVariantType *expected_type,
|
||||||
gboolean default_value);
|
gboolean default_value);
|
||||||
gchar ** (*list) (GSettingsBackend *backend,
|
gchar ** (*list) (GSettingsBackend *backend,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
gchar **resets,
|
gchar **resets,
|
||||||
gsize n_resets,
|
gsize n_resets,
|
||||||
gsize *length);
|
gsize *length);
|
||||||
gboolean (*write) (GSettingsBackend *backend,
|
gboolean (*write) (GSettingsBackend *backend,
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer origin_tag);
|
gpointer origin_tag);
|
||||||
gboolean (*write_keys) (GSettingsBackend *backend,
|
gboolean (*write_keys) (GSettingsBackend *backend,
|
||||||
GTree *tree,
|
GTree *tree,
|
||||||
gpointer origin_tag);
|
gpointer origin_tag);
|
||||||
void (*reset) (GSettingsBackend *backend,
|
void (*reset) (GSettingsBackend *backend,
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
gpointer origin_tag);
|
gpointer origin_tag);
|
||||||
void (*reset_path) (GSettingsBackend *backend,
|
void (*reset_path) (GSettingsBackend *backend,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
gpointer origin_tag);
|
gpointer origin_tag);
|
||||||
gboolean (*get_writable) (GSettingsBackend *backend,
|
gboolean (*get_writable) (GSettingsBackend *backend,
|
||||||
const gchar *key);
|
const gchar *key);
|
||||||
void (*subscribe) (GSettingsBackend *backend,
|
void (*subscribe) (GSettingsBackend *backend,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
void (*unsubscribe) (GSettingsBackend *backend,
|
void (*unsubscribe) (GSettingsBackend *backend,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
void (*sync) (GSettingsBackend *backend);
|
void (*sync) (GSettingsBackend *backend);
|
||||||
|
|
||||||
gpointer padding[8];
|
GPermission * (*get_permission) (GSettingsBackend *backend,
|
||||||
|
const gchar *path);
|
||||||
|
|
||||||
|
gpointer padding[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GSettingsBackend
|
struct _GSettingsBackend
|
||||||
|
@ -99,6 +99,9 @@ G_GNUC_INTERNAL
|
|||||||
void g_settings_backend_subscribe (GSettingsBackend *backend,
|
void g_settings_backend_subscribe (GSettingsBackend *backend,
|
||||||
const char *name);
|
const char *name);
|
||||||
G_GNUC_INTERNAL
|
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);
|
GMainContext * g_settings_backend_get_active_context (void);
|
||||||
|
|
||||||
#endif /* __G_SETTINGS_BACKEND_INTERNAL_H__ */
|
#endif /* __G_SETTINGS_BACKEND_INTERNAL_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user