glib (2.79.0)

(root)/
include/
glib-2.0/
gio/
gsettingsbackend.h
       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  
      24  #ifndef __G_SETTINGS_BACKEND_H__
      25  #define __G_SETTINGS_BACKEND_H__
      26  
      27  #if !defined (G_SETTINGS_ENABLE_BACKEND) && !defined (GIO_COMPILATION)
      28  #error "You must define G_SETTINGS_ENABLE_BACKEND before including <gio/gsettingsbackend.h>."
      29  #endif
      30  
      31  #define __GIO_GIO_H_INSIDE__
      32  #include <gio/giotypes.h>
      33  #undef __GIO_GIO_H_INSIDE__
      34  
      35  G_BEGIN_DECLS
      36  
      37  #define G_TYPE_SETTINGS_BACKEND                             (g_settings_backend_get_type ())
      38  #define G_SETTINGS_BACKEND(inst)                            (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
      39                                                               G_TYPE_SETTINGS_BACKEND, GSettingsBackend))
      40  #define G_SETTINGS_BACKEND_CLASS(class)                     (G_TYPE_CHECK_CLASS_CAST ((class),                       \
      41                                                               G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
      42  #define G_IS_SETTINGS_BACKEND(inst)                         (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
      43                                                               G_TYPE_SETTINGS_BACKEND))
      44  #define G_IS_SETTINGS_BACKEND_CLASS(class)                  (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
      45                                                               G_TYPE_SETTINGS_BACKEND))
      46  #define G_SETTINGS_BACKEND_GET_CLASS(inst)                  (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
      47                                                               G_TYPE_SETTINGS_BACKEND, GSettingsBackendClass))
      48  
      49  /**
      50   * G_SETTINGS_BACKEND_EXTENSION_POINT_NAME:
      51   *
      52   * Extension point for #GSettingsBackend functionality.
      53   **/
      54  #define G_SETTINGS_BACKEND_EXTENSION_POINT_NAME "gsettings-backend"
      55  
      56  typedef struct _GSettingsBackendPrivate                     GSettingsBackendPrivate;
      57  typedef struct _GSettingsBackendClass                       GSettingsBackendClass;
      58  
      59  /**
      60   * GSettingsBackendClass:
      61   * @read: virtual method to read a key's value
      62   * @get_writable: virtual method to get if a key is writable
      63   * @write: virtual method to change key's value
      64   * @write_tree: virtual method to change a tree of keys
      65   * @reset: virtual method to reset state
      66   * @subscribe: virtual method to subscribe to key changes
      67   * @unsubscribe: virtual method to unsubscribe to key changes
      68   * @sync: virtual method to sync state
      69   * @get_permission: virtual method to get permission of a key
      70   * @read_user_value: virtual method to read user's key value
      71   *
      72   * Class structure for #GSettingsBackend.
      73   */
      74  struct _GSettingsBackendClass
      75  {
      76    GObjectClass parent_class;
      77  
      78    GVariant *    (*read)             (GSettingsBackend    *backend,
      79                                       const gchar         *key,
      80                                       const GVariantType  *expected_type,
      81                                       gboolean             default_value);
      82  
      83    gboolean      (*get_writable)     (GSettingsBackend    *backend,
      84                                       const gchar         *key);
      85  
      86    gboolean      (*write)            (GSettingsBackend    *backend,
      87                                       const gchar         *key,
      88                                       GVariant            *value,
      89                                       gpointer             origin_tag);
      90    gboolean      (*write_tree)       (GSettingsBackend    *backend,
      91                                       GTree               *tree,
      92                                       gpointer             origin_tag);
      93    void          (*reset)            (GSettingsBackend    *backend,
      94                                       const gchar         *key,
      95                                       gpointer             origin_tag);
      96  
      97    void          (*subscribe)        (GSettingsBackend    *backend,
      98                                       const gchar         *name);
      99    void          (*unsubscribe)      (GSettingsBackend    *backend,
     100                                       const gchar         *name);
     101    void          (*sync)             (GSettingsBackend    *backend);
     102  
     103    GPermission * (*get_permission)   (GSettingsBackend    *backend,
     104                                       const gchar         *path);
     105  
     106    GVariant *    (*read_user_value)  (GSettingsBackend    *backend,
     107                                       const gchar         *key,
     108                                       const GVariantType  *expected_type);
     109  
     110    /*< private >*/
     111    gpointer padding[23];
     112  };
     113  
     114  struct _GSettingsBackend
     115  {
     116    GObject parent_instance;
     117  
     118    /*< private >*/
     119    GSettingsBackendPrivate *priv;
     120  };
     121  
     122  GIO_AVAILABLE_IN_ALL
     123  GType                   g_settings_backend_get_type                     (void);
     124  
     125  GIO_AVAILABLE_IN_ALL
     126  void                    g_settings_backend_changed                      (GSettingsBackend    *backend,
     127                                                                           const gchar         *key,
     128                                                                           gpointer             origin_tag);
     129  GIO_AVAILABLE_IN_ALL
     130  void                    g_settings_backend_path_changed                 (GSettingsBackend    *backend,
     131                                                                           const gchar         *path,
     132                                                                           gpointer             origin_tag);
     133  GIO_AVAILABLE_IN_ALL
     134  void                    g_settings_backend_flatten_tree                 (GTree               *tree,
     135                                                                           gchar              **path,
     136                                                                           const gchar       ***keys,
     137                                                                           GVariant          ***values);
     138  GIO_AVAILABLE_IN_ALL
     139  void                    g_settings_backend_keys_changed                 (GSettingsBackend    *backend,
     140                                                                           const gchar         *path,
     141                                                                           gchar const * const *items,
     142                                                                           gpointer             origin_tag);
     143  
     144  GIO_AVAILABLE_IN_ALL
     145  void                    g_settings_backend_path_writable_changed        (GSettingsBackend    *backend,
     146                                                                           const gchar         *path);
     147  GIO_AVAILABLE_IN_ALL
     148  void                    g_settings_backend_writable_changed             (GSettingsBackend    *backend,
     149                                                                           const gchar         *key);
     150  GIO_AVAILABLE_IN_ALL
     151  void                    g_settings_backend_changed_tree                 (GSettingsBackend    *backend,
     152                                                                           GTree               *tree,
     153                                                                           gpointer             origin_tag);
     154  
     155  GIO_AVAILABLE_IN_ALL
     156  GSettingsBackend *      g_settings_backend_get_default                  (void);
     157  
     158  GIO_AVAILABLE_IN_ALL
     159  GSettingsBackend *      g_keyfile_settings_backend_new                  (const gchar         *filename,
     160                                                                           const gchar         *root_path,
     161                                                                           const gchar         *root_group);
     162  
     163  GIO_AVAILABLE_IN_ALL
     164  GSettingsBackend *      g_null_settings_backend_new                     (void);
     165  
     166  GIO_AVAILABLE_IN_ALL
     167  GSettingsBackend *      g_memory_settings_backend_new                   (void);
     168  
     169  G_END_DECLS
     170  
     171  #endif /* __G_SETTINGS_BACKEND_H__ */