[evolution/kill-bonobo] Simplify binding EShellSettings properties to GConf keys.



commit fac731e7359c978ff730d48f9ab88a5794450206
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jul 31 00:45:38 2009 -0400

    Simplify binding EShellSettings properties to GConf keys.

 calendar/gui/apps_evolution_calendar.schemas.in |   48 +++
 doc/reference/shell/eshell-sections.txt         |    2 +-
 doc/reference/shell/tmpl/e-shell-settings.sgml  |    3 +-
 doc/reference/shell/tmpl/eshell-unused.sgml     |    9 +
 mail/evolution-mail.schemas.in                  |   43 ++-
 modules/calendar/e-cal-shell-content.c          |    2 +-
 modules/calendar/e-cal-shell-settings.c         |  197 ++--------
 modules/mail/e-mail-shell-settings.c            |  483 ++++-------------------
 shell/e-shell-settings.c                        |  191 ++++++++--
 shell/e-shell-settings.h                        |    4 +-
 shell/e-shell.c                                 |   63 +---
 11 files changed, 392 insertions(+), 653 deletions(-)
---
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in
index 6e5e057..f87c9a2 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in
@@ -4,6 +4,17 @@
     <!-- Display -->
 
     <schema>
+      <key>/schemas/apps/evolution/calendar/display/primary_calendar</key>
+      <applyto>/apps/evolution/calendar/display/primary_calendar</applyto>
+      <owner>evolution-calendar</owner>
+      <type>string</type>
+      <locale name="C">
+        <short>Primary calendar</short>
+        <long>URI of the highlighted ("primary") calendar</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/calendar/display/timezone</key>
       <applyto>/apps/evolution/calendar/display/timezone</applyto>
       <owner>evolution-calendar</owner>
@@ -412,9 +423,46 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/evolution/calendar/display/use_system_timezone</key>
+      <applyto>/apps/evolution/calendar/display/use_system_timezone</applyto>
+      <owner>evolution-calendar</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Use system timezone</short>
+        <long>Use the system timezone instead of the timezone selected
+        in Evolution.</long>
+      </locale>
+    </schema>
+
+    <!-- Memos -->
+
+    <schema>
+      <key>/schemas/apps/evolution/calendar/memos/primary_memos</key>
+      <applyto>/apps/evolution/calendar/memos/primary_memos</applyto>
+      <owner>evolution-calendar</owner>
+      <type>string</type>
+      <locale name="C">
+        <short>Primary memo list</short>
+        <long>URI of the highlighted ("primary") memo list</long>
+      </locale>
+    </schema>
+
     <!-- Tasks -->
 
     <schema>
+      <key>/schemas/apps/evolution/calendar/tasks/primary_tasks</key>
+      <applyto>/apps/evolution/calendar/tasks/primary_tasks</applyto>
+      <owner>evolution-calendar</owner>
+      <type>string</type>
+      <locale name="C">
+        <short>Primary task list</short>
+        <long>URI of the highlighted ("primary") task list</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/calendar/tasks/hide_completed</key>
       <applyto>/apps/evolution/calendar/tasks/hide_completed</applyto>
       <owner>evolution-calendar</owner>
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 5ae8c35..8bfb57b 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -117,7 +117,7 @@ EShellContentPrivate
 <TITLE>EShellSettings</TITLE>
 EShellSettings
 e_shell_settings_install_property
-e_shell_settings_bind_to_gconf
+e_shell_settings_install_property_for_key
 e_shell_settings_enable_debug
 e_shell_settings_get_boolean
 e_shell_settings_set_boolean
diff --git a/doc/reference/shell/tmpl/e-shell-settings.sgml b/doc/reference/shell/tmpl/e-shell-settings.sgml
index edc6af5..40ab707 100644
--- a/doc/reference/shell/tmpl/e-shell-settings.sgml
+++ b/doc/reference/shell/tmpl/e-shell-settings.sgml
@@ -31,12 +31,11 @@ EShellSettings
 @pspec: 
 
 
