aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader.c40
-rw-r--r--mail/em-utils.c76
-rw-r--r--mail/em-utils.h2
3 files changed, 36 insertions, 82 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index d77fafc448..02739f04d9 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -34,7 +34,7 @@
#include "e-util/e-charset.h"
#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
-#include "shell/e-shell.h"
+#include "shell/e-shell-utils.h"
#include "widgets/misc/e-popup-action.h"
#include "widgets/misc/e-menu-tool-action.h"
@@ -801,18 +801,50 @@ static void
action_mail_save_as_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
MessageList *message_list;
+ CamelMessageInfo *info;
CamelFolder *folder;
- GtkWindow *window;
GPtrArray *uids;
+ GFile *file;
+ const gchar *title;
+ const gchar *suggestion;
+ gchar *uri;
message_list = e_mail_reader_get_message_list (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);
folder = message_list->folder;
uids = message_list_get_selected (message_list);
+ g_return_if_fail (uids->len > 0);
+
+ title = ngettext ("Save Message", "Save Messages", uids->len);
+
+ /* Suggest as a filename the subject of the first message. */
+ info = camel_folder_get_message_info (folder, uids->pdata[0]);
+ if (info != NULL) {
+ suggestion = camel_message_info_subject (info);
+ camel_message_info_free (info);
+ } else
+ suggestion = NULL;
+
+ file = e_shell_run_save_dialog (shell, title, suggestion, NULL, NULL);
+
+ if (file == NULL) {
+ em_utils_uids_free (uids);
+ return;
+ }
+
+ uri = g_file_get_uri (file);
+
+ /* This eats the UID array, so do not free it. */
+ mail_save_messages (folder, uids, uri, NULL, NULL);
+
+ g_free (uri);
- em_utils_save_messages (window, folder, uids);
+ g_object_unref (file);
}
static void
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4f264955bd..ee547c4372 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -343,82 +343,6 @@ em_filename_make_safe (gchar *string)
}
}
-/* Saving messages... */
-
-struct _save_messages_data {
- CamelFolder *folder;
- GPtrArray *uids;
-};
-
-static void
-emu_save_messages_response(GtkWidget *filesel, gint response, struct _save_messages_data *data)
-{
- gchar *uri;
-
- if (response == GTK_RESPONSE_OK) {
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (filesel));
-
- if (!e_file_can_save((GtkWindow *)filesel, uri)) {
- g_free(uri);
- return;
- }
-
- e_file_update_save_path(gtk_file_chooser_get_current_folder_uri(
- GTK_FILE_CHOOSER (filesel)), TRUE);
- mail_save_messages(data->folder, data->uids, uri, NULL, NULL);
- data->uids = NULL;
- g_free(uri);
- }
-
- camel_object_unref(data->folder);
- if (data->uids)
- em_utils_uids_free(data->uids);
- g_free(data);
- gtk_widget_destroy((GtkWidget *)filesel);
-}
-
-/**
- * em_utils_save_messages:
- * @parent: parent window
- * @folder: folder containing messages to save
- * @uids: uids of messages to save
- *
- * Saves a group of messages to disk in mbox format (prompting the
- * user for filename).
- **/
-void
-em_utils_save_messages (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
-{
- struct _save_messages_data *data;
- GtkWidget *filesel;
- gchar *filename = NULL;
- CamelMessageInfo *info = NULL;
-
- g_return_if_fail (GTK_IS_WINDOW (parent));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (uids != NULL);
-
- info = camel_folder_get_message_info (folder, uids->pdata[0]);
- if (info) {
- filename = g_strdup (camel_message_info_subject (info));
- e_filename_make_safe (filename);
- camel_message_info_free (info);
- }
-
- filesel = e_file_get_save_filesel (parent, _("Save Message..."), filename, GTK_FILE_CHOOSER_ACTION_SAVE);
- if (filename)
- g_free (filename);
-
- camel_object_ref(folder);
-
- data = g_malloc(sizeof(struct _save_messages_data));
- data->folder = folder;
- data->uids = uids;
-
- g_signal_connect(filesel, "response", G_CALLBACK(emu_save_messages_response), data);
- gtk_widget_show((GtkWidget *)filesel);
-}
-
/* ********************************************************************** */
/* Flag-for-Followup... */
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 9bb35b1dc2..b61dce395a 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -52,8 +52,6 @@ void em_utils_edit_filters (GtkWidget *parent);
void em_filename_make_safe (gchar *string);
void em_utils_edit_vfolders (GtkWidget *parent);
-void em_utils_save_messages (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);
-
void em_utils_flag_for_followup (EMailReader *reader, CamelFolder *folder, GPtrArray *uids);
void em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);
void em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);