aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-03-13 01:22:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-03-13 01:22:17 +0800
commitc3cd3697c5dd8cd03037a76f01f5ade79c3e79ab (patch)
tree03ac14547051490a35d15a9ca73a5efeeac5e1ae /mail
parenta9bdc7c5dccb80c2c9ca1c5b4a03f6988c7d863e (diff)
downloadgsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar.gz
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar.bz2
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar.lz
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar.xz
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.tar.zst
gsoc2013-evolution-c3cd3697c5dd8cd03037a76f01f5ade79c3e79ab.zip
BugĀ 612619 - Don't mark message as read after folder change
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 9fa6ea0f69..ad60195b58 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -68,6 +68,13 @@ struct _EMailReaderPrivate {
/* This is the ID of an asynchronous operation
* to retrieve a message from a mail folder. */
gint retrieving_message_operation_id;
+
+ /* These flags work together to prevent message selection
+ * restoration after a folder switch from automatically
+ * marking the message as read. We only want that to
+ * happen when the -user- selects a message. */
+ guint folder_was_just_selected : 1;
+ guint restoring_message_selection : 1;
};
enum {
@@ -1818,7 +1825,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
EMEvent *event;
EMEventTargetMessage *target;
const gchar *cursor_uid;
- gboolean mark_read;
+ gboolean schedule_timeout;
gint timeout_interval;
priv = E_MAIL_READER_GET_PRIVATE (reader);
@@ -1835,7 +1842,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
/* If the user picked a different message in the time it took
* to fetch this message, then don't bother rendering it. */
if (g_strcmp0 (cursor_uid, message_uid) != 0)
- return;
+ goto exit;
/** @Event: message.reading
* @Title: Viewing a message
@@ -1857,20 +1864,25 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail");
/* Determine whether to mark the message as read. */
- mark_read = e_shell_settings_get_boolean (
- shell_settings, "mail-mark-seen");
- timeout_interval = e_shell_settings_get_int (
+ schedule_timeout =
+ (message != NULL) &&
+ e_shell_settings_get_boolean (
+ shell_settings, "mail-mark-seen") &&
+ !priv->restoring_message_selection;
+ timeout_interval =
+ e_shell_settings_get_int (
shell_settings, "mail-mark-seen-timeout");
g_free (priv->mark_read_message_uid);
- priv->mark_read_message_uid = g_strdup (message_uid);
+ priv->mark_read_message_uid = NULL;
if (MESSAGE_LIST (message_list)->seen_id > 0) {
g_source_remove (MESSAGE_LIST (message_list)->seen_id);
MESSAGE_LIST (message_list)->seen_id = 0;
}
- if (message != NULL && mark_read) {
+ if (schedule_timeout) {
+ priv->mark_read_message_uid = g_strdup (message_uid);
MESSAGE_LIST (message_list)->seen_id = g_timeout_add (
timeout_interval, (GSourceFunc)
mail_reader_message_read_cb, reader);
@@ -1896,6 +1908,9 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
/* We referenced this in the call to mail_get_messagex(). */
g_object_unref (reader);
+
+exit:
+ priv->restoring_message_selection = FALSE;
}
static gboolean
@@ -1959,8 +1974,10 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
if (!store_async)
priv->retrieving_message_operation_id = op_id;
}
- } else
+ } else {
em_format_format (EM_FORMAT (html_display), NULL, NULL, NULL);
+ priv->restoring_message_selection = FALSE;
+ }
priv->message_selected_timeout_id = 0;
@@ -1975,7 +1992,6 @@ mail_reader_message_selected_cb (EMailReader *reader,
MessageList *message_list;
gboolean store_async;
CamelFolder *folder;
- guint source_id;
priv = E_MAIL_READER_GET_PRIVATE (reader);
@@ -1999,11 +2015,21 @@ mail_reader_message_selected_cb (EMailReader *reader,
priv->message_selected_timeout_id = 0;
}
- source_id = g_timeout_add (
- 100, (GSourceFunc)
- mail_reader_message_selected_timeout_cb, reader);
-
- priv->message_selected_timeout_id = source_id;
+ /* If a folder was just selected then we are now automatically
+ * restoring the previous message selection. We behave slightly
+ * differently than if the user had selected the message. */
+ priv->restoring_message_selection = priv->folder_was_just_selected;
+ priv->folder_was_just_selected = FALSE;
+
+ /* Skip the timeout if we're restoring the previous message
+ * selection. The timeout is there for when we're scrolling
+ * rapidly through the message list. */
+ if (priv->restoring_message_selection)
+ mail_reader_message_selected_timeout_cb (reader);
+ else
+ priv->message_selected_timeout_id = g_timeout_add (
+ 100, (GSourceFunc)
+ mail_reader_message_selected_timeout_cb, reader);
e_mail_reader_changed (reader);
}
@@ -2049,12 +2075,15 @@ mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder,
const gchar *folder_uri)
{
+ EMailReaderPrivate *priv;
EMFormatHTMLDisplay *html_display;
CamelFolder *previous_folder;
GtkWidget *message_list;
const gchar *previous_folder_uri;
gboolean outgoing;
+ priv = E_MAIL_READER_GET_PRIVATE (reader);
+
html_display = e_mail_reader_get_html_display (reader);
message_list = e_mail_reader_get_message_list (reader);
@@ -2075,6 +2104,8 @@ mail_reader_set_folder (EMailReader *reader,
em_format_format (EM_FORMAT (html_display), NULL, NULL, NULL);
+ priv->folder_was_just_selected = (folder != NULL);
+
message_list_set_folder (
MESSAGE_LIST (message_list), folder, folder_uri, outgoing);