Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-25 08:26:37

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: the property value to map
0228  * @expected_type: expected type of the result
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 [struct@GLib.Variant] for storing it in [class@Gio.Settings].
0233  *
0234  * Returns: (nullable): a new [struct@GLib.Variant] 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: variant to map to the property value
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 [class@Gio.Settings]
0248  * to an object property.
0249  *
0250  * The @value is already initialized to hold values of the appropriate type.
0251  *
0252  * Returns: true if the conversion succeeded, false in case of an error
0253  */
0254 typedef gboolean      (*GSettingsBindGetMapping)                        (GValue             *value,
0255                                                                          GVariant           *variant,
0256                                                                          gpointer            user_data);
0257 
0258 /**
0259  * GSettingsGetMapping:
0260  * @value: (nullable): variant to map to the application value
0261  * @result: (out): the result of the mapping
0262  * @user_data: (closure): the user data that was passed to
0263  *   [method@Gio.Settings.get_mapped]
0264  *
0265  * The type of the function that is used to convert from a value stored
0266  * in a [class@Gio.Settings] to a value that is useful to the application.
0267  *
0268  * If the value is successfully mapped, the result should be stored at
0269  * @result and true returned.  If mapping fails (for example, if @value
0270  * is not in the right format) then false should be returned.
0271  *
0272  * If @value is `NULL` then it means that the mapping function is being
0273  * given a ‘last chance’ to successfully return a valid value.  True
0274  * must be returned in this case.
0275  *
0276  * Returns: true if the conversion succeeded, false in case of an error
0277  **/
0278 typedef gboolean      (*GSettingsGetMapping)                            (GVariant           *value,
0279                                                                          gpointer           *result,
0280                                                                          gpointer            user_data);
0281 
0282 /**
0283  * GSettingsBindFlags:
0284  * @G_SETTINGS_BIND_DEFAULT: Equivalent to `G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET`
0285  * @G_SETTINGS_BIND_GET: Update the [class@GObject.Object] property when the setting changes.
0286  *   It is an error to use this flag if the property is not writable.
0287  * @G_SETTINGS_BIND_SET: Update the setting when the [class@GObject.Object] property changes.
0288  *   It is an error to use this flag if the property is not readable.
0289  * @G_SETTINGS_BIND_NO_SENSITIVITY: Do not try to bind a ‘sensitivity’ property to the writability of the setting
0290  * @G_SETTINGS_BIND_GET_NO_CHANGES: When set in addition to [flags@Gio.SettingsBindFlags.GET],
0291  *   set the [class@GObject.Object] property
0292  *   value initially from the setting, but do not listen for changes of the setting
0293  * @G_SETTINGS_BIND_INVERT_BOOLEAN: When passed to [method@Gio.Settings.bind],
0294  *   uses a pair of mapping functions that invert
0295  *   the boolean value when mapping between the setting and the property.  The setting and property must both
0296  *   be booleans.  You cannot pass this flag to [method@Gio.Settings.bind_with_mapping].
0297  *
0298  * Flags used when creating a binding.
0299  *
0300  * These flags determine in which direction the binding works. The default is to
0301  * synchronize in both directions.
0302  */
0303 typedef enum
0304 {
0305   G_SETTINGS_BIND_DEFAULT,
0306   G_SETTINGS_BIND_GET            = (1<<0),
0307   G_SETTINGS_BIND_SET            = (1<<1),
0308   G_SETTINGS_BIND_NO_SENSITIVITY = (1<<2),
0309   G_SETTINGS_BIND_GET_NO_CHANGES = (1<<3),
0310   G_SETTINGS_BIND_INVERT_BOOLEAN = (1<<4)
0311 } GSettingsBindFlags;
0312 
0313 GIO_AVAILABLE_IN_ALL
0314 void                    g_settings_bind                                 (GSettings               *settings,
0315                                                                          const gchar             *key,
0316                                                                          gpointer                 object,
0317                                                                          const gchar             *property,
0318                                                                          GSettingsBindFlags       flags);
0319 GIO_AVAILABLE_IN_ALL
0320 void                    g_settings_bind_with_mapping                    (GSettings               *settings,
0321                                                                          const gchar             *key,
0322                                                                          gpointer                 object,
0323                                                                          const gchar             *property,
0324                                                                          GSettingsBindFlags       flags,
0325                                                                          GSettingsBindGetMapping  get_mapping,
0326                                                                          GSettingsBindSetMapping  set_mapping,
0327                                                                          gpointer                 user_data,
0328                                                                          GDestroyNotify           destroy);
0329 GIO_AVAILABLE_IN_2_82
0330 void g_settings_bind_with_mapping_closures (GSettings *settings,
0331                                             const char *key,
0332                                             GObject *object,
0333                                             const char *property,
0334                                             GSettingsBindFlags flags,
0335                                             GClosure *get_mapping,
0336                                             GClosure *set_mapping);
0337 GIO_AVAILABLE_IN_ALL
0338 void                    g_settings_bind_writable                        (GSettings               *settings,
0339                                                                          const gchar             *key,
0340                                                                          gpointer                 object,
0341                                                                          const gchar             *property,
0342                                                                          gboolean                 inverted);
0343 GIO_AVAILABLE_IN_ALL
0344 void                    g_settings_unbind                               (gpointer                 object,
0345                                                                          const gchar             *property);
0346 
0347 GIO_AVAILABLE_IN_2_32
0348 GAction *               g_settings_create_action                        (GSettings               *settings,
0349                                                                          const gchar             *key);
0350 
0351 GIO_AVAILABLE_IN_ALL
0352 gpointer                g_settings_get_mapped                           (GSettings               *settings,
0353                                                                          const gchar             *key,
0354                                                                          GSettingsGetMapping      mapping,
0355                                                                          gpointer                 user_data);
0356 
0357 G_END_DECLS
0358 
0359 #endif  /* __G_SETTINGS_H__ */