aboutsummaryrefslogtreecommitdiffstats
path: root/mail/message-browser.c
diff options
context:
space:
mode:
author5 <NotZed@Ximian.com>2001-11-06 06:44:56 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-11-06 06:44:56 +0800
commit016bfe6a735a8f5b2b31731795d4812cbdaf8f7a (patch)
tree0de19924113e73d15d30285d1c3ea0bac7b3755d /mail/message-browser.c
parenteb48b8f98bfbfc9633447aa2a6c3360622a2a777 (diff)
downloadgsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar.gz
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar.bz2
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar.lz
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar.xz
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.tar.zst
gsoc2013-evolution-016bfe6a735a8f5b2b31731795d4812cbdaf8f7a.zip
Override the Move/Copy handlers setup by the folder_browser_ui code, and
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. svn path=/trunk/; revision=14597
Diffstat (limited to 'mail/message-browser.c')
-rw-r--r--mail/message-browser.c95
1 files changed, 94 insertions, 1 deletions
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);