gsettingsbackend.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright © 2009, 2010 Codethink Limited
  3. * Copyright © 2010 Red Hat, Inc.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Authors: Ryan Lortie <desrt@desrt.ca>
  21. * Matthias Clasen <mclasen@redhat.com>
  22. */
  23. #ifndef __G_SETTINGS_BACKEND_H__
  24. #define __G_SETTINGS_BACKEND_H__
  25. #if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
  26. #error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
  27. #endif
  28. #define __GIO_GIO_H_INSIDE__
  29. #include <gio/giotypes.h>
  30. #undef __GIO_GIO_H_INSIDE__
  31. G_BEGIN_DECLS
  32. #define G_TYPE_SETTINGS_BACKEND (g_settings_backend_get_type ())
  33. #define G_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  34. G_TYPE_SETTINGS_BACKEND, GSettingsBackend))
  35. #define G_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  36. G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
  37. #define G_IS_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  38. G_TYPE_SETTINGS_BACKEND))
  39. #define G_IS_SETTINGS_BACKEND_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  40. G_TYPE_SETTINGS_BACKEND))
  41. #define G_SETTINGS_BACKEND_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  42. G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
  43. /**
  44. * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
  45. *
  46. * Extension point for #GSettingsBackend functionality.
  47. **/
  48. #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
  49. typedef struct _GSettingsBackendPrivate GSettingsBackendPrivate;
  50. typedef struct _GSettingsBackendClass GSettingsBackendClass;
  51. /**
  52. * GSettingsBackendClass:
  53. * @read: virtual method to read a key's value
  54. * @get_writable: virtual method to get if a key is writable
  55. * @write: virtual method to change key's value
  56. * @write_tree: virtual method to change a tree of keys
  57. * @reset: virtual method to reset state
  58. * @subscribe: virtual method to subscribe to key changes
  59. * @unsubscribe: virtual method to unsubscribe to key changes
  60. * @sync: virtual method to sync state
  61. * @get_permission: virtual method to get permission of a key
  62. * @read_user_value: virtual method to read user's key value
  63. *
  64. * Class structure for #GSettingsBackend.
  65. */
  66. struct _GSettingsBackendClass
  67. {
  68. GObjectClass parent_class;
  69. GVariant * (*read) (GSettingsBackend *backend,
  70. const gchar *key,
  71. const GVariantType *expected_type,
  72. gboolean default_value);
  73. gboolean (*get_writable) (GSettingsBackend *backend,
  74. const gchar *key);
  75. gboolean (*write) (GSettingsBackend *backend,
  76. const gchar *key,
  77. GVariant *value,
  78. gpointer origin_tag);
  79. gboolean (*write_tree) (GSettingsBackend *backend,
  80. GTree *tree,
  81. gpointer origin_tag);
  82. void (*reset) (GSettingsBackend *backend,
  83. const gchar *key,
  84. gpointer origin_tag);
  85. void (*subscribe) (GSettingsBackend *backend,
  86. const gchar *name);
  87. void (*unsubscribe) (GSettingsBackend *backend,
  88. const gchar *name);
  89. void (*sync) (GSettingsBackend *backend);
  90. GPermission * (*get_permission) (GSettingsBackend *backend,
  91. const gchar *path);
  92. GVariant * (*read_user_value) (GSettingsBackend *backend,
  93. const gchar *key,
  94. const GVariantType *expected_type);
  95. /*< private >*/
  96. gpointer padding[23];
  97. };
  98. struct _GSettingsBackend
  99. {
  100. GObject parent_instance;
  101. /*< private >*/
  102. GSettingsBackendPrivate *priv;
  103. };
  104. GIO_AVAILABLE_IN_ALL
  105. GType g_settings_backend_get_type (void);
  106. GIO_AVAILABLE_IN_ALL
  107. void g_settings_backend_changed (GSettingsBackend *backend,
  108. const gchar *key,
  109. gpointer origin_tag);
  110. GIO_AVAILABLE_IN_ALL
  111. void g_settings_backend_path_changed (GSettingsBackend *backend,
  112. const gchar *path,
  113. gpointer origin_tag);
  114. GIO_AVAILABLE_IN_ALL
  115. void g_settings_backend_flatten_tree (GTree *tree,
  116. gchar **path,
  117. const gchar ***keys,
  118. GVariant ***values);
  119. GIO_AVAILABLE_IN_ALL
  120. void g_settings_backend_keys_changed (GSettingsBackend *backend,
  121. const gchar *path,
  122. gchar const * const *items,
  123. gpointer origin_tag);
  124. GIO_AVAILABLE_IN_ALL
  125. void g_settings_backend_path_writable_changed (GSettingsBackend *backend,
  126. const gchar *path);
  127. GIO_AVAILABLE_IN_ALL
  128. void g_settings_backend_writable_changed (GSettingsBackend *backend,
  129. const gchar *key);
  130. GIO_AVAILABLE_IN_ALL
  131. void g_settings_backend_changed_tree (GSettingsBackend *backend,
  132. GTree *tree,
  133. gpointer origin_tag);
  134. GIO_AVAILABLE_IN_ALL
  135. GSettingsBackend * g_settings_backend_get_default (void);
  136. GIO_AVAILABLE_IN_ALL
  137. GSettingsBackend * g_keyfile_settings_backend_new (const gchar *filename,
  138. const gchar *root_path,
  139. const gchar *root_group);
  140. GIO_AVAILABLE_IN_ALL
  141. GSettingsBackend * g_null_settings_backend_new (void);
  142. GIO_AVAILABLE_IN_ALL
  143. GSettingsBackend * g_memory_settings_backend_new (void);
  144. G_END_DECLS
  145. #endif /* __G_SETTINGS_BACKEND_H__ */