-<!-- ##### FUNCTION e_shell_settings_bind_to_gconf ##### -->
+<!-- ##### FUNCTION e_shell_settings_install_property_for_key ##### -->
 <para>
 
 </para>
 
- shell_settings: 
 @property_name: 
 @gconf_key: 
 
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index 58ddf10..827e2a9 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -2185,6 +2185,15 @@ intelligent
 @shell: 
 @online_mode: 
 
+<!-- ##### FUNCTION e_shell_settings_bind_to_gconf ##### -->
+<para>
+
+</para>
+
+ shell_settings: 
+ property_name: 
+ gconf_key: 
+
 <!-- ##### FUNCTION e_shell_upgrade_attempt ##### -->
 <para>
 
diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in
index e0895c3..b42a544 100644
--- a/mail/evolution-mail.schemas.in
+++ b/mail/evolution-mail.schemas.in
@@ -47,7 +47,7 @@
 
     <schema>
       <key>/schemas/apps/evolution/mail/composer/magic_smileys</key>
-      <applyto>/apps/evolution/mail/composer/send_smileys</applyto>
+      <applyto>/apps/evolution/mail/composer/magic_smileys</applyto>
       <owner>evolution-mail</owner>
       <type>bool</type>
       <default>false</default>
@@ -60,6 +60,20 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/evolution/mail/composer/reply_start_bottom</key>
+      <applyto>/apps/evolution/mail/composer/reply_start_bottom</applyto>
+      <owner>evolution-mail</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Put the cursor at the bottom of replies</short>
+        <long>Users get all up in arms over where the cursor should go when
+        replying to a message. This determines whether the cursor is placed
+        at the top of the message or the bottom.</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/mail/composer/request_receipt</key>
       <applyto>/apps/evolution/mail/composer/request_receipt</applyto>
       <owner>evolution-mail</owner>
@@ -220,6 +234,20 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/evolution/mail/composer/top_signature</key>
+      <applyto>/apps/evolution/mail/composer/top_signature</applyto>
+      <owner>evolution-mail</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Put personalized signatures at the top of replies</short>
+        <long>Users get all up in arms over where their signature should go
+        when replying to a message. This determines whether the signature is
+        placed at the top of the message or the bottom.</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/mail/composer/width</key>
       <applyto>/apps/evolution/mail/composer/width</applyto>
       <owner>evolution-mail</owner>
@@ -246,6 +274,19 @@
     <!-- Display Settings -->
 
     <schema>
+      <key>/schemas/apps/evolution/mail/display/animated_images</key>
+      <applyto>/apps/evolution/mail/display/animated_images</applyto>
+      <owner>evolution-mail</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Show image animations</short>
+        <long>Enable animated images in HTML mail. Many users find animated
+        images annoying and prefer to see a static image instead.</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/mail/display/side_bar_search</key>
       <applyto>/apps/evolution/mail/display/side_bar_search</applyto>
       <owner>evolution-mail</owner>
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 4e6f871..a688c27 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -626,7 +626,7 @@ cal_shell_content_constructed (GObject *object)
 
 	e_binding_new (
 		G_OBJECT (shell_settings), "cal-use-24-hour-format",
-		G_OBJECT (calendar_view), "use-24-hour-format");
+		G_OBJECT (calendar_model), "use-24-hour-format");
 
 	g_object_unref (memo_model);
 	g_object_unref (task_model);
diff --git a/modules/calendar/e-cal-shell-settings.c b/modules/calendar/e-cal-shell-settings.c
index 0379a65..39581a5 100644
--- a/modules/calendar/e-cal-shell-settings.c
+++ b/modules/calendar/e-cal-shell-settings.c
@@ -30,200 +30,63 @@ e_cal_shell_backend_init_settings (EShell *shell)
 
 	shell_settings = e_shell_get_shell_settings (shell);
 
