evolution-3.6.4/shell/e-shell-settings.c

No issues found

  1 /*
  2  * e-shell-settings.c
  3  *
  4  * This program 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 License, or (at your option) version 3.
  8  *
  9  * This program 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 the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 19  *
 20  */
 21 
 22 /**
 23  * SECTION: e-shell-settings
 24  * @short_description: settings management
 25  * @include: shell/e-shell-settings.h
 26  **/
 27 
 28 #ifdef HAVE_CONFIG_H
 29 #include <config.h>
 30 #endif
 31 
 32 #include "e-shell-settings.h"
 33 
 34 #define E_SHELL_SETTINGS_GET_PRIVATE(obj) \
 35 	(G_TYPE_INSTANCE_GET_PRIVATE \
 36 	((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate))
 37 
 38 #define E_SHELL_SETTINGS_GET_PRIVATE(obj) \
 39 	(G_TYPE_INSTANCE_GET_PRIVATE \
 40 	((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate))
 41 
 42 struct _EShellSettingsPrivate {
 43 	GArray *value_array;
 44 	guint debug	: 1;
 45 };
 46 
 47 static GList *instances;
 48 static guint property_count;
 49 static gpointer parent_class;
 50 
 51 static gboolean
 52 shell_settings_value_equal (const GValue *v1,
 53                             const GValue *v2,
 54                             gboolean is_debug)
 55 {
 56 	if (!v1 || !v2)
 57 		return v1 == v2;
 58 
 59 	if (G_VALUE_HOLDS_STRING (v1) &&
 60 	    G_VALUE_HOLDS_STRING (v2)) {
 61 		return g_strcmp0 (
 62 			g_value_get_string (v1),
 63 			g_value_get_string (v2)) == 0;
 64 	} else if (G_VALUE_HOLDS_UCHAR (v1) &&
 65 			G_VALUE_HOLDS_UCHAR (v2)) {
 66 		return g_value_get_uchar (v1) == g_value_get_uchar (v2);
 67 	} else if (G_VALUE_HOLDS_CHAR (v1) &&
 68 		   G_VALUE_HOLDS_CHAR (v2)) {
 69 		return g_value_get_schar (v1) == g_value_get_schar (v2);
 70 	} else if (G_VALUE_HOLDS_INT (v1) &&
 71 		   G_VALUE_HOLDS_INT (v2)) {
 72 		return g_value_get_int (v1) == g_value_get_int (v2);
 73 	} else if (G_VALUE_HOLDS_UINT (v1) &&
 74 		   G_VALUE_HOLDS_UINT (v2)) {
 75 		return g_value_get_uint (v1) == g_value_get_uint (v2);
 76 	} else if (G_VALUE_HOLDS_LONG (v1) &&
 77 		   G_VALUE_HOLDS_LONG (v2)) {
 78 		return g_value_get_long (v1) == g_value_get_long (v2);
 79 	} else if (G_VALUE_HOLDS_ULONG (v1) &&
 80 		   G_VALUE_HOLDS_ULONG (v2)) {
 81 		return g_value_get_ulong (v1) == g_value_get_ulong (v2);
 82 	} else if (G_VALUE_HOLDS_INT64 (v1) &&
 83 		   G_VALUE_HOLDS_INT64 (v2)) {
 84 		return g_value_get_int64 (v1) == g_value_get_int64 (v2);
 85 	} else if (G_VALUE_HOLDS_UINT64 (v1) &&
 86 		   G_VALUE_HOLDS_UINT64 (v2)) {
 87 		return g_value_get_uint64 (v1) == g_value_get_uint64 (v2);
 88 	} else if (G_VALUE_HOLDS_DOUBLE (v1) &&
 89 		   G_VALUE_HOLDS_DOUBLE (v2)) {
 90 		return g_value_get_double (v1) == g_value_get_double (v2);
 91 	} else if (G_VALUE_HOLDS_BOOLEAN (v1) &&
 92 		   G_VALUE_HOLDS_BOOLEAN (v2)) {
 93 		return g_value_get_boolean (v1) == g_value_get_boolean (v2);
 94 	} else if (G_VALUE_HOLDS_POINTER (v1) &&
 95 		   G_VALUE_HOLDS_POINTER (v2)) {
 96 		return g_value_get_pointer (v1) == g_value_get_pointer (v2);
 97 	}
 98 
 99 	if (is_debug)
100 		g_debug (
101 			"%s: Cannot compare '%s' with '%s'",
102 			G_STRFUNC,
103 			G_VALUE_TYPE_NAME (v1),
104 			G_VALUE_TYPE_NAME (v2));
105 
106 	return FALSE;
107 }
108 
109 static GParamSpec *
110 shell_settings_pspec_for_key (const gchar *property_name,
111                               const gchar *schema,
112                               const gchar *key)
113 {
114 	GSettings *settings;
115 	GVariant *v;
116 	GParamSpec *pspec;
117 	const gchar *bad_type;
118 
119 	settings = g_settings_new (schema);
120 
121 	v = g_settings_get_value (settings, key);
122 
123 	if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) {
124 		pspec = g_param_spec_string (
125 			property_name, NULL, NULL,
126 			g_variant_get_string (v, NULL),
127 			G_PARAM_READWRITE);
128 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) {
129 		pspec = g_param_spec_int (
130 			property_name, NULL, NULL,
131 			G_MININT, G_MAXINT,
132 			g_variant_get_byte (v),
133 			G_PARAM_READWRITE);
134 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT16)) {
135 		pspec = g_param_spec_int (
136 			property_name, NULL, NULL,
137 			G_MININT, G_MAXINT,
138 			g_variant_get_int16 (v),
139 			G_PARAM_READWRITE);
140 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT16)) {
141 		pspec = g_param_spec_int (
142 			property_name, NULL, NULL,
143 			G_MININT, G_MAXINT,
144 			g_variant_get_uint16 (v),
145 			G_PARAM_READWRITE);
146 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) {
147 		pspec = g_param_spec_int (
148 			property_name, NULL, NULL,
149 			G_MININT, G_MAXINT,
150 			g_variant_get_int32 (v),
151 			G_PARAM_READWRITE);
152 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) {
153 		pspec = g_param_spec_int (
154 			property_name, NULL, NULL,
155 			G_MININT, G_MAXINT,
156 			g_variant_get_uint32 (v),
157 			G_PARAM_READWRITE);
158 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) {
159 		pspec = g_param_spec_int (
160 			property_name, NULL, NULL,
161 			G_MININT, G_MAXINT,
162 			g_variant_get_int64 (v),
163 			G_PARAM_READWRITE);
164 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) {
165 		pspec = g_param_spec_int (
166 			property_name, NULL, NULL,
167 			G_MININT, G_MAXINT,
168 			g_variant_get_uint64 (v),
169 			G_PARAM_READWRITE);
170 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_DOUBLE)) {
171 		pspec = g_param_spec_double (
172 			property_name, NULL, NULL,
173 			-G_MAXDOUBLE, G_MAXDOUBLE,
174 			g_variant_get_double (v),
175 			G_PARAM_READWRITE);
176 	} else if (g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN)) {
177 		pspec = g_param_spec_boolean (
178 			property_name, NULL, NULL,
179 			g_variant_get_boolean (v),
180 			G_PARAM_READWRITE);
181 	} else {
182 		bad_type = g_variant_get_type_string (v);
183 		goto fail;
184 	}
185 
186 	g_variant_unref (v);
187 	g_object_unref (settings);
188 
189 	return pspec;
190 
191 fail:
192 	g_error (
193 		"Unable to create EShellSettings property for "
194 		"GSettings key '%s' of type '%s'", key, bad_type);
195 	g_assert_not_reached ();
196 }
197 
198 static void
199 shell_settings_set_property (GObject *object,
200                              guint property_id,
201                              const GValue *value,
202                              GParamSpec *pspec)
203 {
204 	EShellSettingsPrivate *priv;
205 	GValue *dest_value;
206 
207 	priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
208 
209 	dest_value = &g_array_index (
210 		priv->value_array, GValue, property_id - 1);
211 
212 	if (shell_settings_value_equal (value, dest_value, priv->debug)) {
213 		if (priv->debug)
214 			g_debug ("Setting '%s' set, but it didn't change", pspec->name);
215 		return;
216 	}
217 
218 	g_value_copy (value, dest_value);
219 	g_object_notify (object, pspec->name);
220 
221 	if (priv->debug) {
222 		gchar *contents;
223 
224 		contents = g_strdup_value_contents (value);
225 		g_debug (
226 			"Setting '%s' set to '%s' (%s)",
227 			pspec->name, contents, G_VALUE_TYPE_NAME (value));
228 		g_free (contents);
229 	}
230 }
231 
232 static void
233 shell_settings_get_property (GObject *object,
234                              guint property_id,
235                              GValue *value,
236                              GParamSpec *pspec)
237 {
238 	EShellSettingsPrivate *priv;
239 	GValue *src_value;
240 
241 	priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
242 
243 	src_value = &g_array_index (
244 		priv->value_array, GValue, property_id - 1);
245 
246 	g_value_copy (src_value, value);
247 }
248 
249 static void
250 shell_settings_finalize (GObject *object)
251 {
252 	EShellSettingsPrivate *priv;
253 	guint ii;
254 
255 	priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
256 
257 	for (ii = 0; ii < priv->value_array->len; ii++)
258 		g_value_unset (&g_array_index (priv->value_array, GValue, ii));
259 
260 	g_array_free (priv->value_array, TRUE);
261 
262 	/* Chain up to parent's finalize() method. */
263 	G_OBJECT_CLASS (parent_class)->finalize (object);
264 }
265 
266 static void
267 shell_settings_class_init (EShellSettingsClass *class)
268 {
269 	GObjectClass *object_class;
270 
271 	parent_class = g_type_class_peek_parent (class);
272 	g_type_class_add_private (class, sizeof (EShellSettingsPrivate));
273 
274 	object_class = G_OBJECT_CLASS (class);
275 	object_class->set_property = shell_settings_set_property;
276 	object_class->get_property = shell_settings_get_property;
277 	object_class->finalize = shell_settings_finalize;
278 }
279 
280 static void
281 shell_settings_init (EShellSettings *shell_settings,
282                      GObjectClass *object_class)
283 {
284 	GArray *value_array;
285 	GParamSpec **pspecs;
286 	guint ii;
287 
288 	instances = g_list_prepend (instances, shell_settings);
289 
290 	value_array = g_array_new (FALSE, TRUE, sizeof (GValue));
291 	g_array_set_size (value_array, property_count);
292 
293 	shell_settings->priv = E_SHELL_SETTINGS_GET_PRIVATE (shell_settings);
294 	shell_settings->priv->value_array = value_array;
295 
296 	g_object_freeze_notify (G_OBJECT (shell_settings));
297 
298 	pspecs = g_object_class_list_properties (object_class, NULL);
299 	for (ii = 0; ii < property_count; ii++) {
300 		GParamSpec *pspec = pspecs[ii];
301 		GValue *value;
302 
303 		value = &g_array_index (value_array, GValue, ii);
304 		g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
305 		g_param_value_set_default (pspec, value);
306 		g_object_notify (G_OBJECT (shell_settings), pspec->name);
307 
308 		/* FIXME Need to bind those properties that have
309 		 *       associated GSettings keys. */
310 	}
311 	g_free (pspecs);
312 
313 	g_object_thaw_notify (G_OBJECT (shell_settings));
314 }
315 
316 GType
317 e_shell_settings_get_type (void)
318 {
319 	static GType type = 0;
320 
321 	if (G_UNLIKELY (type == 0)) {
322 		const GTypeInfo type_info = {
323 			sizeof (EShellSettingsClass),
324 			(GBaseInitFunc) NULL,
325 			(GBaseFinalizeFunc) NULL,
326 			(GClassInitFunc) shell_settings_class_init,
327 			(GClassFinalizeFunc) NULL,
328 			NULL,  /* class_data */
329 			sizeof (EShellSettings),
330 			0,     /* n_preallocs */
331 			(GInstanceInitFunc) shell_settings_init,
332 			NULL   /* value_table */
333 		};
334 
335 		type = g_type_register_static (
336 			G_TYPE_OBJECT, "EShellSettings", &type_info, 0);
337 	}
338 
339 	return type;
340 }
341 
342 /**
343  * e_shell_settings_install_property:
344  * @pspec: a #GParamSpec
345  *
346  * Installs a new #EShellSettings class property from @pspec.
347  * This is usually done during initialization of an #EShellBackend
348  * or other dynamically loaded entity.
349  **/
350 void
351 e_shell_settings_install_property (GParamSpec *pspec)
352 {
353 	static GObjectClass *class = NULL;
354 	GList *iter, *next;
355 
356 	g_return_if_fail (G_IS_PARAM_SPEC (pspec));
357 
358 	if (G_UNLIKELY (class == NULL))
359 		class = g_type_class_ref (E_TYPE_SHELL_SETTINGS);
360 
361 	if (g_object_class_find_property (class, pspec->name) != NULL) {
362 		g_warning (
363 			"Settings property \"%s\" already exists",
364 			pspec->name);
365 		return;
366 	}
367 
368 	for (iter = instances; iter != NULL; iter = iter->next)
369 		g_object_freeze_notify (iter->data);
370 
371 	g_object_class_install_property (class, ++property_count, pspec);
372 
373 	for (iter = instances; iter != NULL; iter = iter->next) {
374 		EShellSettings *shell_settings;
375 		GArray *value_array;
376 		GValue *value;
377 
378 		shell_settings = E_SHELL_SETTINGS (iter->data);
379 		value_array = shell_settings->priv->value_array;
380 		g_array_set_size (value_array, property_count);
381 
382 		value = &g_array_index (
383 			value_array, GValue, property_count - 1);
384 		g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
385 		g_param_value_set_default (pspec, value);
386 		g_object_notify (G_OBJECT (shell_settings), pspec->name);
387 	}
388 
389 	for (iter = instances; iter != NULL; iter = next) {
390 		next = iter->next;
391 		g_object_thaw_notify (iter->data);
392 	}
393 }
394 
395 /**
396  * e_shell_settings_install_property_for_key:
397  * @property_name: the name of the property to install
398  * @schema: the GSettings schema to use for @key
399  * @key: the GSettings key to bind the property to
400  *
401  * Installs a new #EShellSettings class property by examining the
402  * GSettings schema for @key to determine the appropriate type and
403  * default value.  This is usually done during initialization of an
404  * #EShellBackend of other dynamically loaded entity.
405  *
406  * After the class property is installed, all #EShellSettings instances
407  * are bound to @key, causing @property_name and @key to have
408  * the same value at all times.
409  **/
410 void
411 e_shell_settings_install_property_for_key (const gchar *property_name,
412                                            const gchar *schema,
413                                            const gchar *key)
414 {
415 	GParamSpec *pspec;
416 	GList *iter, *next;
417 	GSettings *settings;
418 
419 	g_return_if_fail (property_name != NULL);
420 	g_return_if_fail (schema != NULL);
421 	g_return_if_fail (key != NULL);
422 
423 	pspec = shell_settings_pspec_for_key (property_name, schema, key);
424 	if (!pspec)
425 		return;
426 
427 	e_shell_settings_install_property (pspec);
428 
429 	settings = g_settings_new (schema);
430 
431 	for (iter = instances; iter != NULL; iter = iter->next)
432 		g_object_freeze_notify (iter->data);
433 
434 	for (iter = instances; iter != NULL; iter = iter->next) {
435 		EShellSettings *shell_settings;
436 
437 		shell_settings = E_SHELL_SETTINGS (iter->data);
438 
439 		g_settings_bind (
440 			settings, key, G_OBJECT (shell_settings),
441 			property_name, G_SETTINGS_BIND_DEFAULT);
442 	}
443 
444 	for (iter = instances; iter != NULL; iter = next) {
445 		next = iter->next;
446 		g_object_thaw_notify (iter->data);
447 	}
448 
449 	g_object_unref (settings);
450 }
451 
452 /**
453  * e_shell_settings_enable_debug:
454  * @shell_settings: an #EShellSettings
455  *
456  * Print a debug message to standard output when a property value changes.
457  **/
458 void
459 e_shell_settings_enable_debug (EShellSettings *shell_settings)
460 {
461 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
462 
463 	shell_settings->priv->debug = TRUE;
464 }
465 
466 /**
467  * e_shell_settings_get_boolean:
468  * @shell_settings: an #EShellSettings
469  * @property_name: an installed property name
470  *
471  * Return the contents of an #EShellSettings property of type
472  * #G_TYPE_BOOLEAN.
473  *
474  * Returns: boolean contents of @property_name
475  **/
476 gboolean
477 e_shell_settings_get_boolean (EShellSettings *shell_settings,
478                               const gchar *property_name)
479 {
480 	GObject *object;
481 	GValue value = { 0, };
482 	gboolean v_boolean;
483 
484 	g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), FALSE);
485 	g_return_val_if_fail (property_name != NULL, FALSE);
486 
487 	object = G_OBJECT (shell_settings);
488 	g_value_init (&value, G_TYPE_BOOLEAN);
489 	g_object_get_property (object, property_name, &value);
490 	v_boolean = g_value_get_boolean (&value);
491 	g_value_unset (&value);
492 
493 	return v_boolean;
494 }
495 
496 /**
497  * e_shell_settings_set_boolean:
498  * @shell_settings: an #EShellSettings
499  * @property_name: an installed property name
500  * @v_boolean: boolean value to be set
501  *
502  * Sets the contents of an #EShellSettings property of type #G_TYPE_BOOLEAN
503  * to @v_boolean.  If @property_name is bound to a GSettings key, the GSettings key
504  * will also be set to @v_boolean.
505  **/
506 void
507 e_shell_settings_set_boolean (EShellSettings *shell_settings,
508                               const gchar *property_name,
509                               gboolean v_boolean)
510 {
511 	GObject *object;
512 	GValue value = { 0, };
513 
514 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
515 	g_return_if_fail (property_name != NULL);
516 
517 	object = G_OBJECT (shell_settings);
518 	g_value_init (&value, G_TYPE_BOOLEAN);
519 	g_value_set_boolean (&value, v_boolean);
520 	g_object_set_property (object, property_name, &value);
521 	g_value_unset (&value);
522 }
523 
524 /**
525  * e_shell_settings_get_int:
526  * @shell_settings: an #EShellSettings
527  * @property_name: an installed property name
528  *
529  * Returns the contents of an #EShellSettings property of type
530  * #G_TYPE_INT.
531  *
532  * Returns: integer contents of @property_name
533  **/
534 gint
535 e_shell_settings_get_int (EShellSettings *shell_settings,
536                           const gchar *property_name)
537 {
538 	GObject *object;
539 	GValue value = { 0, };
540 	gint v_int;
541 
542 	g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), 0);
543 	g_return_val_if_fail (property_name != NULL, 0);
544 
545 	object = G_OBJECT (shell_settings);
546 	g_value_init (&value, G_TYPE_INT);
547 	g_object_get_property (object, property_name, &value);
548 	v_int = g_value_get_int (&value);
549 	g_value_unset (&value);
550 
551 	return v_int;
552 }
553 
554 /**
555  * e_shell_settings_set_int:
556  * @shell_settings: an #EShellSettings
557  * @property_name: an installed property name
558  * @v_int: integer value to be set
559  *
560  * Sets the contents of an #EShellSettings property of type #G_TYPE_INT
561  * to @v_int.  If @property_name is bound to a GSettings key, the GSettings key
562  * will also be set to @v_int.
563  **/
564 void
565 e_shell_settings_set_int (EShellSettings *shell_settings,
566                           const gchar *property_name,
567                           gint v_int)
568 {
569 	GObject *object;
570 	GValue value = { 0, };
571 
572 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
573 	g_return_if_fail (property_name != NULL);
574 
575 	object = G_OBJECT (shell_settings);
576 	g_value_init (&value, G_TYPE_INT);
577 	g_value_set_int (&value, v_int);
578 	g_object_set_property (object, property_name, &value);
579 	g_value_unset (&value);
580 }
581 
582 /**
583  * e_shell_settings_get_string:
584  * @shell_settings: an #EShellSettings
585  * @property_name: an installed property name
586  *
587  * Returns the contents of an #EShellSettings property of type
588  * #G_TYPE_STRING.  The returned string should be freed using g_free().
589  *
590  * Returns: string contents of @property_name
591  **/
592 gchar *
593 e_shell_settings_get_string (EShellSettings *shell_settings,
594                              const gchar *property_name)
595 {
596 	GObject *object;
597 	GValue value = { 0, };
598 	gchar *v_string;
599 
600 	g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
601 	g_return_val_if_fail (property_name != NULL, NULL);
602 
603 	object = G_OBJECT (shell_settings);
604 	g_value_init (&value, G_TYPE_STRING);
605 	g_object_get_property (object, property_name, &value);
606 	v_string = g_value_dup_string (&value);
607 	g_value_unset (&value);
608 
609 	return v_string;
610 }
611 
612 /**
613  * e_shell_settings_set_string:
614  * @shell_settings: an #EShellSettings
615  * @property_name: an installed property name
616  * @v_string: string to be set
617  *
618  * Sets the contents of an #EShellSettings property of type #G_TYPE_STRING
619  * to @v_string.  If @property_name is bound to a GSettings key, the GSettings key
620  * will also be set to @v_string.
621  **/
622 void
623 e_shell_settings_set_string (EShellSettings *shell_settings,
624                              const gchar *property_name,
625                              const gchar *v_string)
626 {
627 	GObject *object;
628 	GValue value = { 0, };
629 
630 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
631 	g_return_if_fail (property_name != NULL);
632 
633 	object = G_OBJECT (shell_settings);
634 	g_value_init (&value, G_TYPE_STRING);
635 	g_value_set_string (&value, v_string);
636 	g_object_set_property (object, property_name, &value);
637 	g_value_unset (&value);
638 }
639 
640 /**
641  * e_shell_settings_get_object:
642  * @shell_settings: an #EShellSettings
643  * @property_name: an installed property name
644  *
645  * Returns the contents of an #EShellSettings property of type
646  * #G_TYPE_OBJECT.  The caller owns the reference to the returned
647  * object, and should call g_object_unref() when finished with it.
648  *
649  * Returns: a new reference to the object under @property_name
650  **/
651 gpointer
652 e_shell_settings_get_object (EShellSettings *shell_settings,
653                              const gchar *property_name)
654 {
655 	GObject *object;
656 	GValue value = { 0, };
657 	gpointer v_object;
658 
659 	g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
660 	g_return_val_if_fail (property_name != NULL, NULL);
661 
662 	object = G_OBJECT (shell_settings);
663 	g_value_init (&value, G_TYPE_OBJECT);
664 	g_object_get_property (object, property_name, &value);
665 	v_object = g_value_dup_object (&value);
666 	g_value_unset (&value);
667 
668 	return v_object;
669 }
670 
671 /**
672  * e_shell_settings_set_object:
673  * @shell_settings: an #EShellSettings
674  * @property_name: an installed property name
675  * @v_object: object to be set
676  *
677  * Sets the contents of an #EShellSettings property of type #G_TYPE_OBJECT
678  * to @v_object.
679  **/
680 void
681 e_shell_settings_set_object (EShellSettings *shell_settings,
682                              const gchar *property_name,
683                              gpointer v_object)
684 {
685 	GObject *object;
686 	GValue value = { 0, };
687 
688 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
689 	g_return_if_fail (property_name != NULL);
690 
691 	object = G_OBJECT (shell_settings);
692 	g_value_init (&value, G_TYPE_OBJECT);
693 	g_value_set_object (&value, v_object);
694 	g_object_set_property (object, property_name, &value);
695 	g_value_unset (&value);
696 }
697 
698 /**
699  * e_shell_settings_get_pointer:
700  * @shell_settings: an #EShellSettings
701  * @property_name: an installed property name
702  *
703  * Returns the contents of an #EShellSettings property of type
704  * #G_TYPE_POINTER.
705  *
706  * Returns: pointer contents of @property_name
707  **/
708 gpointer
709 e_shell_settings_get_pointer (EShellSettings *shell_settings,
710                               const gchar *property_name)
711 {
712 	GObject *object;
713 	GValue value = { 0, };
714 	gpointer v_pointer;
715 
716 	g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
717 	g_return_val_if_fail (property_name != NULL, NULL);
718 
719 	object = G_OBJECT (shell_settings);
720 	g_value_init (&value, G_TYPE_POINTER);
721 	g_object_get_property (object, property_name, &value);
722 	v_pointer = g_value_get_pointer (&value);
723 	g_value_unset (&value);
724 
725 	return v_pointer;
726 }
727 
728 /**
729  * e_shell_settings_set_pointer:
730  * @shell_settings: an #EShellSettings
731  * @property_name: an installed property name
732  * @v_pointer: pointer to be set
733  *
734  * Sets the contents of an #EShellSettings property of type #G_TYPE_POINTER
735  * to @v_pointer.
736  **/
737 void
738 e_shell_settings_set_pointer (EShellSettings *shell_settings,
739                               const gchar *property_name,
740                               gpointer v_pointer)
741 {
742 	GObject *object;
743 	GValue value = { 0, };
744 
745 	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
746 	g_return_if_fail (property_name != NULL);
747 
748 	object = G_OBJECT (shell_settings);
749 	g_value_init (&value, G_TYPE_POINTER);
750 	g_value_set_pointer (&value, v_pointer);
751 	g_object_set_property (object, property_name, &value);
752 	g_value_unset (&value);
753 }