[anjal] Add support for opening mails from Draft as composer.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Add support for opening mails from Draft as composer.
- Date: Thu, 25 Jun 2009 05:15:53 +0000 (UTC)
commit b6667d2aad8df30ecc4347a75497fc5c7d43e3f8
Author: Srinivasa Ragavan <sragavan novell com>
Date: Thu Jun 25 10:44:28 2009 +0530
Add support for opening mails from Draft as composer.
NOTE: You need Evolution equal or later than
http://git.gnome.org/cgit/evolution/commit/?id=87773593220e581de841e837c29acb99a818c890
src/mail-folder-view.c | 69 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 60 insertions(+), 9 deletions(-)
---
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index e7afac2..ec2c824 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -31,6 +31,8 @@
#include "mail/mail-mt.h"
#include "mail/mail-ops.h"
#include "mail/em-utils.h"
+#include "mail/em-composer-utils.h"
+
#ifdef EVOLUTION_2_26
#include "mail/em-marshal.h"
#else
@@ -44,6 +46,8 @@
#include "custom-cell-renderer-toggle-pixbuf.h"
#include <e-util/e-util.h>
#include "mail-utils.h"
+#include "mail-composer-view.h"
+#include "mail-shell.h"
#include <gdk/gdkkeysyms.h>
@@ -66,6 +70,7 @@ struct _MailFolderViewPrivate {
GtkWidget *view_scroller;
GtkWidget *info_bar;
GtkWidget *info_spinner;
+ CamelOperation *cancel;
};
enum {
@@ -231,6 +236,7 @@ mail_folder_view_init (MailFolderView *shell)
shell->priv->show_children = g_getenv("ANJAL_CHILDREN") != NULL;
shell->priv->folder = NULL;
shell->search = NULL;
+ shell->priv->cancel = NULL;
if (shell->priv->light)
shell->model = mail_sqlite_store_new ();
else {
@@ -257,6 +263,9 @@ mail_folder_view_finalize (GObject *object)
{
MailFolderView *mfv = (MailFolderView *)object;
+ if (mfv->priv->cancel) {
+ camel_operation_cancel(mfv->priv->cancel);
+ }
if (mfv->search_state) {
g_free(mfv->search_state);
mfv->search_state = NULL;
@@ -989,6 +998,26 @@ mfv_popup_undelete (EPopup *ep, EPopupItem *pitem, void *data)
mfv_delete (mfv, FALSE);
}
+static void
+mfv_message_got(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data, CamelException *ex)
+{
+ EMsgComposer *composer;
+ MailFolderView *mfv = (MailFolderView *)data;
+ MailComposerView *mcv;
+
+ mfv->priv->cancel = NULL;
+ composer = em_utils_edit_message (msg, folder);
+ mcv = mail_shell_create_composer ();
+ mail_composer_view_replace_composer ((struct _MailComposerView *)mcv, composer);
+}
+
+static void
+mfv_open_composer (MailFolderView *mfv, char *uid)
+{
+ e_msg_composer_set_lite();
+ mfv->priv->cancel = mail_get_messagex (mfv->priv->folder, uid, mfv_message_got, mfv, mail_msg_fast_ordered_push);
+}
+
static EPopupItem mfv_popup_items[] = {
// { E_POPUP_ITEM, "10.emfv.00", N_("_Reply to Sender"), emfv_popup_reply_sender, NULL, "mail-reply-sender", EM_POPUP_SELECT_ONE },
// { E_POPUP_ITEM, "10.emfv.01", N_("Reply to _All"), emfv_popup_reply_all, NULL, "mail-reply-all", EM_POPUP_SELECT_ONE },
@@ -1054,6 +1083,12 @@ mfv_popup (MailFolderView *mfv, GdkEvent *event)
static gboolean
mfv_button_clicked (GtkWidget *w, GdkEventButton *event, MailFolderView *mfv)
{
+ gboolean outgoing = FALSE;
+
+ if (em_utils_folder_is_drafts(mfv->priv->folder, mfv->uri)
+ || em_utils_folder_is_outbox(mfv->priv->folder, mfv->uri))
+ outgoing = TRUE;
+
if (event->button == 2 || event->type == GDK_2BUTTON_PRESS) {
MailConvView *mcv = NULL;
GtkTreePath *path=NULL;
@@ -1065,7 +1100,7 @@ mfv_button_clicked (GtkWidget *w, GdkEventButton *event, MailFolderView *mfv)
char *umid = NULL;
uids = em_tree_store_get_child_sorted_tree ((EMTreeStore *)mfv->model, &iter);
- if (uids && uids->len >0) {
+ if (!outgoing && uids && uids->len >0) {
umid = g_strdup_printf("message://%s/%s\n", mfv->priv->folder->full_name, (char *)uids->pdata[0]);
g_signal_emit (mfv, signals[MESSAGE_NEW], 0, &mcv, umid);
g_free(umid);
@@ -1073,7 +1108,10 @@ mfv_button_clicked (GtkWidget *w, GdkEventButton *event, MailFolderView *mfv)
if (!mcv)
return TRUE;
}
- mail_conv_view_set_thread (mcv, mfv->priv->folder, uids);
+ if (outgoing)
+ mfv_open_composer (mfv, (char *)uids->pdata[0]);
+ else
+ mail_conv_view_set_thread (mcv, mfv->priv->folder, uids);
}
gtk_tree_path_free(path);
}
@@ -1091,18 +1129,27 @@ mfv_message_activated (GtkTreeView *tree_view, GtkTreePath *path, G
{
GtkTreeIter iter;
CamelMessageInfo *info = NULL;
+ gboolean outgoing = FALSE;
- shell->priv->message_shown = 1;
- gtk_widget_hide ((GtkWidget *)shell->tree);
- gtk_widget_hide (shell->priv->view_scroller);
- gtk_widget_show ((GtkWidget *)shell->mail);
+
+ if (em_utils_folder_is_drafts(shell->priv->folder, shell->uri)
+ || em_utils_folder_is_outbox(shell->priv->folder, shell->uri))
+ outgoing = TRUE;
+
+ if (!outgoing) {
+ shell->priv->message_shown = 1;
+ gtk_widget_hide ((GtkWidget *)shell->tree);
+ gtk_widget_hide (shell->priv->view_scroller);
+ gtk_widget_show ((GtkWidget *)shell->mail);
+ }
if (!gtk_tree_model_get_iter (shell->model, &iter, path)) {
g_warning ("Unable to open message\n");
return;
}
gtk_tree_model_get (shell->model, &iter, EMTS_COL_MESSAGEINFO, &info, -1);
- shell->priv->uid = g_strdup (info->uid);
+ if (!outgoing)
+ shell->priv->uid = g_strdup (info->uid);
if (shell->priv->light) {
/* Implement plain message view */
@@ -1111,9 +1158,13 @@ mfv_message_activated (GtkTreeView *tree_view, GtkTreePath *path, G
GPtrArray *msgs = em_tree_store_get_child_sorted_tree ((EMTreeStore *)shell->model, &iter);
/* FIXME: Handle 'Sent' messages */
- mail_conv_view_set_thread (shell->mail, shell->priv->folder, msgs);
+ if (!outgoing)
+ mail_conv_view_set_thread (shell->mail, shell->priv->folder, msgs);
+ else
+ mfv_open_composer(shell, msgs->pdata[0]);
}
- g_signal_emit (shell, signals[MESSAGE_SHOWN], 0);
+ if (!outgoing)
+ g_signal_emit (shell, signals[MESSAGE_SHOWN], 0);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]