aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-10-24 17:30:20 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-10-24 17:30:20 +0800
commitbd149b27954af20cf3f860164486191b0e879e89 (patch)
tree323c26ba15a7e15242c2749b391b5ffa59762fed /mail
parent3b32549c69267295a9a7b482e4a6ca2db9e6c73f (diff)
parent8c67e84f9bf1803108f7a004513e37c6ef22d41f (diff)
downloadgsoc2013-evolution-bd149b27954af20cf3f860164486191b0e879e89.tar.gz
gsoc2013-evolution-bd149b27954af20cf3f860164486191b0e879e89.tar.zst
gsoc2013-evolution-bd149b27954af20cf3f860164486191b0e879e89.zip
Merge branch 'master' into wip/gsettings
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-backend.c15
-rw-r--r--mail/e-mail-reader.c105
2 files changed, 87 insertions, 33 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index cb91339503..be2f94eeb9 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -544,7 +544,6 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
const gchar *msg_subject,
EMailBackend *mail_backend)
{
- CamelFolder *folder = NULL;
EMEvent *event = em_event_peek ();
EMEventTargetFolder *target;
EMFolderTreeModel *model;
@@ -554,11 +553,15 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
folder_uri = e_mail_folder_uri_build (store, folder_name);
- if (mail_folder_cache_get_folder_from_uri (
- folder_cache, folder_uri, &folder))
- if (folder && !mail_folder_cache_get_folder_info_flags (
- folder_cache, folder, &flags))
- g_return_if_reached ();
+ if (folder_uri) {
+ CamelFolder *folder = NULL;
+
+ if (mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
+ if (folder && !mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags))
+ g_return_if_reached ();
+ if (folder)
+ g_object_unref (folder);
+ }
g_free (folder_uri);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 820fadfb4e..2fbd04c5c6 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -45,6 +45,7 @@
#include "mail/e-mail-display.h"
#include "mail/e-mail-enumtypes.h"
#include "mail/e-mail-reader-utils.h"
+#include "mail/e-mail-view.h"
#include "mail/em-composer-utils.h"
#include "mail/em-event.h"
#include "mail/em-folder-selector.h"
@@ -2484,6 +2485,58 @@ mail_reader_message_read_cb (EMailReaderClosure *closure)
return FALSE;
}
+static gboolean
+schedule_timeout_mark_seen (EMailReader *reader)
+{
+ EShell *shell;
+ EMailBackend *backend;
+ EShellBackend *shell_backend;
+ EShellSettings *shell_settings;
+ MessageList *message_list;
+ gboolean schedule_timeout;
+ gint timeout_interval;
+ const gchar *message_uid;
+
+ backend = e_mail_reader_get_backend (reader);
+ message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ message_uid = message_list->cursor_uid;
+ if (!message_uid)
+ return FALSE;
+
+ schedule_timeout =
+ (message_uid != NULL) &&
+ e_shell_settings_get_boolean (
+ shell_settings, "mail-mark-seen");
+ timeout_interval =
+ e_shell_settings_get_int (
+ shell_settings, "mail-mark-seen-timeout");
+
+ if (message_list->seen_id > 0) {
+ g_source_remove (message_list->seen_id);
+ 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 = g_timeout_add_full (
+ G_PRIORITY_DEFAULT, timeout_interval,
+ (GSourceFunc) mail_reader_message_read_cb,
+ timeout_closure, (GDestroyNotify)
+ mail_reader_closure_free);
+ }
+
+ return schedule_timeout;
+}
+
static void
mail_reader_message_loaded_cb (CamelFolder *folder,
GAsyncResult *result,
@@ -2496,14 +2549,11 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
GtkWidget *message_list;
EMailBackend *backend;
EShellBackend *shell_backend;
- EShellSettings *shell_settings;
EShell *shell;
EWebView *web_view;
EMEvent *event;
EMEventTargetMessage *target;
const gchar *message_uid;
- gboolean schedule_timeout;
- gint timeout_interval;
GError *error = NULL;
reader = closure->reader;
@@ -2540,7 +2590,6 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
web_view = em_format_html_get_web_view (formatter);
@@ -2565,34 +2614,16 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
/* Reset the shell view icon. */
e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail");
- /* Determine whether to mark the message as read. */
- 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");
-
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 (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 = g_timeout_add_full (
- G_PRIORITY_DEFAULT, timeout_interval,
- (GSourceFunc) mail_reader_message_read_cb,
- timeout_closure, (GDestroyNotify)
- mail_reader_closure_free);
-
+ /* Determine whether to mark the message as read. */
+ if (message != NULL &&
+ !priv->restoring_message_selection &&
+ schedule_timeout_mark_seen (reader)) {
+ g_clear_error (&error);
} else if (error != NULL) {
e_alert_submit (
E_ALERT_SINK (web_view),
@@ -2735,6 +2766,22 @@ mail_reader_message_selected_cb (EMailReader *reader,
}
static void
+mail_reader_message_cursor_change_cb (EMailReader *reader)
+{
+ MessageList *message_list;
+
+ g_return_if_fail (reader != NULL);
+
+ message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
+ g_return_if_fail (message_list != NULL);
+
+ if (!message_list->seen_id &&
+ E_IS_MAIL_VIEW (reader) &&
+ e_mail_view_get_preview_visible (E_MAIL_VIEW (reader)))
+ schedule_timeout_mark_seen (reader);
+}
+
+static void
mail_reader_emit_folder_loaded (EMailReader *reader)
{
g_signal_emit (reader, signals[FOLDER_LOADED], 0);
@@ -3615,6 +3662,10 @@ connect_signals:
G_CALLBACK (mail_reader_message_selected_cb), reader);
g_signal_connect_swapped (
+ message_list, "cursor-change",
+ G_CALLBACK (mail_reader_message_cursor_change_cb), reader);
+
+ g_signal_connect_swapped (
message_list, "message-list-built",
G_CALLBACK (mail_reader_emit_folder_loaded), reader);