diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-11-29 04:37:43 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-11-29 04:37:43 +0800 |
commit | f22ac8e3a051c76a48206a7a717c21a180148b58 (patch) | |
tree | 4dadee5e00f11aaa860ca4042864b57e7fa38989 /mail | |
parent | 1db83e1fb92869bdac0eef802867aef989feb72c (diff) | |
download | gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar.gz gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar.bz2 gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar.lz gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar.xz gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.tar.zst gsoc2013-evolution-f22ac8e3a051c76a48206a7a717c21a180148b58.zip |
Added the SaveAs bonobo menu verb thingy.
2000-11-28 Jeffrey Stedfast <fejj@helixcode.com>
* folder-browser-factory.c: Added the SaveAs bonobo menu verb
thingy.
* mail-callbacks.c (save_msg): New callback for saving messages.
(save_msg_ok):
* folder-browser.c (on_right_click): Add a Save Ass menu item.
* mail-ops.c (cleanup_save_messages): Save all emails to the path
given.
svn path=/trunk/; revision=6699
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 13 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 1 | ||||
-rw-r--r-- | mail/folder-browser.c | 1 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 61 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 1 | ||||
-rw-r--r-- | mail/mail-ops.c | 55 |
6 files changed, 94 insertions, 38 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index c63eb13543..e5781f0f5b 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2000-11-28 Jeffrey Stedfast <fejj@helixcode.com> + + * folder-browser-factory.c: Added the SaveAs bonobo menu verb + thingy. + + * mail-callbacks.c (save_msg): New callback for saving messages. + (save_msg_ok): + + * folder-browser.c (on_right_click): Add a Save Ass menu item. + + * mail-ops.c (cleanup_save_messages): Save all emails to the path + given. + 2000-11-28 Dan Winship <danw@helixcode.com> * mail-local.c (cleanup_register_folder): Fix the initial unread diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 07bd36d3fb..d24c56e10e 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -54,6 +54,7 @@ BonoboUIVerb verbs [] = { /* Message Menu */ BONOBO_UI_UNSAFE_VERB ("MessageOpenNewWnd", view_message), BONOBO_UI_UNSAFE_VERB ("MessageEdit", edit_message), + BONOBO_UI_UNSAFE_VERB ("MessageSaveAs", save_msg), BONOBO_UI_UNSAFE_VERB ("MessagePrint", print_msg), BONOBO_UI_UNSAFE_VERB ("MessageReplySndr", reply_to_sender), BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all), diff --git a/mail/folder-browser.c b/mail/folder-browser.c index d03e58eaa4..145e5512d2 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -477,6 +477,7 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Fold EPopupMenu menu[] = { { _("Open"), NULL, GTK_SIGNAL_FUNC (view_msg), NULL, 0 }, { _("Edit"), NULL, GTK_SIGNAL_FUNC (edit_msg), NULL, 1 }, + { _("Save As..."), NULL, GTK_SIGNAL_FUNC (save_msg), NULL, 0 }, { _("Print"), NULL, GTK_SIGNAL_FUNC (print_msg), NULL, 0 }, { "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 }, { _("Reply to Sender"), NULL, GTK_SIGNAL_FUNC (reply_to_sender), NULL, 0 }, diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index fd57b5b6bc..caf62352af 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -672,6 +672,67 @@ edit_msg (GtkWidget *widget, gpointer user_data) mail_do_edit_messages (fb->folder, uids, (GtkSignalFunc) composer_send_cb); } +static void +save_msg_ok (GtkWidget *widget, gpointer user_data) +{ + CamelFolder *folder; + GPtrArray *uids; + char *path; + + /* FIXME: is path an allocated string? */ + path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (user_data)); + + folder = gtk_object_get_data (GTK_OBJECT (user_data), "folder"); + uids = gtk_object_get_data (GTK_OBJECT (user_data), "uids"); + gtk_object_remove_no_notify (GTK_OBJECT (user_data), "uids"); + mail_do_save_messages (folder, uids, path); + + gtk_widget_destroy (GTK_WIDGET (user_data)); +} + +static void +save_msg_destroy (gpointer user_data) +{ + GPtrArray *uids = user_data; + + if (uids) { + int i; + + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + + g_ptr_array_free (uids, TRUE); + } +} + +void +save_msg (GtkWidget *widget, gpointer user_data) +{ + FolderBrowser *fb = FOLDER_BROWSER (user_data); + GtkFileSelection *filesel; + GPtrArray *uids; + char *title; + + uids = g_ptr_array_new (); + message_list_foreach (fb->message_list, enumerate_msg, uids); + + if (uids->len == 1) + title = _("Save Message As..."); + else + title = _("Save Messages As..."); + + filesel = GTK_FILE_SELECTION (gtk_file_selection_new (title)); + gtk_object_set_data_full (GTK_OBJECT (filesel), "uids", uids, save_msg_destroy); + gtk_object_set_data (GTK_OBJECT (filesel), "folder", fb->folder); + gtk_signal_connect (GTK_OBJECT (filesel->ok_button), + "clicked", GTK_SIGNAL_FUNC (save_msg_ok), filesel); + gtk_signal_connect_object (GTK_OBJECT (filesel->cancel_button), + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (filesel)); + + gtk_widget_show (GTK_WIDGET (filesel)); +} + void delete_msg (GtkWidget *button, gpointer user_data) { diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index 23e7f13d75..63becc96db 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -53,6 +53,7 @@ void apply_filters (GtkWidget *widget, gpointer user_data); void print_msg (GtkWidget *widget, gpointer user_data); void print_preview_msg (GtkWidget *widget, gpointer user_data); void edit_msg (GtkWidget *widget, gpointer user_data); +void save_msg (GtkWidget *widget, gpointer user_data); void view_msg (GtkWidget *widget, gpointer user_data); void view_source (GtkWidget *widget, gpointer user_data); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 60c7a3dad6..1646c35416 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -2397,7 +2397,6 @@ typedef struct save_messages_input_s { } save_messages_input_t; typedef struct save_messages_data_s { - GPtrArray *messages; } save_messages_data_t; static gchar * @@ -2425,10 +2424,11 @@ static void do_save_messages (gpointer in_data, gpointer op_data, CamelException *ex) { save_messages_input_t *input = (save_messages_input_t *) in_data; - save_messages_data_t *data = (save_messages_data_t *) op_data; + CamelStream *stream; int i; - data->messages = g_ptr_array_new (); + mail_tool_camel_lock_up (); + stream = camel_stream_fs_new_with_name (input->path, O_WRONLY | O_CREAT | O_TRUNC, 0600); for (i = 0; i < input->uids->len; i++) { CamelMimeMessage *message; @@ -2436,12 +2436,21 @@ do_save_messages (gpointer in_data, gpointer op_data, CamelException *ex) mail_op_set_message (_("Retrieving message %d of %d (uid \"%s\")"), i + 1, input->uids->len, (char *)input->uids->pdata[i]); - mail_tool_camel_lock_up (); message = camel_folder_get_message (input->folder, input->uids->pdata[i], ex); - mail_tool_camel_lock_down (); + if (message) { + camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream); + camel_object_unref (CAMEL_OBJECT (message)); + } - g_ptr_array_add (data->messages, message); + g_free (input->uids->pdata[i]); } + + g_ptr_array_free (input->uids, TRUE); + + camel_stream_flush (stream); + camel_object_unref (CAMEL_OBJECT (stream)); + + mail_tool_camel_lock_down (); } static void @@ -2449,39 +2458,9 @@ cleanup_save_messages (gpointer in_data, gpointer op_data, CamelException *ex) { save_messages_input_t *input = (save_messages_input_t *) in_data; - save_messages_data_t *data = (save_messages_data_t *) op_data; - int i; - for (i = 0; i < data->messages->len; i++) { - CamelMimeMessage *msg; - CamelStream *stream; - char *filename; - - if (data->messages->pdata[i] == NULL) - continue; - - msg = data->messages->pdata[i]; - - /* if we are saving a single message, use the filename the user selected */ - if (input->uids->len == 1) - filename = g_strdup (input->path); - else - filename = g_strdup_printf ("%s/[%s] %s.eml", input->path, - camel_mime_message_get_subject (msg), - (char *) input->uids->pdata[i]); - - stream = camel_stream_fs_new_with_name (filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), stream); - camel_stream_flush (stream); - g_free (filename); - - camel_object_unref (CAMEL_OBJECT (stream)); - camel_object_unref (CAMEL_OBJECT (data->messages->pdata[i])); - g_free (input->uids->pdata[i]); - } + g_free (input->path); - g_ptr_array_free (input->uids, TRUE); - g_ptr_array_free (data->messages, TRUE); camel_object_unref (CAMEL_OBJECT (input->folder)); } @@ -2505,7 +2484,7 @@ mail_do_save_messages (CamelFolder *folder, GPtrArray *uids, gchar *path) input = g_new (save_messages_input_t, 1); input->folder = folder; input->uids = uids; - input->path = path; + input->path = g_strdup (path); mail_operation_queue (&op_save_messages, input, TRUE); } |