From 0ae8e9e7b7c224915f474a4e635a8ccecd476c40 Mon Sep 17 00:00:00 2001
From: Matthew Barnes <mbarnes@redhat.com>
Date: Wed, 8 Aug 2012 10:04:20 -0400
Subject: Return of the "mark messages as read" preference.

This reverses the removal of the "Mark messages as read" preference in
commit e7247d6d60336861ed5c0ba05dd64e29f728349c.

I apparently misjudged the popularity of this preference, as there's
been a surprising amout of backlash and confusion as to its removal on
the mailing list, IRC channel, and various distro-support forums.

So, "mea culpa" for removing that one.  Haven't heard a peep about the
other removed preferences, however, so they will stay gone.
---
 mail/mail-config.ui            | 62 +++++++++++++++++++++++++++++++++++++++---
 modules/mail/em-mailer-prefs.c | 56 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 4 deletions(-)

diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 224f659487..00a47c2736 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -1819,6 +1819,60 @@
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkHBox" id="hboxReadTimeout">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkCheckButton" id="chkMarkTimeout">
+                            <property name="label" translatable="yes">_Mark messages as read after</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSpinButton" id="spinMarkTimeout">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="adjustment">adjustment1</property>
+                            <property name="climb_rate">1</property>
+                            <property name="digits">1</property>
+                            <property name="numeric">True</property>
+                            <property name="update_policy">if-valid</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="lblSeconds">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">seconds</property>
+                            <property name="justify">center</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkHBox" id="hboxHighlightColor">
                         <property name="visible">True</property>
@@ -1873,7 +1927,7 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                     <child>
@@ -1902,7 +1956,7 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">3</property>
+                        <property name="position">4</property>
                       </packing>
                     </child>
                     <child>
@@ -1918,7 +1972,7 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">4</property>
+                        <property name="position">5</property>
                       </packing>
                     </child>
                     <child>
@@ -1934,7 +1988,7 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">5</property>
+                        <property name="position">6</property>
                       </packing>
                     </child>
                   </object>
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index b2381b2cf2..1877e28624 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -121,6 +121,38 @@ em_mailer_prefs_init (EMMailerPrefs *preferences)
 	preferences->settings = g_settings_new ("org.gnome.evolution.mail");
 }
 
+static gboolean
+mark_seen_milliseconds_to_seconds (GBinding *binding,
+                                   const GValue *source_value,
+                                   GValue *target_value,
+                                   gpointer user_data)
+{
+	gint milliseconds;
+	gdouble seconds;
+
+	milliseconds = g_value_get_int (source_value);
+	seconds = milliseconds / 1000.0;
+	g_value_set_double (target_value, seconds);
+
+	return TRUE;
+}
+
+static gboolean
+mark_seen_seconds_to_milliseconds (GBinding *binding,
+                                   const GValue *source_value,
+                                   GValue *target_value,
+                                   gpointer user_data)
+{
+	gint milliseconds;
+	gdouble seconds;
+
+	seconds = g_value_get_double (source_value);
+	milliseconds = seconds * 1000;
+	g_value_set_int (target_value, milliseconds);
+
+	return TRUE;
+}
+
 enum {
 	JH_LIST_COLUMN_NAME,
 	JH_LIST_COLUMN_VALUE
@@ -768,6 +800,30 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
 
 	/* Message Display */
 
+	widget = e_builder_get_widget (prefs->builder, "chkMarkTimeout");
+	g_object_bind_property (
+		shell_settings, "mail-mark-seen",
+		widget, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* The "mark seen" timeout requires special transform functions
+	 * because we display the timeout value to the user in seconds
+	 * but store the settings value in milliseconds. */
+	widget = e_builder_get_widget (prefs->builder, "spinMarkTimeout");
+	g_object_bind_property (
+		shell_settings, "mail-mark-seen",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE);
+	g_object_bind_property_full (
+		shell_settings, "mail-mark-seen-timeout",
+		widget, "value",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		mark_seen_milliseconds_to_seconds,
+		mark_seen_seconds_to_milliseconds,
+		NULL, (GDestroyNotify) NULL);
+
 	widget = e_builder_get_widget (prefs->builder, "view-check");
 	g_object_bind_property (
 		shell_settings, "mail-global-view-setting",
-- 
cgit v1.2.3