Improve the g_file_make_symbolic_link docs
[platform/upstream/glib.git] / gio / gsettings.h
1 /*
2  * Copyright © 2009, 2010 Codethink Limited
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the licence, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #ifndef __G_SETTINGS_H__
23 #define __G_SETTINGS_H__
24
25 #include <glib-object.h>
26
27 G_BEGIN_DECLS
28
29 #define G_TYPE_SETTINGS                                     (g_settings_get_type ())
30 #define G_SETTINGS(inst)                                    (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
31                                                              G_TYPE_SETTINGS, GSettings))
32 #define G_SETTINGS_CLASS(class)                             (G_TYPE_CHECK_CLASS_CAST ((class),                       \
33                                                              G_TYPE_SETTINGS, GSettingsClass))
34 #define G_IS_SETTINGS(inst)                                 (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_SETTINGS))
35 #define G_IS_SETTINGS_CLASS(class)                          (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_SETTINGS))
36 #define G_SETTINGS_GET_CLASS(inst)                          (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
37                                                              G_TYPE_SETTINGS, GSettingsClass))
38
39 typedef struct _GSettingsPrivate                            GSettingsPrivate;
40 typedef struct _GSettingsClass                              GSettingsClass;
41 typedef struct _GSettings                                   GSettings;
42
43 struct _GSettingsClass
44 {
45   GObjectClass parent_class;
46
47   /* Signals */
48   void        (*writable_changed)      (GSettings    *settings,
49                                         const gchar  *key);
50   void        (*changed)               (GSettings    *settings,
51                                         const gchar  *key);
52   gboolean    (*writable_change_event) (GSettings    *settings,
53                                         GQuark        key);
54   gboolean    (*change_event)          (GSettings    *settings,
55                                         const GQuark *keys,
56                                         gint          n_keys);
57
58   gpointer padding[20];
59 };
60
61 struct _GSettings
62 {
63   GObject parent_instance;
64   GSettingsPrivate *priv;
65 };
66
67
68 GType                   g_settings_get_type                             (void);
69
70 GSettings *             g_settings_new                                  (const gchar        *schema);
71 GSettings *             g_settings_new_with_path                        (const gchar        *schema,
72                                                                          const gchar        *path);
73 gboolean                g_settings_supports_context                     (const gchar        *context);
74 GSettings *             g_settings_new_with_context                     (const gchar        *schema,
75                                                                          const gchar        *context);
76 GSettings *             g_settings_new_with_context_and_path            (const gchar        *schema,
77                                                                          const gchar        *context,
78                                                                          const gchar        *path);
79
80 gboolean                g_settings_set_value                            (GSettings          *settings,
81                                                                          const gchar        *key,
82                                                                          GVariant           *value);
83 GVariant *              g_settings_get_value                            (GSettings          *settings,
84                                                                          const gchar        *key);
85
86 gboolean                g_settings_set                                  (GSettings          *settings,
87                                                                          const gchar        *key,
88                                                                          const gchar        *format,
89                                                                          ...);
90 void                    g_settings_get                                  (GSettings          *settings,
91                                                                          const gchar        *key,
92                                                                          const gchar        *format,
93                                                                          ...);
94
95 gint                    g_settings_get_int                              (GSettings          *settings,
96                                                                          const gchar        *key);
97 gboolean                g_settings_set_int                              (GSettings          *settings,
98                                                                          const gchar        *key,
99                                                                          gint                value);
100 gchar *                 g_settings_get_string                           (GSettings          *settings,
101                                                                          const gchar        *key);
102 gboolean                g_settings_set_string                           (GSettings          *settings,
103                                                                          const gchar        *key,
104                                                                          const gchar        *value);
105 gboolean                g_settings_get_boolean                          (GSettings          *settings,
106                                                                          const gchar        *key);
107 gboolean                g_settings_set_boolean                          (GSettings          *settings,
108                                                                          const gchar        *key,
109                                                                          gboolean            value);
110 gdouble                 g_settings_get_double                           (GSettings          *settings,
111                                                                          const gchar        *key);
112 gboolean                g_settings_set_double                           (GSettings          *settings,
113                                                                          const gchar        *key,
114                                                                          gdouble             value);
115 gchar **                g_settings_get_strv                             (GSettings          *settings,
116                                                                          const gchar        *key,
117                                                                          gsize              *length);
118 gboolean                g_settings_set_strv                             (GSettings          *settings,
119                                                                          const gchar        *key,
120                                                                          const gchar *const *value,
121                                                                          gssize              length);
122
123 GSettings *             g_settings_get_child                            (GSettings          *settings,
124                                                                          const gchar        *name);
125
126 gboolean                g_settings_is_writable                          (GSettings          *settings,
127                                                                          const gchar        *name);
128
129 void                    g_settings_delay                                (GSettings          *settings);
130 void                    g_settings_apply                                (GSettings          *settings);
131 void                    g_settings_revert                               (GSettings          *settings);
132 gboolean                g_settings_get_has_unapplied                    (GSettings          *settings);
133
134 /**
135  * GSettingsBindSetMapping:
136  * @value: a #GValue containing the property value to map
137  * @expected_type: the #GVariantType to create
138  * @user_data: user data that was specified when the binding was created
139  * @returns: a new #GVariant holding the data from @value,
140  *     or %NULL in case of an error
141  *
142  * The type for the function that is used to convert an object property
143  * value to a #GVariant for storing it in #GSettings.
144  */
145 typedef GVariant *    (*GSettingsBindSetMapping)                        (const GValue       *value,
146                                                                          const GVariantType *expected_type,
147                                                                          gpointer            user_data);
148
149 /**
150  * GSettingsBindGetMapping:
151  * @value: return location for the property value
152  * @variant: the #GVariant
153  * @user_data: user data that was specified when the binding was created
154  * @returns: %TRUE if the conversion succeeded, %FALSE in case of an error
155  *
156  * The type for the function that is used to convert from #GSettings to
157  * an object property. The @value is already initialized to hold values
158  * of the appropriate type.
159  */
160 typedef gboolean      (*GSettingsBindGetMapping)                        (GValue             *value,
161                                                                          GVariant           *variant,
162                                                                          gpointer            user_data);
163
164 /**
165  * GSettingsBindFlags:
166  * @G_SETTINGS_BIND_DEFAULT: Equivalent to <literal>G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET</literal>
167  * @G_SETTINGS_BIND_GET: Update the #GObject property when the setting changes.
168  *     It is an error to use this flag if the property is not writable.
169  * @G_SETTINGS_BIND_SET: Update the setting when the #GObject property changes.
170  *     It is an error to use this flag if the property is not readable.
171  * @G_SETTINGS_BIND_NO_SENSITIVITY: Do not try to bind a "sensitivity" property to the writability of the setting
172  * @G_SETTINGS_BIND_GET_NO_CHANGES: When set in addition to #G_SETTINGS_BIND_GET, set the #GObject property
173  *     value initially from the setting, but do not listen for changes of the setting
174  *
175  * Flags used when creating a binding. These flags determine in which
176  * direction the binding works. The default is to synchronize in both
177  * directions.
178  */
179 typedef enum
180 {
181   G_SETTINGS_BIND_DEFAULT,
182   G_SETTINGS_BIND_GET            = (1<<0),
183   G_SETTINGS_BIND_SET            = (1<<1),
184   G_SETTINGS_BIND_NO_SENSITIVITY = (1<<2),
185   G_SETTINGS_BIND_GET_NO_CHANGES = (1<<3)
186 } GSettingsBindFlags;
187
188 void                    g_settings_bind                                 (GSettings               *settings,
189                                                                          const gchar             *key,
190                                                                          gpointer                 object,
191                                                                          const gchar             *property,
192                                                                          GSettingsBindFlags       flags);
193 void                    g_settings_bind_with_mapping                    (GSettings               *settings,
194                                                                          const gchar             *key,
195                                                                          gpointer                 object,
196                                                                          const gchar             *property,
197                                                                          GSettingsBindFlags       flags,
198                                                                          GSettingsBindGetMapping  get_mapping,
199                                                                          GSettingsBindSetMapping  set_mapping,
200                                                                          gpointer                 user_data,
201                                                                          GDestroyNotify           destroy);
202 void                    g_settings_bind_writable                        (GSettings               *settings,
203                                                                          const gchar             *key,
204                                                                          gpointer                 object,
205                                                                          const gchar             *property,
206                                                                          gboolean                 inverted);
207 void                    g_settings_unbind                               (gpointer                 object,
208                                                                          const gchar             *property);
209
210 G_END_DECLS
211
212 #endif  /* __G_SETTINGS_H__ */