-	/* XXX Default values should match the GConf schema.
-	 *     Yes it's redundant, but we're stuck with GConf. */
-
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"cal-compress-weekend",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-compress-weekend",
+	e_shell_settings_install_property_for_key (
+		"cal-compress-weekend",
 		"/apps/evolution/calendar/display/compress_weekend");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"cal-marcus-bains-day-view-color",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-marcus-bains-day-view-color",
+	e_shell_settings_install_property_for_key (
+		"cal-marcus-bains-day-view-color",
 		"/apps/evolution/calendar/display/marcus_bains_color_dayview");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"cal-marcus-bains-time-bar-color",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-marcus-bains-time-bar-color",
+	e_shell_settings_install_property_for_key (
+		"cal-marcus-bains-time-bar-color",
 		"/apps/evolution/calendar/display/marcus_bains_color_timebar");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"cal-marcus-bains-show-line",
-			NULL,
-			NULL,
-			TRUE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-marcus-bains-show-line",
+	e_shell_settings_install_property_for_key (
+		"cal-marcus-bains-show-line",
 		"/apps/evolution/calendar/display/marcus_bains_line");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"cal-primary-calendar",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-primary-calendar",
+	e_shell_settings_install_property_for_key (
+		"cal-primary-calendar",
 		"/apps/evolution/calendar/display/primary_calendar");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"cal-show-event-end-times",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-show-event-end-times",
+	e_shell_settings_install_property_for_key (
+		"cal-show-event-end-times",
 		"/apps/evolution/calendar/display/show_event_end");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-time-divisions",
-			NULL,
-			NULL,
-			5,
-			60,
-			30,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-time-divisions",
+	e_shell_settings_install_property_for_key (
+		"cal-time-divisions",
 		"/apps/evolution/calendar/display/time_divisions");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"cal-use-24-hour-format",
-			NULL,
-			NULL,
-			TRUE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-use-24-hour-format",
+	e_shell_settings_install_property_for_key (
+		"cal-use-24-hour-format",
 		"/apps/evolution/calendar/display/use_24hour_format");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"cal-use-system-timezone",
-			NULL,
-			NULL,
-			TRUE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-use-system-timezone",
+	e_shell_settings_install_property_for_key (
+		"cal-use-system-timezone",
 		"/apps/evolution/calendar/display/use_system_timezone");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-week-start-day",
-			NULL,
-			NULL,
-			0,  /* Sunday */
-			6,  /* Saturday */
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-week-start-day",
+	e_shell_settings_install_property_for_key (
+		"cal-week-start-day",
 		"/apps/evolution/calendar/display/week_start_day");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-work-day-end-hour",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-work-day-end-hour",
+	e_shell_settings_install_property_for_key (
+		"cal-work-day-end-hour",
 		"/apps/evolution/calendar/display/day_end_hour");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-work-day-end-minute",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-work-day-end-minute",
+	e_shell_settings_install_property_for_key (
+		"cal-work-day-end-minute",
 		"/apps/evolution/calendar/display/day_end_minute");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-work-day-start-hour",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-work-day-start-hour",
+	e_shell_settings_install_property_for_key (
+		"cal-work-day-start-hour",
 		"/apps/evolution/calendar/display/day_start_hour");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-work-day-start-minute",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-work-day-start-minute",
+	e_shell_settings_install_property_for_key (
+		"cal-work-day-start-minute",
 		"/apps/evolution/calendar/display/day_start_minute");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"cal-working-days",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "cal-working-days",
+	e_shell_settings_install_property_for_key (
+		"cal-working-days",
 		"/apps/evolution/calendar/display/working_days");
 }
diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c
index 827d3bf..907c5fb 100644
--- a/modules/mail/e-mail-shell-settings.c
+++ b/modules/mail/e-mail-shell-settings.c
@@ -36,9 +36,6 @@ e_mail_shell_settings_init (EShell *shell)
 
 	shell_settings = e_shell_get_shell_settings (shell);
 
