aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader.c31
-rw-r--r--mail/e-mail-shell-module.c5
-rw-r--r--mail/e-mail-shell-view-actions.c140
-rw-r--r--mail/e-mail-shell-view-actions.h4
-rw-r--r--mail/e-mail-shell-view-private.c53
-rw-r--r--mail/em-folder-browser.c56
-rw-r--r--mail/em-utils.c6
-rw-r--r--mail/mail-send-recv.c20
-rw-r--r--mail/mail-send-recv.h8
-rw-r--r--mail/mail-session.h11
10 files changed, 248 insertions, 86 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 196f2f0323..dd8e24bd55 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1658,20 +1658,17 @@ mail_reader_double_click_cb (EMailReader *reader,
e_mail_reader_activate (reader, "mail-message-open");
}
-static gint
-mail_reader_key_press_cb (EMailReader *reader,
- gint row,
- ETreePath path,
- gint col,
- GdkEvent *event)
+static gboolean
+mail_reader_key_press_event_cb (EMailReader *reader,
+ GdkEventKey *event)
{
const gchar *action_name;
- if ((event->key.state & GDK_CONTROL_MASK) != 0)
+ if ((event->state & GDK_CONTROL_MASK) != 0)
goto ctrl;
/* <keyval> alone */
- switch (event->key.keyval) {
+ switch (event->keyval) {
case GDK_Delete:
case GDK_KP_Delete:
action_name = "mail-delete";
@@ -1714,7 +1711,7 @@ mail_reader_key_press_cb (EMailReader *reader,
ctrl:
/* Ctrl + <keyval> */
- switch (event->key.keyval) {
+ switch (event->keyval) {
case GDK_period:
action_name = "mail-next-unread";
break;
@@ -1733,6 +1730,16 @@ exit:
return TRUE;
}
+static gint
+mail_reader_key_press_cb (EMailReader *reader,
+ gint row,
+ ETreePath path,
+ gint col,
+ GdkEvent *event)
+{
+ return mail_reader_key_press_event_cb (reader, &event->key);
+}
+
static gboolean
mail_reader_message_read_cb (EMailReader *reader)
{
@@ -2137,10 +2144,14 @@ e_mail_reader_init (EMailReader *reader)
/* Connect signals. */
g_signal_connect_swapped (
- EM_FORMAT_HTML (html_display)->html, "button-release-event",
+ html, "button-release-event",
G_CALLBACK (mail_reader_html_button_release_event_cb), reader);
g_signal_connect_swapped (
+ html, "key-press-event",
+ G_CALLBACK (mail_reader_key_press_event_cb), reader);
+
+ g_signal_connect_swapped (
message_list, "message-selected",
G_CALLBACK (mail_reader_message_selected_cb), reader);
diff --git a/mail/e-mail-shell-module.c b/mail/e-mail-shell-module.c
index 9f5eafc0a5..35bde6fed5 100644
--- a/mail/e-mail-shell-module.c
+++ b/mail/e-mail-shell-module.c
@@ -110,7 +110,8 @@ static struct {
};
/* XXX So many things need the shell module that it's
- * just easier to make it globally available. */
+ * just easier for now to make it globally available.
+ * We should fix this, though. */
EShellModule *mail_shell_module = NULL;
static GHashTable *store_hash;
@@ -846,7 +847,7 @@ mail_shell_module_start (EShellModule *shell_module)
if (enable_search_folders)
vfolder_load_storage ();
- mail_autoreceive_init (session);
+ mail_autoreceive_init (shell_module, session);
if (g_getenv ("CAMEL_FLUSH_CHANGES") != NULL)
mail_sync_timeout_source_id = g_timeout_add_seconds (
diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c
index 08c5882a5b..f9235a6104 100644
--- a/mail/e-mail-shell-view-actions.c
+++ b/mail/e-mail-shell-view-actions.c
@@ -615,6 +615,132 @@ action_mail_show_hidden_cb (GtkAction *action,
}
static void
+action_mail_smart_backward_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSettings *shell_settings;
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ EMFormatHTMLDisplay *html_display;
+ EMailReader *reader;
+ MessageList *message_list;
+ GtkToggleAction *toggle_action;
+ GtkHTML *html;
+ gboolean caret_mode;
+ gboolean magic_spacebar;
+
+ /* This implements the so-called "Magic Backspace". */
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+
+ reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+
+ magic_spacebar = e_shell_settings_get_boolean (
+ shell_settings, "mail-magic-spacebar");
+
+ toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE));
+ caret_mode = gtk_toggle_action_get_active (toggle_action);
+
+ html = EM_FORMAT_HTML (html_display)->html;
+
+ if (gtk_html_command (html, "scroll-backward"))
+ return;
+
+ if (caret_mode || !magic_spacebar)
+ return;
+
+ /* XXX Are two separate calls really necessary? */
+
+ if (message_list_select (
+ message_list, MESSAGE_LIST_SELECT_PREVIOUS,
+ 0, CAMEL_MESSAGE_SEEN))
+ return;
+
+ if (message_list_select (
+ message_list, MESSAGE_LIST_SELECT_PREVIOUS |
+ MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN))
+ return;
+
+ em_folder_tree_select_prev_path (folder_tree, TRUE);
+
+ gtk_widget_grab_focus (GTK_WIDGET (message_list));
+}
+
+static void
+action_mail_smart_forward_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellSettings *shell_settings;
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ EMFormatHTMLDisplay *html_display;
+ EMailReader *reader;
+ MessageList *message_list;
+ GtkToggleAction *toggle_action;
+ GtkHTML *html;
+ gboolean caret_mode;
+ gboolean magic_spacebar;
+
+ /* This implements the so-called "Magic Spacebar". */
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+
+ reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+
+ magic_spacebar = e_shell_settings_get_boolean (
+ shell_settings, "mail-magic-spacebar");
+
+ toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE));
+ caret_mode = gtk_toggle_action_get_active (toggle_action);
+
+ html = EM_FORMAT_HTML (html_display)->html;
+
+ if (gtk_html_command (html, "scroll-forward"))
+ return;
+
+ if (caret_mode || !magic_spacebar)
+ return;
+
+ /* XXX Are two separate calls really necessary? */
+
+ if (message_list_select (
+ message_list, MESSAGE_LIST_SELECT_NEXT,
+ 0, CAMEL_MESSAGE_SEEN))
+ return;
+
+ if (message_list_select (
+ message_list, MESSAGE_LIST_SELECT_NEXT |
+ MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN))
+ return;
+
+ em_folder_tree_select_next_path (folder_tree, TRUE);
+
+ gtk_widget_grab_focus (GTK_WIDGET (message_list));
+}
+
+static void
action_mail_stop_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -906,6 +1032,20 @@ static GtkActionEntry mail_entries[] = {
N_("Show messages that have been temporarily hidden"),
G_CALLBACK (action_mail_show_hidden_cb) },
+ { "mail-smart-backward",
+ NULL,
+ NULL, /* No menu item; key press only */
+ NULL,
+ NULL,
+ G_CALLBACK (action_mail_smart_backward_cb) },
+
+ { "mail-smart-forward",
+ NULL,
+ NULL, /* No menu item; key press only */
+ NULL,
+ NULL,
+ G_CALLBACK (action_mail_smart_forward_cb) },
+
{ "mail-stop",
GTK_STOCK_STOP,
N_("Cancel"),
diff --git a/mail/e-mail-shell-view-actions.h b/mail/e-mail-shell-view-actions.h
index 16490fe38b..c6c1fa3c91 100644
--- a/mail/e-mail-shell-view-actions.h
+++ b/mail/e-mail-shell-view-actions.h
@@ -177,6 +177,10 @@
E_SHELL_WINDOW_ACTION ((window), "mail-show-hidden")
#define E_SHELL_WINDOW_ACTION_MAIL_SHOW_SOURCE(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-show-source")
+#define E_SHELL_WINDOW_ACTION_MAIL_SMART_BACKWARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-smart-backward")
+#define E_SHELL_WINDOW_ACTION_MAIL_SMART_FORWARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-smart-forward")
#define E_SHELL_WINDOW_ACTION_MAIL_STOP(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-stop")
#define E_SHELL_WINDOW_ACTION_MAIL_THREADS_COLLAPSE_ALL(window) \
diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c
index 8aecb20656..5974cc7386 100644
--- a/mail/e-mail-shell-view-private.c
+++ b/mail/e-mail-shell-view-private.c
@@ -64,6 +64,49 @@ mail_shell_view_folder_tree_popup_event_cb (EShellView *shell_view,
}
static gboolean
+mail_shell_view_key_press_event_cb (EMailShellView *mail_shell_view,
+ GdkEventKey *event)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ if ((event->state & GDK_CONTROL_MASK) != 0)
+ return FALSE;
+
+ switch (event->keyval) {
+ case GDK_space:
+ action = ACTION (MAIL_SMART_FORWARD);
+ break;
+
+ case GDK_BackSpace:
+ action = ACTION (MAIL_SMART_BACKWARD);
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ gtk_action_activate (action);
+
+ return TRUE;
+}
+
+static gint
+mail_shell_view_message_list_key_press_cb (EMailShellView *mail_shell_view,
+ gint row,
+ ETreePath path,
+ gint col,
+ GdkEvent *event)
+{
+ return mail_shell_view_key_press_event_cb (
+ mail_shell_view, &event->key);
+}
+
+static gboolean
mail_shell_view_message_list_right_click_cb (EShellView *shell_view,
gint row,
ETreePath path,
@@ -231,6 +274,11 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
mail_shell_view);
g_signal_connect_swapped (
+ message_list->tree, "key-press",
+ G_CALLBACK (mail_shell_view_message_list_key_press_cb),
+ mail_shell_view);
+
+ g_signal_connect_swapped (
message_list->tree, "right-click",
G_CALLBACK (mail_shell_view_message_list_right_click_cb),
mail_shell_view);
@@ -262,6 +310,11 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
mail_shell_view);
g_signal_connect_swapped (
+ html, "key-press-event",
+ G_CALLBACK (mail_shell_view_key_press_event_cb),
+ mail_shell_view);
+
+ g_signal_connect_swapped (
html, "status-message",
G_CALLBACK (mail_shell_view_reader_status_message_cb),
mail_shell_view);
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 97945cad56..5d47304d84 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -140,7 +140,6 @@ static void emfb_search_menu_activated(ESearchBar *esb, int id, EMFolderBrowser
static void emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb);
static void emfb_search_search_cleared(ESearchBar *esb);
-static int emfb_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, EMFolderBrowser *emfb);
static void emfb_list_message_selected (MessageList *ml, const char *uid, EMFolderBrowser *emfb);
static void emfb_expand_all_threads(BonoboUIComponent *uid, void *data, const char *path);
@@ -337,7 +336,6 @@ emfb_init(GObject *o)
e_event_emit((EEvent *)eme, "emfb.created", (EEventTarget *)target);
- g_signal_connect (((EMFolderView *) emfb)->list->tree, "key_press", G_CALLBACK(emfb_list_key_press), emfb);
g_signal_connect (((EMFolderView *) emfb)->list, "message_selected", G_CALLBACK (emfb_list_message_selected), emfb);
}
@@ -818,60 +816,6 @@ emfb_search_search_cleared(ESearchBar *esb)
/* ********************************************************************** */
-static int
-emfb_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, EMFolderBrowser *emfb)
-{
- gboolean state, folder_choose = TRUE;
- if ((ev->key.state & GDK_CONTROL_MASK) != 0)
- return FALSE;
-
- switch (ev->key.keyval) {
- case GDK_space:
- if (!emfb->view.preview->caret_mode && mail_config_get_enable_magic_spacebar ()) {
- state = gtk_html_command(((EMFormatHTML *)((EMFolderView *) emfb)->preview)->html, "scroll-forward");
- if (!state) {
- folder_choose = message_list_select(((EMFolderView *) emfb)->list, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN);
- if (!folder_choose)
- folder_choose = message_list_select(((EMFolderView *) emfb)->list,
- MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN);
- }
-
- } else
- em_utils_adjustment_page(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)emfb->priv->scroll), TRUE);
- break;
- case GDK_BackSpace:
- if (!emfb->view.preview->caret_mode && mail_config_get_enable_magic_spacebar ()) {
- state = gtk_html_command(((EMFormatHTML *)((EMFolderView *) emfb)->preview)->html, "scroll-backward");
- if (!state) {
- folder_choose = message_list_select(((EMFolderView *) emfb)->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, CAMEL_MESSAGE_SEEN);
- if (!folder_choose)
- folder_choose = message_list_select(((EMFolderView *) emfb)->list,
- MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN);
- }
-
- } else
- em_utils_adjustment_page(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)emfb->priv->scroll), FALSE);
- break;
- default:
- return FALSE;
- }
-
- if (!folder_choose && !emfb->view.preview->caret_mode && mail_config_get_enable_magic_spacebar ()) {
- //check for unread messages. if yes .. rewindback to the folder
- EMFolderTree *emft = g_object_get_data((GObject*)emfb, "foldertree");
- switch (ev->key.keyval) {
- case GDK_space:
- em_folder_tree_select_next_path (emft, TRUE);
- break;
- case GDK_BackSpace:
- em_folder_tree_select_prev_path (emft, TRUE);
- break;
- }
- gtk_widget_grab_focus ((GtkWidget *)((EMFolderView *) emfb)->list);
- }
- return TRUE;
-}
-
static void
emfb_list_message_selected (MessageList *ml, const char *uid, EMFolderBrowser *emfb)
{
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 34562bb44d..a98359e12f 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1402,7 +1402,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const char *uri)
if (folder == local_templates_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
accounts = e_get_account_list ();
@@ -1453,7 +1453,7 @@ em_utils_folder_is_drafts(CamelFolder *folder, const char *uri)
if (folder == local_drafts_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
accounts = e_get_account_list ();
@@ -1504,7 +1504,7 @@ em_utils_folder_is_sent(CamelFolder *folder, const char *uri)
if (folder == local_sent_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
accounts = e_get_account_list ();
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 6e2ace004b..9fe40a5fbc 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -46,6 +46,7 @@
#include "mail-folder-cache.h"
#include "em-event.h"
+#include "shell/e-shell.h"
#include "e-util/e-account-utils.h"
#include "e-util/gconf-bridge.h"
@@ -1069,13 +1070,13 @@ auto_account_changed(EAccountList *eal, EAccount *ea, void *dummy)
}
static void
-auto_online(CamelObject *o, void *ed, void *d)
+auto_online (EShell *shell)
{
EIterator *iter;
EAccountList *accounts;
struct _auto_data *info;
- if (!GPOINTER_TO_INT(ed))
+ if (!e_shell_get_online (shell))
return;
accounts = e_get_account_list ();
@@ -1089,10 +1090,15 @@ auto_online(CamelObject *o, void *ed, void *d)
/* call to setup initial, and after changes are made to the config */
/* FIXME: Need a cleanup funciton for when object is deactivated */
void
-mail_autoreceive_init (CamelSession *session)
+mail_autoreceive_init (EShellModule *shell_module,
+ CamelSession *session)
{
EAccountList *accounts;
EIterator *iter;
+ EShell *shell;
+
+ g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
+ g_return_if_fail (CAMEL_IS_SESSION (session));
if (auto_active)
return;
@@ -1107,7 +1113,13 @@ mail_autoreceive_init (CamelSession *session)
for (iter = e_list_get_iterator((EList *)accounts);e_iterator_is_valid(iter);e_iterator_next(iter))
auto_account_added(accounts, (EAccount *)e_iterator_get(iter), NULL);
- camel_object_hook_event (session, "online", auto_online, NULL);
+ shell = e_shell_module_get_shell (shell_module);
+
+ auto_online (shell);
+
+ g_signal_connect (
+ shell, "notify::online",
+ G_CALLBACK (auto_online), NULL);
}
/* we setup the download info's in a hashtable, if we later need to build the gui, we insert
diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h
index 92daaa5cd7..d602e63bd7 100644
--- a/mail/mail-send-recv.h
+++ b/mail/mail-send-recv.h
@@ -25,20 +25,22 @@
#include <gtk/gtk.h>
#include <camel/camel-session.h>
+#include <shell/e-shell-module.h>
G_BEGIN_DECLS
/* send/receive all uri's */
-GtkWidget * mail_send_receive (GtkWindow *parent);
+GtkWidget * mail_send_receive (GtkWindow *parent);
/* receive a single uri */
-void mail_receive_uri (const gchar *uri,
+void mail_receive_uri (const gchar *uri,
gboolean keep_on_server);
void mail_send (void);
/* setup auto receive stuff */
-void mail_autoreceive_init (CamelSession *session);
+void mail_autoreceive_init (EShellModule *shell_module,
+ CamelSession *session);
G_END_DECLS
diff --git a/mail/mail-session.h b/mail/mail-session.h
index 5998c9b91c..e98a4bd604 100644
--- a/mail/mail-session.h
+++ b/mail/mail-session.h
@@ -27,10 +27,7 @@
#include <camel/camel-session.h>
#include <shell/e-shell-module.h>
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+G_BEGIN_DECLS
void mail_session_init (EShellModule *shell_module);
void mail_session_shutdown (void);
@@ -55,8 +52,6 @@ void mail_session_set_junk_headers (const char **name, const char **value, int l
extern CamelSession *session;
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
-#endif /* ! MAIL_SESSION_H */
+#endif /* MAIL_SESSION_H */