Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:59

0001 /*
0002  * Copyright © 2009, 2010 Codethink Limited
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
0018  *
0019  * Author: Ryan Lortie <desrt@desrt.ca>
0020  */
0021 
0022 #ifndef __G_SETTINGS_H__
0023 #define __G_SETTINGS_H__
0024 
0025 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
0026 #error "Only <gio/gio.h> can be included directly."
0027 #endif
0028 
0029 #include <gio/gsettingsschema.h>
0030 #include <gio/giotypes.h>
0031 
0032 G_BEGIN_DECLS
0033 
0034 #define G_TYPE_SETTINGS                                     (g_settings_get_type ())
0035 #define G_SETTINGS(inst)                                    (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
0036                                                              G_TYPE_SETTINGS, GSettings))
0037 #define G_SETTINGS_CLASS(class)                             (G_TYPE_CHECK_CLASS_CAST ((class),                       \
0038                                                              G_TYPE_SETTINGS, GSettingsClass))
0039 #define G_IS_SETTINGS(inst)                                 (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_SETTINGS))
0040 #define G_IS_SETTINGS_CLASS(class)                          (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_SETTINGS))
0041 #define G_SETTINGS_GET_CLASS(inst)                          (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
0042                                                              G_TYPE_SETTINGS, GSettingsClass))
0043 
0044 typedef struct _GSettingsPrivate                            GSettingsPrivate;
0045 typedef struct _GSettingsClass                              GSettingsClass;
0046 
0047 struct _GSettingsClass
0048 {
0049   GObjectClass parent_class;
0050 
0051   /* Signals */
0052   void        (*writable_changed)      (GSettings    *settings,
0053                                         const gchar  *key);
0054   void        (*changed)               (GSettings    *settings,
0055                                         const gchar  *key);
0056   gboolean    (*writable_change_event) (GSettings    *settings,
0057                                         GQuark        key);
0058   gboolean    (*change_event)          (GSettings    *settings,
0059                                         const GQuark *keys,
0060                                         gint          n_keys);
0061 
0062   gpointer padding[20];
0063 };
0064 
0065 struct _GSettings
0066 {
0067   GObject parent_instance;
0068   GSettingsPrivate *priv;
0069 };
0070 
0071 
0072 GIO_AVAILABLE_IN_ALL
0073 GType                   g_settings_get_type                             (void);
0074 
0075 GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_source_list_schemas)
0076 const gchar * const *   g_settings_list_schemas                         (void);
0077 GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_source_list_schemas)
0078 const gchar * const *   g_settings_list_relocatable_schemas             (void);
0079 GIO_AVAILABLE_IN_ALL
0080 GSettings *             g_settings_new                                  (const gchar        *schema_id);
0081 GIO_AVAILABLE_IN_ALL
0082 GSettings *             g_settings_new_with_path                        (const gchar        *schema_id,
0083                                                                          const gchar        *path);
0084 GIO_AVAILABLE_IN_ALL
0085 GSettings *             g_settings_new_with_backend                     (const gchar        *schema_id,
0086                                                                          GSettingsBackend   *backend);
0087 GIO_AVAILABLE_IN_ALL
0088 GSettings *             g_settings_new_with_backend_and_path            (const gchar        *schema_id,
0089                                                                          GSettingsBackend   *backend,
0090                                                                          const gchar        *path);
0091 GIO_AVAILABLE_IN_2_32
0092 GSettings *             g_settings_new_full                             (GSettingsSchema    *schema,
0093                                                                          GSettingsBackend   *backend,
0094                                                                          const gchar        *path);
0095 GIO_AVAILABLE_IN_ALL
0096 gchar **                g_settings_list_children                        (GSettings          *settings);
0097 GIO_DEPRECATED_IN_2_46_FOR(g_settings_schema_list_keys)
0098 gchar **                g_settings_list_keys                            (GSettings          *settings);
0099 GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_key_get_range)
0100 GVariant *              g_settings_get_range                            (GSettings          *settings,
0101                                                                          const gchar        *key);
0102 GIO_DEPRECATED_IN_2_40_FOR(g_settings_schema_key_range_check)
0103 gboolean                g_settings_range_check                          (GSettings          *settings,
0104                                                                          const gchar        *key,
0105                                                                          GVariant           *value);
0106 
0107 GIO_AVAILABLE_IN_ALL
0108 gboolean                g_settings_set_value                            (GSettings          *settings,
0109                                                                          const gchar        *key,
0110                                                                          GVariant           *value);
0111 GIO_AVAILABLE_IN_ALL
0112 GVariant *              g_settings_get_value                            (GSettings          *settings,
0113                                                                          const gchar        *key);
0114 
0115 GIO_AVAILABLE_IN_2_40
0116 GVariant *              g_settings_get_user_value                       (GSettings          *settings,
0117                                                                          const gchar        *key);
0118 GIO_AVAILABLE_IN_2_40
0119 GVariant *              g_settings_get_default_value                    (GSettings          *settings,
0120                                                                          const gchar        *key);
0121 
0122 GIO_AVAILABLE_IN_ALL
0123 gboolean                g_settings_set                                  (GSettings          *settings,
0124                                                                          const gchar        *key,
0125                                                                          const gchar        *format,
0126                                                                          ...);
0127 GIO_AVAILABLE_IN_ALL
0128 void                    g_settings_get                                  (GSettings          *settings,
0129                                                                          const gchar        *key,
0130                                                                          const gchar        *format,
0131                                                                          ...);
0132 GIO_AVAILABLE_IN_ALL
0133 void                    g_settings_reset                                (GSettings          *settings,
0134                                                                          const gchar        *key);
0135 
0136 GIO_AVAILABLE_IN_ALL
0137 gint                    g_settings_get_int                              (GSettings          *settings,
0138                                                                          const gchar        *key);
0139 GIO_AVAILABLE_IN_ALL
0140 gboolean                g_settings_set_int                              (GSettings          *settings,
0141                                                                          const gchar        *key,
0142                                                                          gint                value);
0143 GIO_AVAILABLE_IN_2_50
0144 gint64                  g_settings_get_int64                            (GSettings          *settings,
0145                                                                          const gchar        *key);
0146 GIO_AVAILABLE_IN_2_50
0147 gboolean                g_settings_set_int64                            (GSettings          *settings,
0148                                                                          const gchar        *key,
0149                                                                          gint64              value);
0150 GIO_AVAILABLE_IN_2_32
0151 guint                   g_settings_get_uint                             (GSettings          *settings,
0152                                                                          const gchar        *key);
0153 GIO_AVAILABLE_IN_2_32
0154 gboolean                g_settings_set_uint                             (GSettings          *settings,
0155                                                                          const gchar        *key,
0156                                                                          guint               value);
0157 GIO_AVAILABLE_IN_2_50
0158 guint64                 g_settings_get_uint64                           (GSettings          *settings,
0159                                                                          const gchar        *key);
0160 GIO_AVAILABLE_IN_2_50
0161 gboolean                g_settings_set_uint64                           (GSettings          *settings,
0162                                                                          const gchar        *key,
0163                                                                          guint64             value);
0164 GIO_AVAILABLE_IN_ALL
0165 gchar *                 g_settings_get_string                           (GSettings          *settings,
0166                                                                          const gchar        *key);
0167 GIO_AVAILABLE_IN_ALL
0168 gboolean                g_settings_set_string                           (GSettings          *settings,
0169                                                                          const gchar        *key,
0170                                                                          const gchar        *value);
0171 GIO_AVAILABLE_IN_ALL
0172 gboolean                g_settings_get_boolean                          (GSettings          *settings,
0173                                                                          const gchar        *key);
0174 GIO_AVAILABLE_IN_ALL
0175 gboolean                g_settings_set_boolean                          (GSettings          *settings,
0176                                                                          const gchar        *key,
0177                                                                          gboolean            value);
0178 GIO_AVAILABLE_IN_ALL
0179 gdouble                 g_settings_get_double                           (GSettings          *settings,
0180                                                                          const gchar        *key);
0181 GIO_AVAILABLE_IN_ALL
0182 gboolean                g_settings_set_double                           (GSettings          *settings,
0183                                                                          const gchar        *key,
0184                                                                          gdouble             value);
0185 GIO_AVAILABLE_IN_ALL
0186 gchar **                g_settings_get_strv                             (GSettings          *settings,
0187                                                                          const gchar        *key);
0188 GIO_AVAILABLE_IN_ALL
0189 gboolean                g_settings_set_strv                             (GSettings          *settings,
0190                                                                          const gchar        *key,
0191                                                                          const gchar *const *value);
0192 GIO_AVAILABLE_IN_ALL
0193 gint                    g_settings_get_enum                             (GSettings          *settings,
0194                                                                          const gchar        *key);
0195 GIO_AVAILABLE_IN_ALL
0196 gboolean                g_settings_set_enum                             (GSettings          *settings,
0197                                                                          const gchar        *key,
0198                                                                          gint                value);
0199 GIO_AVAILABLE_IN_ALL
0200 guint                   g_settings_get_flags                            (GSettings          *settings,
0201                                                                          const gchar        *key);
0202 GIO_AVAILABLE_IN_ALL
0203 gboolean                g_settings_set_flags                            (GSettings          *settings,
0204                                                                          const gchar        *key,
0205                                                                          guint               value);
0206 GIO_AVAILABLE_IN_ALL
0207 GSettings *             g_settings_get_child                            (GSettings          *settings,
0208                                                                          const gchar        *name);
0209 
0210 GIO_AVAILABLE_IN_ALL
0211 gboolean                g_settings_is_writable                          (GSettings          *settings,
0212                                                                          const gchar        *name);
0213 
0214 GIO_AVAILABLE_IN_ALL
0215 void                    g_settings_delay                                (GSettings          *settings);
0216 GIO_AVAILABLE_IN_ALL
0217 void                    g_settings_apply                                (GSettings          *settings);
0218 GIO_AVAILABLE_IN_ALL
0219 void                    g_settings_revert                               (GSettings          *settings);
0220 GIO_AVAILABLE_IN_ALL
0221 gboolean                g_settings_get_has_unapplied                    (GSettings          *settings);
0222 GIO_AVAILABLE_IN_ALL
0223 void                    g_settings_sync                                 (void);
0224 
0225 /**
0226  * GSettingsBindSetMapping:
0227  * @value: a #GValue containing the property value to map
0228  * @expected_type: the #GVariantType to create
0229  * @user_data: user data that was specified when the binding was created
0230  *
0231  * The type for the function that is used to convert an object property
0232  * value to a #GVariant for storing it in #GSettings.
0233  *
0234  * Returns: a new #GVariant holding the data from @value,
0235  *     or %NULL in case of an error
0236  */
0237 typedef GVariant *    (*GSettingsBindSetMapping)                        (const GValue       *value,
0238                                                                          const GVariantType *expected_type,
0239                                                                          gpointer            user_data);
0240 
0241 /**
0242  * GSettingsBindGetMapping:
0243  * @value: return location for the property value
0244  * @variant: the #GVariant
0245  * @user_data: user data that was specified when the binding was created
0246  *
0247  * The type for the function that is used to convert from #GSettings to
0248  * an object property. The @value is already initialized to hold values
0249  * of the appropriate type.
0250  *
0251  * Returns: %TRUE if the conversion succeeded, %FALSE in case of an error
0252  */
0253 typedef gboolean      (*GSettingsBindGetMapping)                        (GValue             *value,
0254                                                                          GVariant           *variant,
0255                                                                          gpointer            user_data);
0256 
0257 /**
0258  * GSettingsGetMapping:
0259  * @value: the #GVariant to map, or %NULL
0260  * @result: (out): the result of the mapping
0261  * @user_data: (closure): the user data that was passed to
0262  * g_settings_get_mapped()
0263  *
0264  * The type of the function that is used to convert from a value stored
0265  * in a #GSettings to a value that is useful to the application.
0266  *
0267  * If the value is successfully mapped, the result should be stored at
0268  * @result and %TRUE returned.  If mapping fails (for example, if @value
0269  * is not in the right format) then %FALSE should be returned.
0270  *
0271  * If @value is %NULL then it means that the mapping function is being
0272  * given a "last chance" to successfully return a valid value.  %TRUE
0273  * must be returned in this case.
0274  *
0275  * Returns: %TRUE if the conversion succeeded, %FALSE in case of an error
0276  **/
0277 typedef gboolean      (*GSettingsGetMapping)                            (GVariant           *value,
0278                                                                          gpointer           *result,
0279                                                                          gpointer            user_data);
0280 
0281 /**
0282  * GSettingsBindFlags:
0283  * @G_SETTINGS_BIND_DEFAULT: Equivalent to `G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET`
0284  * @G_SETTINGS_BIND_GET: Update the #GObject property when the setting changes.
0285  *     It is an error to use this flag if the property is not writable.
0286  * @G_SETTINGS_BIND_SET: Update the setting when the #GObject property changes.
0287  *     It is an error to use this flag if the property is not readable.
0288  * @G_SETTINGS_BIND_NO_SENSITIVITY: Do not try to bind a "sensitivity" property to the writability of the setting
0289  * @G_SETTINGS_BIND_GET_NO_CHANGES: When set in addition to %G_SETTINGS_BIND_GET, set the #GObject property
0290  *     value initially from the setting, but do not listen for changes of the setting
0291  * @G_SETTINGS_BIND_INVERT_BOOLEAN: When passed to g_settings_bind(), uses a pair of mapping functions that invert
0292  *     the boolean value when mapping between the setting and the property.  The setting and property must both
0293  *     be booleans.  You cannot pass this flag to g_settings_bind_with_mapping().
0294  *
0295  * Flags used when creating a binding. These flags determine in which
0296  * direction the binding works. The default is to synchronize in both
0297  * directions.
0298  */
0299 typedef enum
0300 {
0301   G_SETTINGS_BIND_DEFAULT,
0302   G_SETTINGS_BIND_GET            = (1<<0),
0303   G_SETTINGS_BIND_SET            = (1<<1),
0304   G_SETTINGS_BIND_NO_SENSITIVITY = (1<<2),
0305   G_SETTINGS_BIND_GET_NO_CHANGES = (1<<3),
0306   G_SETTINGS_BIND_INVERT_BOOLEAN = (1<<4)
0307 } GSettingsBindFlags;
0308 
0309 GIO_AVAILABLE_IN_ALL
0310 void                    g_settings_bind                                 (GSettings               *settings,
0311                                                                          const gchar             *key,
0312                                                                          gpointer                 object,
0313                                                                          const gchar             *property,
0314                                                                          GSettingsBindFlags       flags);
0315 GIO_AVAILABLE_IN_ALL
0316 void                    g_settings_bind_with_mapping                    (GSettings               *settings,
0317                                                                          const gchar             *key,
0318                                                                          gpointer                 object,
0319                                                                          const gchar             *property,
0320                                                                          GSettingsBindFlags       flags,
0321                                                                          GSettingsBindGetMapping  get_mapping,
0322                                                                          GSettingsBindSetMapping  set_mapping,
0323                                                                          gpointer                 user_data,
0324                                                                          GDestroyNotify           destroy);
0325 GIO_AVAILABLE_IN_2_82
0326 void g_settings_bind_with_mapping_closures (GSettings *settings,
0327                                             const char *key,
0328                                             GObject *object,
0329                                             const char *property,
0330                                             GSettingsBindFlags flags,
0331                                             GClosure *get_mapping,
0332                                             GClosure *set_mapping);
0333 GIO_AVAILABLE_IN_ALL
0334 void                    g_settings_bind_writable                        (GSettings               *settings,
0335                                                                          const gchar             *key,
0336                                                                          gpointer                 object,
0337                                                                          const gchar             *property,
0338                                                                          gboolean                 inverted);
0339 GIO_AVAILABLE_IN_ALL
0340 void                    g_settings_unbind                               (gpointer                 object,
0341                                                                          const gchar             *property);
0342 
0343 GIO_AVAILABLE_IN_2_32
0344 GAction *               g_settings_create_action                        (GSettings               *settings,
0345                                                                          const gchar             *key);
0346 
0347 GIO_AVAILABLE_IN_ALL
0348 gpointer                g_settings_get_mapped                           (GSettings               *settings,
0349                                                                          const gchar             *key,
0350                                                                          GSettingsGetMapping      mapping,
0351                                                                          gpointer                 user_data);
0352 
0353 G_END_DECLS
0354 
0355 #endif  /* __G_SETTINGS_H__ */