aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-01-24 04:30:38 +0800
committerMilan Crha <mcrha@redhat.com>2014-01-24 04:30:38 +0800
commit51cafd4067f700d1946bb6f68318127595f4a648 (patch)
tree76ff6b5b305f3e200a41947c2613ed61d91d6bb0
parent29a6e2542ce06cf2efb64092263b25c61f924a7a (diff)
downloadgsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar.gz
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar.bz2
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar.lz
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar.xz
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.tar.zst
gsoc2013-evolution-51cafd4067f700d1946bb6f68318127595f4a648.zip
Bug #583773 - Does not always mark mails as read automatically
-rw-r--r--mail/e-mail-reader.c88
1 files changed, 71 insertions, 17 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index bef1aa99cc..ba739703b3 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -90,6 +90,11 @@ struct _EMailReaderPrivate {
guint avoid_next_mark_as_seen : 1;
guint group_by_threads : 1;
+
+ /* to be able to start the mark_seen timeout only after
+ the message is loaded into the EMailDisplay */
+ gboolean schedule_mark_seen;
+ guint schedule_mark_seen_interval;
};
enum {
@@ -2591,9 +2596,61 @@ mail_reader_message_seen_cb (gpointer user_data)
return FALSE;
}
-static gboolean
+static void
schedule_timeout_mark_seen (EMailReader *reader)
{
+ EMailReaderPrivate *priv;
+ MessageList *message_list;
+
+ g_return_if_fail (E_IS_MAIL_READER (reader));
+
+ priv = E_MAIL_READER_GET_PRIVATE (reader);
+
+ message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
+ g_return_if_fail (message_list != NULL);
+
+ if (message_list->cursor_uid) {
+ EMailReaderClosure *timeout_closure;
+
+ if (message_list->seen_id > 0) {
+ g_source_remove (message_list->seen_id);
+ message_list->seen_id = 0;
+ }
+
+ timeout_closure = g_slice_new0 (EMailReaderClosure);
+ timeout_closure->reader = g_object_ref (reader);
+ timeout_closure->message_uid = g_strdup (message_list->cursor_uid);
+
+ MESSAGE_LIST (message_list)->seen_id =
+ e_named_timeout_add_full (
+ G_PRIORITY_DEFAULT, priv->schedule_mark_seen_interval,
+ mail_reader_message_seen_cb,
+ timeout_closure, (GDestroyNotify)
+ mail_reader_closure_free);
+ }
+}
+
+static void
+mail_reader_load_status_changed_cb (EMailReader *reader,
+ GParamSpec *pspec,
+ EMailDisplay *display)
+{
+ EMailReaderPrivate *priv;
+
+ if (webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (display)) != WEBKIT_LOAD_FINISHED)
+ return;
+
+ priv = E_MAIL_READER_GET_PRIVATE (reader);
+ if (priv->schedule_mark_seen &&
+ e_mail_display_get_part_list (display) &&
+ e_mail_view_get_preview_visible (E_MAIL_VIEW (reader)))
+ schedule_timeout_mark_seen (reader);
+}
+
+static gboolean
+maybe_schedule_timeout_mark_seen (EMailReader *reader)
+{
+ EMailReaderPrivate *priv;
MessageList *message_list;
GSettings *settings;
gboolean schedule_timeout;
@@ -2622,20 +2679,9 @@ schedule_timeout_mark_seen (EMailReader *reader)
message_list->seen_id = 0;
}
- if (schedule_timeout) {
- EMailReaderClosure *timeout_closure;
-
- timeout_closure = g_slice_new0 (EMailReaderClosure);
- timeout_closure->reader = g_object_ref (reader);
- timeout_closure->message_uid = g_strdup (message_uid);
-
- MESSAGE_LIST (message_list)->seen_id =
- e_named_timeout_add_full (
- G_PRIORITY_DEFAULT, timeout_interval,
- mail_reader_message_seen_cb,
- timeout_closure, (GDestroyNotify)
- mail_reader_closure_free);
- }
+ priv = E_MAIL_READER_GET_PRIVATE (reader);
+ priv->schedule_mark_seen = schedule_timeout;
+ priv->schedule_mark_seen_interval = timeout_interval;
return schedule_timeout;
}
@@ -2643,10 +2689,14 @@ schedule_timeout_mark_seen (EMailReader *reader)
static gboolean
discard_timeout_mark_seen_cb (EMailReader *reader)
{
+ EMailReaderPrivate *priv;
MessageList *message_list;
g_return_val_if_fail (reader != NULL, FALSE);
+ priv = E_MAIL_READER_GET_PRIVATE (reader);
+ priv->schedule_mark_seen = FALSE;
+
message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
g_return_val_if_fail (message_list != NULL, FALSE);
@@ -2879,7 +2929,7 @@ mail_reader_message_cursor_change_cb (EMailReader *reader)
E_IS_MAIL_VIEW (reader) &&
e_mail_view_get_preview_visible (E_MAIL_VIEW (reader)) &&
!priv->avoid_next_mark_as_seen)
- schedule_timeout_mark_seen (reader);
+ maybe_schedule_timeout_mark_seen (reader);
}
static void
@@ -3104,7 +3154,7 @@ mail_reader_message_loaded (EMailReader *reader,
if (message != NULL &&
!priv->restoring_message_selection &&
!priv->avoid_next_mark_as_seen &&
- schedule_timeout_mark_seen (reader)) {
+ maybe_schedule_timeout_mark_seen (reader)) {
g_clear_error (&error);
} else if (error != NULL) {
e_alert_submit (
@@ -3895,6 +3945,10 @@ connect_signals:
G_CALLBACK (mail_reader_key_press_event_cb), reader);
g_signal_connect_swapped (
+ display, "notify::load-status",
+ G_CALLBACK (mail_reader_load_status_changed_cb), reader);
+
+ g_signal_connect_swapped (
message_list, "message-selected",
G_CALLBACK (mail_reader_message_selected_cb), reader);