aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/mail-callbacks.c3
-rw-r--r--mail/message-browser.c95
3 files changed, 113 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index c063e797b5..6ad2e81963 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2001-11-05 <NotZed@Ximian.com>
+
+ * message-browser.c (set_bonobo_ui): Override the Move/Copy
+ handlers setup by the folder_browser_ui code, and use our own,
+ because we need to pass it a live window which we can't.
+ (transfer_msg): Our own version of mail-callbacks.c:transfer_msg,
+ so we can properly pass the parent to the user_select_folder.
+ (transfer_msg_done): Also copy this so we can pass it diff args.
+ All fix #13919.
+
+ * mail-callbacks.c (transfer_msg): Set physical/uri to NULL before
+ calling, because althought he shell client api call is supposed to
+ null these out, it doesn't with its stupid assertion checks on
+ entry. Also free physical to plug a memleak. Bugs exposed by
+ #13919.
+
2001-11-01 Jeffrey Stedfast <fejj@ximian.com>
* mail-display.h (mail_html_write): Renamed from
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 789e60cad8..527d9d39a5 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -1276,6 +1276,8 @@ transfer_msg (FolderBrowser *fb, gboolean delete_from_source)
else
desc = _("Copy message(s) to");
+ uri = NULL;
+ physical = NULL;
evolution_shell_client_user_select_folder (global_shell_client,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (fb))),
desc, last,
@@ -1301,6 +1303,7 @@ transfer_msg (FolderBrowser *fb, gboolean delete_from_source)
mail_transfer_messages (fb->folder, uids, delete_from_source,
physical, 0, NULL, NULL);
}
+ g_free(physical);
}
void
diff --git a/mail/message-browser.c b/mail/message-browser.c
index c8f2b7ed85..10ec477e7e 100644
--- a/mail/message-browser.c
+++ b/mail/message-browser.c
@@ -87,6 +87,81 @@ message_browser_init (GtkObject *object)
}
+static void
+transfer_msg_done (gboolean ok, void *data)
+{
+ MessageBrowser *mb = data;
+ int row;
+
+ if (ok && !GTK_OBJECT_DESTROYED (mb)) {
+ row = e_tree_row_of_node (mb->fb->message_list->tree,
+ e_tree_get_cursor (mb->fb->message_list->tree));
+
+ /* If this is the last message and deleted messages
+ are hidden, select the previous */
+ if ((row + 1 == e_tree_row_count (mb->fb->message_list->tree))
+ && mail_config_get_hide_deleted ())
+ message_list_select (mb->fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
+ 0, CAMEL_MESSAGE_DELETED, FALSE);
+ else
+ message_list_select (mb->fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
+ 0, 0, FALSE);
+ }
+
+ gtk_object_unref (GTK_OBJECT (mb));
+}
+
+static void
+transfer_msg (MessageBrowser *mb, int del)
+{
+ const char *allowed_types[] = { "mail", "vtrash", NULL };
+ extern EvolutionShellClient *global_shell_client;
+ char *uri, *physical, *path, *desc;
+ static char *last = NULL;
+ GPtrArray *uids;
+
+ if (GTK_OBJECT_DESTROYED(mb))
+ return;
+
+ if (last == NULL)
+ last = g_strdup ("");
+
+ if (del)
+ desc = _("Move message(s) to");
+ else
+ desc = _("Copy message(s) to");
+
+ uri = NULL;
+ physical = NULL;
+ evolution_shell_client_user_select_folder (global_shell_client,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mb))),
+ desc, last,
+ allowed_types, &uri, &physical);
+ if (!uri)
+ return;
+
+ path = strchr (uri, '/');
+ if (path && strcmp (last, path) != 0) {
+ g_free (last);
+ last = g_strdup_printf ("evolution:%s", path);
+ }
+ g_free (uri);
+
+ uids = g_ptr_array_new ();
+ message_list_foreach (mb->fb->message_list, enumerate_msg, uids);
+
+ if (del) {
+ gtk_object_ref (GTK_OBJECT (mb));
+ mail_transfer_messages (mb->fb->folder, uids, del,
+ physical, 0, transfer_msg_done, mb);
+ } else {
+ mail_transfer_messages (mb->fb->folder, uids, del,
+ physical, 0, NULL, NULL);
+ }
+ g_free(physical);
+}
+
+
/* UI callbacks */
static void
@@ -95,9 +170,23 @@ message_browser_close (BonoboUIComponent *uih, void *user_data, const char *path
gtk_widget_destroy (GTK_WIDGET (user_data));
}
+static void
+message_browser_move (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ transfer_msg(user_data, TRUE);
+}
+
+static void
+message_browser_copy (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ transfer_msg(user_data, FALSE);
+}
+
static BonoboUIVerb
browser_verbs [] = {
BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", message_browser_close),
+ BONOBO_UI_UNSAFE_VERB ("MessageMove", message_browser_move),
+ BONOBO_UI_UNSAFE_VERB ("MessageCopy", message_browser_copy),
BONOBO_UI_VERB_END
};
@@ -200,7 +289,11 @@ set_bonobo_ui (GtkWidget *widget, FolderBrowser *fb)
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
- /* Add the Close item */
+ /* Hack around the move/copy commands api's */
+ bonobo_ui_component_remove_listener (uic, "MessageCopy");
+ bonobo_ui_component_remove_listener (uic, "MessageMove");
+
+ /* Add the Close & Move/Copy items */
bonobo_ui_component_add_verb_list_with_data (uic, browser_verbs, widget);