| 45 } PurplePrefType; |
45 } PurplePrefType; |
| 46 |
46 |
| 47 /** |
47 /** |
| 48 * The type of callbacks for preference changes. |
48 * The type of callbacks for preference changes. |
| 49 * |
49 * |
| 50 * @param name the name of the preference which has changed. |
50 * @name: the name of the preference which has changed. |
| 51 * @param type the type of the preferenced named @a name |
51 * @type: the type of the preferenced named @a name |
| 52 * @param val the new value of the preferencs; should be cast to the correct |
52 * @val: the new value of the preferencs; should be cast to the correct |
| 53 * type. For instance, to recover the value of a #PURPLE_PREF_INT |
53 * type. For instance, to recover the value of a #PURPLE_PREF_INT |
| 54 * preference, use <tt>GPOINTER_TO_INT(val)</tt>. Alternatively, |
54 * preference, use <tt>GPOINTER_TO_INT(val)</tt>. Alternatively, |
| 55 * just call purple_prefs_get_int(), purple_prefs_get_string_list() |
55 * just call purple_prefs_get_int(), purple_prefs_get_string_list() |
| 56 * etc. |
56 * etc. |
| 57 * @param data Arbitrary data specified when the callback was connected with |
57 * @data: Arbitrary data specified when the callback was connected with |
| 58 * purple_prefs_connect_callback(). |
58 * purple_prefs_connect_callback(). |
| 59 * |
59 * |
| 60 * @see purple_prefs_connect_callback() |
60 * @see purple_prefs_connect_callback() |
| 61 */ |
61 */ |
| 62 typedef void (*PurplePrefCallback) (const char *name, PurplePrefType type, |
62 typedef void (*PurplePrefCallback) (const char *name, PurplePrefType type, |
| 89 void purple_prefs_uninit(void); |
89 void purple_prefs_uninit(void); |
| 90 |
90 |
| 91 /** |
91 /** |
| 92 * Add a new typeless pref. |
92 * Add a new typeless pref. |
| 93 * |
93 * |
| 94 * @param name The name of the pref |
94 * @name: The name of the pref |
| 95 */ |
95 */ |
| 96 void purple_prefs_add_none(const char *name); |
96 void purple_prefs_add_none(const char *name); |
| 97 |
97 |
| 98 /** |
98 /** |
| 99 * Add a new boolean pref. |
99 * Add a new boolean pref. |
| 100 * |
100 * |
| 101 * @param name The name of the pref |
101 * @name: The name of the pref |
| 102 * @param value The initial value to set |
102 * @value: The initial value to set |
| 103 */ |
103 */ |
| 104 void purple_prefs_add_bool(const char *name, gboolean value); |
104 void purple_prefs_add_bool(const char *name, gboolean value); |
| 105 |
105 |
| 106 /** |
106 /** |
| 107 * Add a new integer pref. |
107 * Add a new integer pref. |
| 108 * |
108 * |
| 109 * @param name The name of the pref |
109 * @name: The name of the pref |
| 110 * @param value The initial value to set |
110 * @value: The initial value to set |
| 111 */ |
111 */ |
| 112 void purple_prefs_add_int(const char *name, int value); |
112 void purple_prefs_add_int(const char *name, int value); |
| 113 |
113 |
| 114 /** |
114 /** |
| 115 * Add a new string pref. |
115 * Add a new string pref. |
| 116 * |
116 * |
| 117 * @param name The name of the pref |
117 * @name: The name of the pref |
| 118 * @param value The initial value to set |
118 * @value: The initial value to set |
| 119 */ |
119 */ |
| 120 void purple_prefs_add_string(const char *name, const char *value); |
120 void purple_prefs_add_string(const char *name, const char *value); |
| 121 |
121 |
| 122 /** |
122 /** |
| 123 * Add a new string list pref. |
123 * Add a new string list pref. |
| 124 * |
124 * |
| 125 * @param name The name of the pref |
125 * @name: The name of the pref |
| 126 * @param value The initial value to set |
126 * @value: The initial value to set |
| 127 * @note This function takes a copy of the strings in the value list. The list |
127 * @note This function takes a copy of the strings in the value list. The list |
| 128 * itself and original copies of the strings are up to the caller to |
128 * itself and original copies of the strings are up to the caller to |
| 129 * free. |
129 * free. |
| 130 */ |
130 */ |
| 131 void purple_prefs_add_string_list(const char *name, GList *value); |
131 void purple_prefs_add_string_list(const char *name, GList *value); |
| 132 |
132 |
| 133 /** |
133 /** |
| 134 * Add a new path pref. |
134 * Add a new path pref. |
| 135 * |
135 * |
| 136 * @param name The name of the pref |
136 * @name: The name of the pref |
| 137 * @param value The initial value to set |
137 * @value: The initial value to set |
| 138 */ |
138 */ |
| 139 void purple_prefs_add_path(const char *name, const char *value); |
139 void purple_prefs_add_path(const char *name, const char *value); |
| 140 |
140 |
| 141 /** |
141 /** |
| 142 * Add a new path list pref. |
142 * Add a new path list pref. |
| 143 * |
143 * |
| 144 * @param name The name of the pref |
144 * @name: The name of the pref |
| 145 * @param value The initial value to set |
145 * @value: The initial value to set |
| 146 * @note This function takes a copy of the strings in the value list. The list |
146 * @note This function takes a copy of the strings in the value list. The list |
| 147 * itself and original copies of the strings are up to the caller to |
147 * itself and original copies of the strings are up to the caller to |
| 148 * free. |
148 * free. |
| 149 */ |
149 */ |
| 150 void purple_prefs_add_path_list(const char *name, GList *value); |
150 void purple_prefs_add_path_list(const char *name, GList *value); |
| 151 |
151 |
| 152 |
152 |
| 153 /** |
153 /** |
| 154 * Remove a pref. |
154 * Remove a pref. |
| 155 * |
155 * |
| 156 * @param name The name of the pref |
156 * @name: The name of the pref |
| 157 */ |
157 */ |
| 158 void purple_prefs_remove(const char *name); |
158 void purple_prefs_remove(const char *name); |
| 159 |
159 |
| 160 /** |
160 /** |
| 161 * Rename a pref |
161 * Rename a pref |
| 162 * |
162 * |
| 163 * @param oldname The old name of the pref |
163 * @oldname: The old name of the pref |
| 164 * @param newname The new name for the pref |
164 * @newname: The new name for the pref |
| 165 */ |
165 */ |
| 166 void purple_prefs_rename(const char *oldname, const char *newname); |
166 void purple_prefs_rename(const char *oldname, const char *newname); |
| 167 |
167 |
| 168 /** |
168 /** |
| 169 * Rename a boolean pref, toggling it's value |
169 * Rename a boolean pref, toggling it's value |
| 170 * |
170 * |
| 171 * @param oldname The old name of the pref |
171 * @oldname: The old name of the pref |
| 172 * @param newname The new name for the pref |
172 * @newname: The new name for the pref |
| 173 */ |
173 */ |
| 174 void purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname); |
174 void purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname); |
| 175 |
175 |
| 176 /** |
176 /** |
| 177 * Remove all prefs. |
177 * Remove all prefs. |
| 179 void purple_prefs_destroy(void); |
179 void purple_prefs_destroy(void); |
| 180 |
180 |
| 181 /** |
181 /** |
| 182 * Set boolean pref value |
182 * Set boolean pref value |
| 183 * |
183 * |
| 184 * @param name The name of the pref |
184 * @name: The name of the pref |
| 185 * @param value The value to set |
185 * @value: The value to set |
| 186 */ |
186 */ |
| 187 void purple_prefs_set_bool(const char *name, gboolean value); |
187 void purple_prefs_set_bool(const char *name, gboolean value); |
| 188 |
188 |
| 189 /** |
189 /** |
| 190 * Set integer pref value |
190 * Set integer pref value |
| 191 * |
191 * |
| 192 * @param name The name of the pref |
192 * @name: The name of the pref |
| 193 * @param value The value to set |
193 * @value: The value to set |
| 194 */ |
194 */ |
| 195 void purple_prefs_set_int(const char *name, int value); |
195 void purple_prefs_set_int(const char *name, int value); |
| 196 |
196 |
| 197 /** |
197 /** |
| 198 * Set string pref value |
198 * Set string pref value |
| 199 * |
199 * |
| 200 * @param name The name of the pref |
200 * @name: The name of the pref |
| 201 * @param value The value to set |
201 * @value: The value to set |
| 202 */ |
202 */ |
| 203 void purple_prefs_set_string(const char *name, const char *value); |
203 void purple_prefs_set_string(const char *name, const char *value); |
| 204 |
204 |
| 205 /** |
205 /** |
| 206 * Set string list pref value |
206 * Set string list pref value |
| 207 * |
207 * |
| 208 * @param name The name of the pref |
208 * @name: The name of the pref |
| 209 * @param value The value to set |
209 * @value: The value to set |
| 210 */ |
210 */ |
| 211 void purple_prefs_set_string_list(const char *name, GList *value); |
211 void purple_prefs_set_string_list(const char *name, GList *value); |
| 212 |
212 |
| 213 /** |
213 /** |
| 214 * Set path pref value |
214 * Set path pref value |
| 215 * |
215 * |
| 216 * @param name The name of the pref |
216 * @name: The name of the pref |
| 217 * @param value The value to set |
217 * @value: The value to set |
| 218 */ |
218 */ |
| 219 void purple_prefs_set_path(const char *name, const char *value); |
219 void purple_prefs_set_path(const char *name, const char *value); |
| 220 |
220 |
| 221 /** |
221 /** |
| 222 * Set path list pref value |
222 * Set path list pref value |
| 223 * |
223 * |
| 224 * @param name The name of the pref |
224 * @name: The name of the pref |
| 225 * @param value The value to set |
225 * @value: The value to set |
| 226 */ |
226 */ |
| 227 void purple_prefs_set_path_list(const char *name, GList *value); |
227 void purple_prefs_set_path_list(const char *name, GList *value); |
| 228 |
228 |
| 229 |
229 |
| 230 /** |
230 /** |
| 231 * Check if a pref exists |
231 * Check if a pref exists |
| 232 * |
232 * |
| 233 * @param name The name of the pref |
233 * @name: The name of the pref |
| 234 * @return TRUE if the pref exists. Otherwise FALSE. |
234 * Returns: TRUE if the pref exists. Otherwise FALSE. |
| 235 */ |
235 */ |
| 236 gboolean purple_prefs_exists(const char *name); |
236 gboolean purple_prefs_exists(const char *name); |
| 237 |
237 |
| 238 /** |
238 /** |
| 239 * Get pref type |
239 * Get pref type |
| 240 * |
240 * |
| 241 * @param name The name of the pref |
241 * @name: The name of the pref |
| 242 * @return The type of the pref |
242 * Returns: The type of the pref |
| 243 */ |
243 */ |
| 244 PurplePrefType purple_prefs_get_type(const char *name); |
244 PurplePrefType purple_prefs_get_type(const char *name); |
| 245 |
245 |
| 246 /** |
246 /** |
| 247 * Get boolean pref value |
247 * Get boolean pref value |
| 248 * |
248 * |
| 249 * @param name The name of the pref |
249 * @name: The name of the pref |
| 250 * @return The value of the pref |
250 * Returns: The value of the pref |
| 251 */ |
251 */ |
| 252 gboolean purple_prefs_get_bool(const char *name); |
252 gboolean purple_prefs_get_bool(const char *name); |
| 253 |
253 |
| 254 /** |
254 /** |
| 255 * Get integer pref value |
255 * Get integer pref value |
| 256 * |
256 * |
| 257 * @param name The name of the pref |
257 * @name: The name of the pref |
| 258 * @return The value of the pref |
258 * Returns: The value of the pref |
| 259 */ |
259 */ |
| 260 int purple_prefs_get_int(const char *name); |
260 int purple_prefs_get_int(const char *name); |
| 261 |
261 |
| 262 /** |
262 /** |
| 263 * Get string pref value |
263 * Get string pref value |
| 264 * |
264 * |
| 265 * @param name The name of the pref |
265 * @name: The name of the pref |
| 266 * @return The value of the pref |
266 * Returns: The value of the pref |
| 267 */ |
267 */ |
| 268 const char *purple_prefs_get_string(const char *name); |
268 const char *purple_prefs_get_string(const char *name); |
| 269 |
269 |
| 270 /** |
270 /** |
| 271 * Get string list pref value |
271 * Get string list pref value |
| 272 * |
272 * |
| 273 * @param name The name of the pref |
273 * @name: The name of the pref |
| 274 * @return The value of the pref |
274 * Returns: The value of the pref |
| 275 */ |
275 */ |
| 276 GList *purple_prefs_get_string_list(const char *name); |
276 GList *purple_prefs_get_string_list(const char *name); |
| 277 |
277 |
| 278 /** |
278 /** |
| 279 * Get path pref value |
279 * Get path pref value |
| 280 * |
280 * |
| 281 * @param name The name of the pref |
281 * @name: The name of the pref |
| 282 * @return The value of the pref |
282 * Returns: The value of the pref |
| 283 */ |
283 */ |
| 284 const char *purple_prefs_get_path(const char *name); |
284 const char *purple_prefs_get_path(const char *name); |
| 285 |
285 |
| 286 /** |
286 /** |
| 287 * Get path list pref value |
287 * Get path list pref value |
| 288 * |
288 * |
| 289 * @param name The name of the pref |
289 * @name: The name of the pref |
| 290 * @return The value of the pref |
290 * Returns: The value of the pref |
| 291 */ |
291 */ |
| 292 GList *purple_prefs_get_path_list(const char *name); |
292 GList *purple_prefs_get_path_list(const char *name); |
| 293 |
293 |
| 294 /** |
294 /** |
| 295 * Returns a list of children for a pref |
295 * Returns a list of children for a pref |
| 296 * |
296 * |
| 297 * @param name The parent pref |
297 * @name: The parent pref |
| 298 * @return A list of newly allocated strings denoting the names of the children. |
298 * Returns: A list of newly allocated strings denoting the names of the children. |
| 299 * Returns @c NULL if there are no children or if pref doesn't exist. |
299 * Returns @c NULL if there are no children or if pref doesn't exist. |
| 300 * The caller must free all the strings and the list. |
300 * The caller must free all the strings and the list. |
| 301 */ |
301 */ |
| 302 GList *purple_prefs_get_children_names(const char *name); |
302 GList *purple_prefs_get_children_names(const char *name); |
| 303 |
303 |
| 304 /** |
304 /** |
| 305 * Add a callback to a pref (and its children) |
305 * Add a callback to a pref (and its children) |
| 306 * |
306 * |
| 307 * @param handle The handle of the receiver. |
307 * @handle: The handle of the receiver. |
| 308 * @param name The name of the preference |
308 * @name: The name of the preference |
| 309 * @param cb The callback function |
309 * @cb: The callback function |
| 310 * @param data The data to pass to the callback function. |
310 * @data: The data to pass to the callback function. |
| 311 * |
311 * |
| 312 * @return An id to disconnect the callback |
312 * Returns: An id to disconnect the callback |
| 313 * |
313 * |
| 314 * @see purple_prefs_disconnect_callback |
314 * @see purple_prefs_disconnect_callback |
| 315 */ |
315 */ |
| 316 guint purple_prefs_connect_callback(void *handle, const char *name, PurplePrefCallback cb, |
316 guint purple_prefs_connect_callback(void *handle, const char *name, PurplePrefCallback cb, |
| 317 gpointer data); |
317 gpointer data); |