diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-12-02 00:43:13 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-12-02 04:01:14 +0800 |
commit | 5e938b590f66a44ed69e0867efe5158b634a7f57 (patch) | |
tree | ac3881b20ef9bcff5e93cf478e8d8abf9875dc0a /mail | |
parent | 76fbb9d23242cba427d71ded5590a9cad271b2b3 (diff) | |
download | gsoc2013-evolution-5e938b590f66a44ed69e0867efe5158b634a7f57.tar.gz gsoc2013-evolution-5e938b590f66a44ed69e0867efe5158b634a7f57.tar.zst gsoc2013-evolution-5e938b590f66a44ed69e0867efe5158b634a7f57.zip |
Expand the EMailReader interface so it's easier to use.
Adds the following methods:
CamelFolder * (*get_folder) (EMailReader *reader);
const gchar * (*get_folder_uri) (EMailReader *reader);
GPtrArray * (*get_selected_uids) (EMailReader *reader);
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 9 | ||||
-rw-r--r-- | mail/e-mail-reader-utils.c | 55 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 268 | ||||
-rw-r--r-- | mail/e-mail-reader.h | 6 | ||||
-rw-r--r-- | mail/em-utils.c | 6 |
5 files changed, 175 insertions, 169 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index e0d6aa9e16..ab27694778 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -193,7 +193,6 @@ mail_browser_message_selected_cb (EMailBrowser *browser, const gchar *uid) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; CamelMessageInfo *info; CamelFolder *folder; EMailReader *reader; @@ -202,10 +201,9 @@ mail_browser_message_selected_cb (EMailBrowser *browser, return; reader = E_MAIL_READER (browser); + folder = e_mail_reader_get_folder (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); - folder = MESSAGE_LIST (message_list)->folder; info = camel_folder_get_message_info (folder, uid); if (info == NULL) @@ -606,7 +604,6 @@ mail_browser_set_message (EMailReader *reader, const gchar *uid) { EMailReaderIface *iface; - GtkWidget *message_list; CamelMessageInfo *info; CamelFolder *folder; @@ -619,9 +616,7 @@ mail_browser_set_message (EMailReader *reader, return; } - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; + folder = e_mail_reader_get_folder (reader); info = camel_folder_get_message_info (folder, uid); if (info != NULL) { diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index de171d90ad..ff129a4a87 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -68,7 +68,6 @@ e_mail_reader_confirm_delete (EMailReader *reader) CamelFolder *folder; GtkWidget *check_button; GtkWidget *content_area; - GtkWidget *message_list; GtkWidget *dialog; GtkWindow *window; const gchar *label; @@ -79,15 +78,13 @@ e_mail_reader_confirm_delete (EMailReader *reader) g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE); - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); window = e_mail_reader_get_window (reader); shell_backend = e_mail_reader_get_shell_backend (reader); shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - folder = MESSAGE_LIST (message_list)->folder; - prompt_delete_in_vfolder = e_shell_settings_get_boolean ( shell_settings, "mail-prompt-delete-in-vfolder"); @@ -131,7 +128,6 @@ e_mail_reader_mark_as_read (EMailReader *reader, const gchar *uid) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; CamelFolder *folder; guint32 mask, set; guint32 flags; @@ -139,10 +135,9 @@ e_mail_reader_mark_as_read (EMailReader *reader, g_return_if_fail (E_IS_MAIL_READER (reader)); g_return_if_fail (uid != NULL); + folder = e_mail_reader_get_folder (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); - folder = MESSAGE_LIST (message_list)->folder; flags = camel_folder_get_message_flags (folder, uid); if (!(flags & CAMEL_MESSAGE_SEEN)) { @@ -162,21 +157,19 @@ e_mail_reader_mark_selected (EMailReader *reader, guint32 mask, guint32 set) { - GtkWidget *message_list; CamelFolder *folder; GPtrArray *uids; guint ii; g_return_val_if_fail (E_IS_MAIL_READER (reader), 0); - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); - folder = MESSAGE_LIST (message_list)->folder; if (folder == NULL) return 0; camel_folder_freeze (folder); - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + uids = e_mail_reader_get_selected_uids (reader); for (ii = 0; ii < uids->len; ii++) camel_folder_set_message_flags ( @@ -192,7 +185,6 @@ guint e_mail_reader_open_selected (EMailReader *reader) { EShellBackend *shell_backend; - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *views; @@ -202,14 +194,12 @@ e_mail_reader_open_selected (EMailReader *reader) g_return_val_if_fail (E_IS_MAIL_READER (reader), 0); - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); shell_backend = e_mail_reader_get_shell_backend (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); - if (!em_utils_ask_open_many (window, uids->len)) { em_utils_uids_free (uids); return 0; @@ -283,7 +273,6 @@ void e_mail_reader_print (EMailReader *reader, GtkPrintOperationAction action) { - GtkWidget *message_list; EMFormatHTMLDisplay *html_display; EMFormatHTMLPrint *html_print; CamelFolder *folder; @@ -291,17 +280,16 @@ e_mail_reader_print (EMailReader *reader, g_return_if_fail (E_IS_MAIL_READER (reader)); - html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; + folder = e_mail_reader_get_folder (reader); g_return_if_fail (folder != NULL); /* XXX Learn to handle len > 1. */ - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + uids = e_mail_reader_get_selected_uids (reader); if (uids->len != 1) goto exit; + html_display = e_mail_reader_get_html_display (reader); + html_print = em_format_html_print_new ( (EMFormatHTML *) html_display, action); em_format_merge_handler ( @@ -382,10 +370,10 @@ e_mail_reader_reply_to_message (EMailReader *reader, html_display = e_mail_reader_get_html_display (reader); html = ((EMFormatHTML *) html_display)->html; + folder = e_mail_reader_get_folder (reader); message_list = e_mail_reader_get_message_list (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; uid = MESSAGE_LIST (message_list)->cursor_uid; g_return_if_fail (uid != NULL); @@ -480,7 +468,6 @@ void e_mail_reader_create_filter_from_selected (EMailReader *reader, gint filter_type) { - GtkWidget *message_list; CamelFolder *folder; const gchar *filter_source; const gchar *folder_uri; @@ -493,10 +480,8 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader, g_return_if_fail (E_IS_MAIL_READER (reader)); - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); if (em_utils_folder_is_sent (folder, folder_uri)) filter_source = E_FILTER_SOURCE_OUTGOING; @@ -505,7 +490,7 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader, else filter_source = E_FILTER_SOURCE_INCOMING; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + uids = e_mail_reader_get_selected_uids (reader); if (uids->len == 1) { filter_data = g_malloc (sizeof (*filter_data)); @@ -545,7 +530,6 @@ void e_mail_reader_create_vfolder_from_selected (EMailReader *reader, gint vfolder_type) { - GtkWidget *message_list; CamelFolder *folder; const gchar *folder_uri; GPtrArray *uids; @@ -557,12 +541,9 @@ e_mail_reader_create_vfolder_from_selected (EMailReader *reader, g_return_if_fail (E_IS_MAIL_READER (reader)); - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); if (uids->len == 1) { vfolder_data = g_malloc (sizeof (*vfolder_data)); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 9055d6b26a..7ea11698a4 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -69,17 +69,14 @@ action_mail_add_sender_cb (GtkAction *action, { EShell *shell; EShellBackend *shell_backend; - GtkWidget *message_list; CamelMessageInfo *info; CamelFolder *folder; GPtrArray *uids; const gchar *address; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); shell_backend = e_mail_reader_get_shell_backend (reader); - - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + uids = e_mail_reader_get_selected_uids (reader); if (uids->len != 1) goto exit; @@ -159,14 +156,11 @@ static void action_mail_check_for_junk_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GPtrArray *uids; - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); mail_filter_junk (folder, uids); } @@ -188,21 +182,18 @@ static void action_mail_copy_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWidget *folder_tree; GtkWidget *dialog; - GtkWindow *parent; - GPtrArray *selected; + GtkWindow *window; + GPtrArray *uids; const gchar *uri; - parent = e_mail_reader_get_window (reader); - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + window = e_mail_reader_get_window (reader); + uids = e_mail_reader_get_selected_uids (reader); folder_tree = em_folder_tree_new (); - selected = message_list_get_selected (MESSAGE_LIST (message_list)); - - folder = MESSAGE_LIST (message_list)->folder; em_folder_tree_set_excluded ( EM_FOLDER_TREE (folder_tree), @@ -210,7 +201,7 @@ action_mail_copy_cb (GtkAction *action, EMFT_EXCLUDE_VTRASH); dialog = em_folder_selector_new ( - parent, EM_FOLDER_TREE (folder_tree), + window, EM_FOLDER_TREE (folder_tree), EM_FOLDER_SELECTOR_CAN_CREATE, _("Copy to Folder"), NULL, _("C_opy")); @@ -230,13 +221,13 @@ action_mail_copy_cb (GtkAction *action, if (uri != NULL) { mail_transfer_messages ( - folder, selected, FALSE, uri, 0, NULL, NULL); - selected = NULL; + folder, uids, FALSE, uri, 0, NULL, NULL); + uids = NULL; } exit: - if (selected != NULL) - em_utils_uids_free (selected); + if (uids != NULL) + em_utils_uids_free (uids); gtk_widget_destroy (dialog); } @@ -290,14 +281,11 @@ static void action_mail_filters_apply_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GPtrArray *uids; - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); mail_filter_on_demand (folder, uids); } @@ -314,18 +302,15 @@ action_mail_flag_clear_cb (GtkAction *action, EMailReader *reader) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; + folder = e_mail_reader_get_folder (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); - em_utils_flag_for_followup_clear (window, folder, uids); em_format_redraw (EM_FORMAT (html_display)); @@ -336,18 +321,15 @@ action_mail_flag_completed_cb (GtkAction *action, EMailReader *reader) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; + folder = e_mail_reader_get_folder (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); - em_utils_flag_for_followup_completed (window, folder, uids); em_format_redraw (EM_FORMAT (html_display)); @@ -357,17 +339,14 @@ static void action_mail_flag_for_followup_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); - em_utils_flag_for_followup (reader, folder, uids); } @@ -375,18 +354,16 @@ static void action_mail_forward_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids != NULL); if (em_utils_ask_open_many (window, uids->len)) @@ -399,18 +376,16 @@ static void action_mail_forward_attached_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids != NULL); if (em_utils_ask_open_many (window, uids->len)) @@ -423,18 +398,16 @@ static void action_mail_forward_inline_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids != NULL); if (em_utils_ask_open_many (window, uids->len)) @@ -447,18 +420,16 @@ static void action_mail_forward_quoted_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids != NULL); if (em_utils_ask_open_many (window, uids->len)) @@ -555,16 +526,13 @@ static void action_mail_message_edit_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWindow *window; GPtrArray *uids; + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); window = e_mail_reader_get_window (reader); - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); em_utils_edit_messages (folder, uids, FALSE); } @@ -573,12 +541,9 @@ static void action_mail_message_new_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); - - folder_uri = MESSAGE_LIST (message_list)->folder_uri; + folder_uri = e_mail_reader_get_folder_uri (reader); em_utils_compose_new_message (folder_uri); } @@ -594,21 +559,18 @@ static void action_mail_move_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GtkWidget *folder_tree; GtkWidget *dialog; - GtkWindow *parent; - GPtrArray *selected; + GtkWindow *window; + GPtrArray *uids; const gchar *uri; - parent = e_mail_reader_get_window (reader); - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); + window = e_mail_reader_get_window (reader); folder_tree = em_folder_tree_new (); - selected = message_list_get_selected (MESSAGE_LIST (message_list)); - - folder = MESSAGE_LIST (message_list)->folder; em_folder_tree_set_excluded ( EM_FOLDER_TREE (folder_tree), @@ -616,7 +578,7 @@ action_mail_move_cb (GtkAction *action, EMFT_EXCLUDE_VTRASH); dialog = em_folder_selector_new ( - parent, EM_FOLDER_TREE (folder_tree), + window, EM_FOLDER_TREE (folder_tree), EM_FOLDER_SELECTOR_CAN_CREATE, _("Move to Folder"), NULL, _("_Move")); @@ -636,13 +598,13 @@ action_mail_move_cb (GtkAction *action, if (uri != NULL) { mail_transfer_messages ( - folder, selected, TRUE, uri, 0, NULL, NULL); - selected = NULL; + folder, uids, TRUE, uri, 0, NULL, NULL); + uids = NULL; } exit: - if (selected != NULL) - em_utils_uids_free (selected); + if (uids != NULL) + em_utils_uids_free (uids); gtk_widget_destroy (dialog); } @@ -795,10 +757,10 @@ action_mail_redirect_cb (GtkAction *action, GtkWindow *window; const gchar *uid; + folder = e_mail_reader_get_folder (reader); message_list = e_mail_reader_get_message_list (reader); window = e_mail_reader_get_window (reader); - folder = MESSAGE_LIST (message_list)->folder; uid = MESSAGE_LIST (message_list)->cursor_uid; g_return_if_fail (uid != NULL); @@ -832,7 +794,6 @@ action_mail_save_as_cb (GtkAction *action, { EShell *shell; EShellBackend *shell_backend; - GtkWidget *message_list; CamelMessageInfo *info; CamelFolder *folder; GPtrArray *uids; @@ -841,12 +802,10 @@ action_mail_save_as_cb (GtkAction *action, const gchar *suggestion; gchar *uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); shell_backend = e_mail_reader_get_shell_backend (reader); - shell = e_shell_backend_get_shell (shell_backend); + uids = e_mail_reader_get_selected_uids (reader); - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids->len > 0); title = ngettext ("Save Message", "Save Messages", uids->len); @@ -859,6 +818,7 @@ action_mail_save_as_cb (GtkAction *action, } else suggestion = NULL; + shell = e_shell_backend_get_shell (shell_backend); file = e_shell_run_save_dialog (shell, title, suggestion, NULL, NULL); if (file == NULL) { @@ -947,18 +907,16 @@ action_mail_show_source_cb (GtkAction *action, { EMFormatHTMLDisplay *html_display; EShellBackend *shell_backend; - GtkWidget *message_list; CamelFolder *folder; GtkWidget *browser; GPtrArray *uids; const gchar *folder_uri; - message_list = e_mail_reader_get_message_list (reader); + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); shell_backend = e_mail_reader_get_shell_backend (reader); + uids = e_mail_reader_get_selected_uids (reader); - folder = MESSAGE_LIST (message_list)->folder; - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); g_return_if_fail (uids->len > 0); browser = e_mail_browser_new (shell_backend); @@ -976,15 +934,12 @@ static void action_mail_toggle_important_cb (GtkAction *action, EMailReader *reader) { - GtkWidget *message_list; CamelFolder *folder; GPtrArray *uids; guint ii; - message_list = e_mail_reader_get_message_list (reader); - - folder = MESSAGE_LIST (message_list)->folder; - uids = message_list_get_selected (MESSAGE_LIST (message_list)); + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); camel_folder_freeze (folder); @@ -1060,15 +1015,15 @@ action_search_folder_recipient_cb (GtkAction *action, EMailReader *reader) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; EWebView *web_view; CamelURL *curl; + const gchar *folder_uri; const gchar *uri; /* This action is defined in EMailDisplay. */ + folder_uri = e_mail_reader_get_folder_uri (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html); @@ -1080,13 +1035,10 @@ action_search_folder_recipient_cb (GtkAction *action, if (curl->path != NULL && *curl->path != '\0') { CamelInternetAddress *inet_addr; - const gchar *folder_uri; /* Ensure vfolder is running. */ vfolder_load_storage (); - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - inet_addr = camel_internet_address_new (); camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path); vfolder_gui_add_from_address (inet_addr, AUTO_TO, folder_uri); @@ -1101,15 +1053,15 @@ action_search_folder_sender_cb (GtkAction *action, EMailReader *reader) { EMFormatHTMLDisplay *html_display; - GtkWidget *message_list; EWebView *web_view; CamelURL *curl; + const gchar *folder_uri; const gchar *uri; /* This action is defined in EMailDisplay. */ + folder_uri = e_mail_reader_get_folder_uri (reader); html_display = e_mail_reader_get_html_display (reader); - message_list = e_mail_reader_get_message_list (reader); web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html); @@ -1121,13 +1073,10 @@ action_search_folder_sender_cb (GtkAction *action, if (curl->path != NULL && *curl->path != '\0') { CamelInternetAddress *inet_addr; - const gchar *folder_uri; /* Ensure vfolder is running. */ vfolder_load_storage (); - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - inet_addr = camel_internet_address_new (); camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path); vfolder_gui_add_from_address (inet_addr, AUTO_FROM, folder_uri); @@ -1918,10 +1867,12 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader) { EMFormatHTMLDisplay *html_display; GtkWidget *message_list; + CamelFolder *folder; const gchar *cursor_uid; const gchar *format_uid; const gchar *key; + folder = e_mail_reader_get_folder (reader); html_display = e_mail_reader_get_html_display (reader); message_list = e_mail_reader_get_message_list (reader); @@ -1944,8 +1895,7 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader) gint op_id; op_id = mail_get_messagex ( - MESSAGE_LIST (message_list)->folder, - cursor_uid, + folder, cursor_uid, mail_reader_message_loaded_cb, g_object_ref (reader), mail_msg_fast_ordered_push); @@ -2007,24 +1957,58 @@ mail_reader_emit_folder_loaded (EMailReader *reader) g_signal_emit (reader, signals[FOLDER_LOADED], 0); } +static GPtrArray * +mail_reader_get_selected_uids (EMailReader *reader) +{ + GtkWidget *message_list; + + message_list = e_mail_reader_get_message_list (reader); + + return message_list_get_selected (MESSAGE_LIST (message_list)); +} + +static CamelFolder * +mail_reader_get_folder (EMailReader *reader) +{ + GtkWidget *message_list; + + message_list = e_mail_reader_get_message_list (reader); + + return MESSAGE_LIST (message_list)->folder; +} + +static const gchar * +mail_reader_get_folder_uri (EMailReader *reader) +{ + GtkWidget *message_list; + + message_list = e_mail_reader_get_message_list (reader); + + return MESSAGE_LIST (message_list)->folder_uri; +} + static void mail_reader_set_folder (EMailReader *reader, CamelFolder *folder, const gchar *folder_uri) { EMFormatHTMLDisplay *html_display; + CamelFolder *previous_folder; GtkWidget *message_list; + const gchar *previous_folder_uri; gboolean outgoing; html_display = e_mail_reader_get_html_display (reader); message_list = e_mail_reader_get_message_list (reader); - if (MESSAGE_LIST (message_list)->folder != NULL) - mail_sync_folder ( - MESSAGE_LIST (message_list)->folder, NULL, NULL); + previous_folder = e_mail_reader_get_folder (reader); + previous_folder_uri = e_mail_reader_get_folder_uri (reader); + + if (previous_folder != NULL) + mail_sync_folder (previous_folder, NULL, NULL); /* Skip the rest if we're already viewing the folder. */ - if (g_strcmp0 (folder_uri, MESSAGE_LIST (message_list)->folder_uri) == 0) + if (g_strcmp0 (folder_uri, previous_folder_uri) == 0) return; outgoing = folder != NULL && folder_uri != NULL && ( @@ -2416,6 +2400,9 @@ mail_reader_init_charset_actions (EMailReader *reader) static void mail_reader_class_init (EMailReaderIface *iface) { + iface->get_selected_uids = mail_reader_get_selected_uids; + iface->get_folder = mail_reader_get_folder; + iface->get_folder_uri = mail_reader_get_folder_uri; iface->set_folder = mail_reader_set_folder; iface->set_message = mail_reader_set_message; iface->update_actions = mail_reader_update_actions; @@ -2673,7 +2660,6 @@ e_mail_reader_changed (EMailReader *reader) guint32 e_mail_reader_check_state (EMailReader *reader) { - GtkWidget *message_list; GPtrArray *uids; CamelFolder *folder; CamelStore *store = NULL; @@ -2698,10 +2684,9 @@ e_mail_reader_check_state (EMailReader *reader) g_return_val_if_fail (E_IS_MAIL_READER (reader), 0); - message_list = e_mail_reader_get_message_list (reader); - uids = message_list_get_selected (MESSAGE_LIST (message_list)); - folder_uri = MESSAGE_LIST (message_list)->folder_uri; - folder = MESSAGE_LIST (message_list)->folder; + folder = e_mail_reader_get_folder (reader); + folder_uri = e_mail_reader_get_folder_uri (reader); + uids = e_mail_reader_get_selected_uids (reader); if (folder != NULL) { store = CAMEL_STORE (folder->parent_store); @@ -2921,6 +2906,19 @@ e_mail_reader_get_popup_menu (EMailReader *reader) return iface->get_popup_menu (reader); } +GPtrArray * +e_mail_reader_get_selected_uids (EMailReader *reader) +{ + EMailReaderIface *iface; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL); + + iface = E_MAIL_READER_GET_IFACE (reader); + g_return_val_if_fail (iface->get_selected_uids != NULL, NULL); + + return iface->get_selected_uids (reader); +} + EShellBackend * e_mail_reader_get_shell_backend (EMailReader *reader) { @@ -2947,6 +2945,32 @@ e_mail_reader_get_window (EMailReader *reader) return iface->get_window (reader); } +CamelFolder * +e_mail_reader_get_folder (EMailReader *reader) +{ + EMailReaderIface *iface; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL); + + iface = E_MAIL_READER_GET_IFACE (reader); + g_return_val_if_fail (iface->get_folder != NULL, NULL); + + return iface->get_folder (reader); +} + +const gchar * +e_mail_reader_get_folder_uri (EMailReader *reader) +{ + EMailReaderIface *iface; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL); + + iface = E_MAIL_READER_GET_IFACE (reader); + g_return_val_if_fail (iface->get_folder_uri != NULL, NULL); + + return iface->get_folder_uri (reader); +} + void e_mail_reader_set_folder (EMailReader *reader, CamelFolder *folder, diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index 122d11fb88..6e3b8d4f9a 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -90,9 +90,12 @@ struct _EMailReaderIface { (*get_html_display) (EMailReader *reader); GtkWidget * (*get_message_list) (EMailReader *reader); GtkMenu * (*get_popup_menu) (EMailReader *reader); + GPtrArray * (*get_selected_uids) (EMailReader *reader); EShellBackend * (*get_shell_backend) (EMailReader *reader); GtkWindow * (*get_window) (EMailReader *reader); + CamelFolder * (*get_folder) (EMailReader *reader); + const gchar * (*get_folder_uri) (EMailReader *reader); void (*set_folder) (EMailReader *reader, CamelFolder *folder, const gchar *folder_uri); @@ -118,8 +121,11 @@ EMFormatHTMLDisplay * e_mail_reader_get_html_display (EMailReader *reader); GtkWidget * e_mail_reader_get_message_list (EMailReader *reader); GtkMenu * e_mail_reader_get_popup_menu (EMailReader *reader); +GPtrArray * e_mail_reader_get_selected_uids (EMailReader *reader); EShellBackend * e_mail_reader_get_shell_backend (EMailReader *reader); GtkWindow * e_mail_reader_get_window (EMailReader *reader); +CamelFolder * e_mail_reader_get_folder (EMailReader *reader); +const gchar * e_mail_reader_get_folder_uri (EMailReader *reader); void e_mail_reader_set_folder (EMailReader *reader, CamelFolder *folder, const gchar *folder_uri); diff --git a/mail/em-utils.c b/mail/em-utils.c index 1238fcf2e5..3cb662e5bd 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -399,7 +399,7 @@ em_utils_flag_for_followup (EMailReader *reader, EShellBackend *shell_backend; EShell *shell; GtkWidget *editor; - GtkWindow *parent; + GtkWindow *window; CamelTag *tags; gint i; @@ -408,8 +408,8 @@ em_utils_flag_for_followup (EMailReader *reader, g_return_if_fail (uids != NULL); editor = e_mail_tag_editor_new (); - parent = e_mail_reader_get_window (reader); - gtk_window_set_transient_for (GTK_WINDOW (editor), parent); + window = e_mail_reader_get_window (reader); + gtk_window_set_transient_for (GTK_WINDOW (editor), window); shell_backend = e_mail_reader_get_shell_backend (reader); shell = e_shell_backend_get_shell (shell_backend); |