-	/* XXX Default values should match the GConf schema.
-	 *     Yes it's redundant, but we're stuck with GConf. */
-
 	/*** Global Objects ***/
 
 	e_shell_settings_install_property (
@@ -67,490 +64,166 @@ e_mail_shell_settings_init (EShell *shell)
 
 	/*** Mail Preferences ***/
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-address-compress",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-address-compress",
+	e_shell_settings_install_property_for_key (
+		"mail-address-compress",
 		"/apps/evolution/mail/display/address_compress");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-address-count",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-address-count",
+	e_shell_settings_install_property_for_key (
+		"mail-address-count",
 		"/apps/evolution/mail/display/address_count");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"mail-charset",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-charset",
+	e_shell_settings_install_property_for_key (
+		"mail-charset",
 		"/apps/evolution/mail/display/charset");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-check-for-junk",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-check-for-junk",
+	e_shell_settings_install_property_for_key (
+		"mail-check-for-junk",
 		"/apps/evolution/mail/junk/check_incoming");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"mail-citation-color",
-			NULL,
-			NULL,
-			"#737373",
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-citation-color",
+	e_shell_settings_install_property_for_key (
+		"mail-citation-color",
 		"/apps/evolution/mail/display/citation_colour");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-confirm-expunge",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-confirm-expunge",
+	e_shell_settings_install_property_for_key (
+		"mail-confirm-expunge",
 		"/apps/evolution/mail/prompts/expunge");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-confirm-unwanted-html",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-confirm-unwanted-html",
+	e_shell_settings_install_property_for_key (
+		"mail-confirm-unwanted-html",
 		"/apps/evolution/mail/prompts/unwanted_html");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-empty-junk-on-exit",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-empty-junk-on-exit",
+	e_shell_settings_install_property_for_key (
+		"mail-empty-junk-on-exit",
 		"/apps/evolution/mail/junk/empty_on_exit");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-empty-trash-on-exit",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-empty-trash-on-exit",
+	e_shell_settings_install_property_for_key (
+		"mail-empty-trash-on-exit",
 		"/apps/evolution/mail/trash/empty_on_exit");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-enable-search-folders",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-enable-search-folders",
+	e_shell_settings_install_property_for_key (
+		"mail-enable-search-folders",
 		"/apps/evolution/mail/display/enable_vfolders");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"mail-font-monospace",
-			NULL,
-			NULL,
-			"",
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-font-monospace",
+	e_shell_settings_install_property_for_key (
+		"mail-font-monospace",
 		"/apps/evolution/mail/display/fonts/monospace");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"mail-font-variable",
-			NULL,
-			NULL,
-			"",
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-font-variable",
+	e_shell_settings_install_property_for_key (
+		"mail-font-variable",
 		"/apps/evolution/mail/display/fonts/variable");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-force-message-limit",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-force-message-limit",
+	e_shell_settings_install_property_for_key (
+		"mail-force-message-limit",
 		"/apps/evolution/mail/display/force_message_limit");
 
 	/* This value corresponds to MailConfigForwardStyle enum. */
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-forward-style",
-			NULL,
-			NULL,
-			0,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-forward-style",
+	e_shell_settings_install_property_for_key (
+		"mail-forward-style",
 		"/apps/evolution/mail/format/forward_style");
 
 	/* This value corresponds to MailConfigHTTPMode enum. */
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-image-loading-policy",
-			NULL,
-			NULL,
-			0,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-image-loading-policy",
+	e_shell_settings_install_property_for_key (
+		"mail-image-loading-policy",
 		"/apps/evolution/mail/display/load_http_images");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-magic-spacebar",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-magic-spacebar",
+	e_shell_settings_install_property_for_key (
+		"mail-magic-spacebar",
 		"/apps/evolution/mail/display/magic_spacebar");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-mark-citations",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-mark-citations",
+	e_shell_settings_install_property_for_key (
+		"mail-mark-citations",
 		"/apps/evolution/mail/display/mark_citations");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-mark-seen",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-mark-seen",
+	e_shell_settings_install_property_for_key (
+		"mail-mark-seen",
 		"/apps/evolution/mail/display/mark_seen");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-mark-seen-timeout",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-mark-seen-timeout",
+	e_shell_settings_install_property_for_key (
+		"mail-mark-seen-timeout",
 		"/apps/evolution/mail/display/mark_seen_timeout");
 
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-message-text-part-limit",
-			NULL,
-			NULL,
-			G_MININT,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-message-text-part-limit",
+	e_shell_settings_install_property_for_key (
+		"mail-message-text-part-limit",
 		"/apps/evolution/mail/display/message_text_part_limit");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-only-local-photos",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-only-local-photos",
+	e_shell_settings_install_property_for_key (
+		"mail-only-local-photos",
 		"/apps/evolution/mail/display/photo_local");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-prompt-delete-in-vfolder",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-prompt-delete-in-vfolder",
+	e_shell_settings_install_property_for_key (
+		"mail-prompt-delete-in-vfolder",
 		"/apps/evolution/mail/prompts/delete_in_vfolder");
 
 	/* This value corresponds to MailConfigReplyStyle enum,
 	 * but the ordering of the combo box items in preferences
 	 * has changed.  We use transformation functions there. */
-	e_shell_settings_install_property (
-		g_param_spec_int (
-			"mail-reply-style",
-			NULL,
-			NULL,
-			0,
-			G_MAXINT,
-			0,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-reply-style",
+	e_shell_settings_install_property_for_key (
+		"mail-reply-style",
 		"/apps/evolution/mail/format/reply_style");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-show-animated-images",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-show-animated-images",
+	e_shell_settings_install_property_for_key (
+		"mail-show-animated-images",
 		"/apps/evolution/mail/display/animated_images");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-show-sender-photo",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-show-sender-photo",
+	e_shell_settings_install_property_for_key (
+		"mail-show-sender-photo",
 		"/apps/evolution/mail/display/sender_photo");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-side-bar-search",
-			NULL,
-			NULL,
-			TRUE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-side-bar-search",
+	e_shell_settings_install_property_for_key (
+		"mail-side-bar-search",
 		"/apps/evolution/mail/display/side_bar_search");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"mail-use-custom-fonts",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "mail-use-custom-fonts",
+	e_shell_settings_install_property_for_key (
+		"mail-use-custom-fonts",
 		"/apps/evolution/mail/display/fonts/use_custom");
 
 	/*** Composer Preferences ***/
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"composer-charset",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-charset",
+	e_shell_settings_install_property_for_key (
+		"composer-charset",
 		"/apps/evolution/mail/composer/charset");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-format-html",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-format-html",
+	e_shell_settings_install_property_for_key (
+		"composer-format-html",
 		"/apps/evolution/mail/composer/send_html");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-inline-spelling",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-inline-spelling",
+	e_shell_settings_install_property_for_key (
+		"composer-inline-spelling",
 		"/apps/evolution/mail/composer/inline_spelling");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-magic-links",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-magic-links",
+	e_shell_settings_install_property_for_key (
+		"composer-magic-links",
 		"/apps/evolution/mail/composer/magic_links");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-magic-smileys",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-magic-smileys",
+	e_shell_settings_install_property_for_key (
+		"composer-magic-smileys",
 		"/apps/evolution/mail/composer/magic_smileys");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-outlook-filenames",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-outlook-filenames",
+	e_shell_settings_install_property_for_key (
+		"composer-outlook-filenames",
 		"/apps/evolution/mail/composer/outlook_filenames");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-prompt-only-bcc",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-prompt-only-bcc",
+	e_shell_settings_install_property_for_key (
+		"composer-prompt-only-bcc",
 		"/apps/evolution/mail/prompts/only_bcc");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-prompt-empty-subject",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-prompt-empty-subject",
+	e_shell_settings_install_property_for_key (
+		"composer-prompt-empty-subject",
 		"/apps/evolution/mail/prompts/empty_subject");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-reply-start-bottom",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-reply-start-bottom",
+	e_shell_settings_install_property_for_key (
+		"composer-reply-start-bottom",
 		"/apps/evolution/mail/composer/reply_start_bottom");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-request-receipt",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-request-receipt",
+	e_shell_settings_install_property_for_key (
+		"composer-request-receipt",
 		"/apps/evolution/mail/composer/request_receipt");
 
-	e_shell_settings_install_property (
-		g_param_spec_string (
-			"composer-spell-color",
-			NULL,
-			NULL,
-			"#ff0000",
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-spell-color",
+	e_shell_settings_install_property_for_key (
+		"composer-spell-color",
 		"/apps/evolution/mail/composer/spell_color");
 
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"composer-top-signature",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_bind_to_gconf (
-		shell_settings, "composer-top-signature",
+	e_shell_settings_install_property_for_key (
+		"composer-top-signature",
 		"/apps/evolution/mail/composer/top_signature");
 }
diff --git a/shell/e-shell-settings.c b/shell/e-shell-settings.c
index 0883382..21cc855 100644
--- a/shell/e-shell-settings.c
+++ b/shell/e-shell-settings.c
@@ -36,6 +36,131 @@ static GList *instances;
 static guint property_count;
 static gpointer parent_class;
 
+static GParamSpec *
+shell_settings_pspec_for_key (const gchar *property_name,
+                              const gchar *gconf_key)
+{
+	GConfClient *client;
+	GConfEntry *entry;
+	GConfSchema *schema;
+	GConfValue *default_value;
+	GConfValueType value_type;
+	GParamSpec *pspec;
+	const gchar *bad_type;
+	const gchar *schema_name;
+	GError *error = NULL;
+
+	client = gconf_client_get_default ();
+
+	entry = gconf_client_get_entry (client, gconf_key, NULL, TRUE, &error);
+	if (error != NULL) {
+		g_error ("%s", error->message);
+		g_assert_not_reached ();
+	}
+
+	schema_name = gconf_entry_get_schema_name (entry);
+	if (schema_name == NULL) {
+		g_error ("No schema for GConf key '%s'", gconf_key);
+		g_assert_not_reached ();
+	}
+
+	schema = gconf_client_get_schema (client, schema_name, &error);
+	if (error != NULL) {
+		g_error ("%s", error->message);
+		g_assert_not_reached ();
+	}
+
+	value_type = gconf_schema_get_type (schema);
+	default_value = gconf_schema_get_default_value (schema);
+
+	/* If the schema does not specify a default value, make one up. */
+	if (default_value == NULL) {
+		default_value = gconf_value_new (value_type);
+
+		/* XXX This should NOT be necessary, but the GConfValue
+		 *     documentation claims it is.  Bother. */
+		switch (value_type) {
+			case GCONF_VALUE_STRING:
+				gconf_value_set_string (default_value, "");
+				break;
+
+			case GCONF_VALUE_INT:
+				gconf_value_set_int (default_value, 0);
+				break;
+
+			case GCONF_VALUE_FLOAT:
+				gconf_value_set_float (default_value, 0.0);
+				break;
+
+			case GCONF_VALUE_BOOL:
+				gconf_value_set_bool (default_value, FALSE);
+				break;
+
+			default:
+				/* We'll fail in the next switch statement. */
+				break;
+		}
+	}
+
+	switch (value_type) {
+		case GCONF_VALUE_STRING:
+			pspec = g_param_spec_string (
+				property_name, NULL, NULL,
+				gconf_value_get_string (default_value),
+				G_PARAM_READWRITE);
+			break;
+
+		case GCONF_VALUE_INT:
+			pspec = g_param_spec_int (
+				property_name, NULL, NULL,
+				G_MININT, G_MAXINT,
+				gconf_value_get_int (default_value),
+				G_PARAM_READWRITE);
+			break;
+
+		case GCONF_VALUE_FLOAT:
+			pspec = g_param_spec_double (
+				property_name, NULL, NULL,
+				-G_MAXDOUBLE, G_MAXDOUBLE,
+				gconf_value_get_float (default_value),
+				G_PARAM_READWRITE);
+			break;
+
+		case GCONF_VALUE_BOOL:
+			pspec = g_param_spec_boolean (
+				property_name, NULL, NULL,
+				gconf_value_get_bool (default_value),
+				G_PARAM_READWRITE);
+			break;
+
+		case GCONF_VALUE_SCHEMA:
+			bad_type = "schema";
+			goto fail;
+
+		case GCONF_VALUE_LIST:
+			bad_type = "list";
+			goto fail;
+
+		case GCONF_VALUE_PAIR:
+			bad_type = "pair";
+			goto fail;
+
+		default:
+			bad_type = "invalid";
+			goto fail;
+	}
+
+	gconf_value_free (default_value);
+
+	return pspec;
+
+fail:
+	g_error (
+		"Unable to create EShellSettings property for "
+		"GConf key '%s' of type '%s'", gconf_key, bad_type);
+	g_assert_not_reached ();
+}
+
 static void
 shell_settings_set_property (GObject *object,
                              guint property_id,
@@ -139,6 +264,9 @@ shell_settings_init (EShellSettings *shell_settings,
 		g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
 		g_param_value_set_default (pspec, value);
 		g_object_notify (G_OBJECT (shell_settings), pspec->name);
+
+		/* FIXME Need to bind those properties that have
+		 *       associated GConf keys. */
 	}
 	g_free (pspecs);
 
@@ -175,10 +303,9 @@ e_shell_settings_get_type (void)
  * e_shell_settings_install_property:
  * @pspec: a #GParamSpec
  *
- * Installs a new class property for #EShellSettings.  This is usually
- * done during initialization of a #EShellBackend or plugin, followed by
- * a call to e_shell_settings_bind_to_gconf() to bind the property to a
- * GConf key.
+ * Installs a new #EShellSettings class property from @pspec.
+ * This is usually done during initialization of an #EShellBackend
+ * or other dynamically loaded entity.
  **/
 void
 e_shell_settings_install_property (GParamSpec *pspec)
@@ -204,10 +331,11 @@ e_shell_settings_install_property (GParamSpec *pspec)
 	g_object_class_install_property (class, ++property_count, pspec);
 
 	for (iter = instances; iter != NULL; iter = iter->next) {
-		EShellSettings *shell_settings = iter->data;
+		EShellSettings *shell_settings;
 		GArray *value_array;
 		GValue *value;
 
+		shell_settings = E_SHELL_SETTINGS (iter->data);
 		value_array = shell_settings->priv->value_array;
 		g_array_set_size (value_array, property_count);
 
@@ -225,34 +353,49 @@ e_shell_settings_install_property (GParamSpec *pspec)
 }
 
 /**
- * e_shell_settings_bind_to_gconf:
- * @shell_settings: an #EShellSettings
- * @property_name: the name of the property to bind
+ * e_shell_settings_install_property_for_key:
+ * @property_name: the name of the property to install
  * @gconf_key: the GConf key to bind the property to
  *
- * Binds @property_name to @gconf_key, causing them to have the same value
- * at all times.
+ * Installs a new #EShellSettings class property by examining the
+ * GConf schema for @gconf_key to determine the appropriate type and
+ * default value.  This is usually done during initialization of an
+ * #EShellBackend of other dynamically loaded entity.
  *
- * The types of @property_name and @gconf_key should be compatible.  Floats
- * and doubles, and ints, uints, longs, unlongs, int64s, uint64s, chars,
- * uchars and enums can be matched up.  Booleans and strings can only be
- * matched to their respective types.
- *
- * On calling this function, @property_name is initialized to the current
- * value of @gconf_key.
+ * After the class property is installed, all #EShellSettings instances
+ * are bound to @gconf_key, causing @property_name and @gconf_key to have
+ * the same value at all times.
  **/
 void
-e_shell_settings_bind_to_gconf (EShellSettings *shell_settings,
-                                const gchar *property_name,
-                                const gchar *gconf_key)
+e_shell_settings_install_property_for_key (const gchar *property_name,
+                                           const gchar *gconf_key)
 {
-	g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+	GParamSpec *pspec;
+	GList *iter, *next;
+
 	g_return_if_fail (property_name != NULL);
 	g_return_if_fail (gconf_key != NULL);
 
-	gconf_bridge_bind_property (
-		gconf_bridge_get (), gconf_key,
-		G_OBJECT (shell_settings), property_name);
+	pspec = shell_settings_pspec_for_key (property_name, gconf_key);
+	e_shell_settings_install_property (pspec);
+
+	for (iter = instances; iter != NULL; iter = iter->next)
+		g_object_freeze_notify (iter->data);
+
+	for (iter = instances; iter != NULL; iter = iter->next) {
+		EShellSettings *shell_settings;
+
+		shell_settings = E_SHELL_SETTINGS (iter->data);
+
+		gconf_bridge_bind_property (
+			gconf_bridge_get (), gconf_key,
+			G_OBJECT (shell_settings), property_name);
+	}
+
+	for (iter = instances; iter != NULL; iter = next) {
+		next = iter->next;
+		g_object_thaw_notify (iter->data);
+	}
 }
 
 /**
diff --git a/shell/e-shell-settings.h b/shell/e-shell-settings.h
index c56df44..c1ac497 100644
--- a/shell/e-shell-settings.h
+++ b/shell/e-shell-settings.h
@@ -73,8 +73,8 @@ struct _EShellSettingsClass {
 GType		e_shell_settings_get_type	(void);
 void		e_shell_settings_install_property
 						(GParamSpec *pspec);
-void		e_shell_settings_bind_to_gconf	(EShellSettings *shell_settings,
-						 const gchar *property_name,
+void		e_shell_settings_install_property_for_key
+						(const gchar *property_name,
 						 const gchar *gconf_key);
 void		e_shell_settings_enable_debug	(EShellSettings *shell_settings);
 
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 9ac85e9..5b1e3be 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -924,46 +924,6 @@ shell_class_init (EShellClass *class)
 	/* Install some application-wide settings. */
 
 	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"disable-application-handlers",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"disable-command-line",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"disable-printing",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"disable-print-setup",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_install_property (
-		g_param_spec_boolean (
-			"disable-save-to-disk",
-			NULL,
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	e_shell_settings_install_property (
 		g_param_spec_string (
 			"file-chooser-folder",
 			NULL,
@@ -1003,24 +963,27 @@ shell_init (EShell *shell)
 		shell, "notify::online",
 		G_CALLBACK (shell_notify_online_cb), NULL);
 
-	e_shell_settings_bind_to_gconf (
-		shell->priv->settings, "disable-application-handlers",
+	/* XXX Do this after creating the EShellSettings instance,
+	 *     otherwise the GConf bindings will not get set up. */
+
+	e_shell_settings_install_property_for_key (
+		"disable-application-handlers",
 		"/desktop/gnome/lockdown/disable_application_handlers");
 
-	e_shell_settings_bind_to_gconf (
-		shell->priv->settings, "disable-command-line",
+	e_shell_settings_install_property_for_key (
+		"disable-command-line",
 		"/desktop/gnome/lockdown/disable_command_line");
 
-	e_shell_settings_bind_to_gconf (
-		shell->priv->settings, "disable-printing",
+	e_shell_settings_install_property_for_key (
+		"disable-printing",
 		"/desktop/gnome/lockdown/disable_printing");
 
-	e_shell_settings_bind_to_gconf (
-		shell->priv->settings, "disable-print-setup",
+	e_shell_settings_install_property_for_key (
+		"disable-print-setup",
 		"/desktop/gnome/lockdown/disable_print_setup");
 
-	e_shell_settings_bind_to_gconf (
-		shell->priv->settings, "disable-save-to-disk",
+	e_shell_settings_install_property_for_key (
+		"disable-save-to-disk",
 		"/desktop/gnome/lockdown/disable_save_to_disk");
 
 	/*** Session Management ***/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]