[anjal/inline-composer-quotes] Quoting support for inline reply
- From: Bharath Acharya <abharath src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal/inline-composer-quotes] Quoting support for inline reply
- Date: Thu, 26 Mar 2009 03:44:33 -0400 (EDT)
commit 6624faa752315bca714e2abe1bd4a868ff424810
Author: Bharath Acharya <abharath novell com>
Date: Wed Mar 25 14:35:15 2009 +0530
Quoting support for inline reply
---
src/e-msg-composer.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++
src/e-msg-composer.h | 5 +++
src/mail-editor.c | 38 +++++++++++++++++++--
src/mail-message-view.c | 44 ++++++++++++++++--------
src/mail-message-view.h | 2 +
5 files changed, 155 insertions(+), 19 deletions(-)
diff --git a/src/e-msg-composer.c b/src/e-msg-composer.c
index a2fb7d6..16cf979 100644
--- a/src/e-msg-composer.c
+++ b/src/e-msg-composer.c
@@ -95,6 +95,7 @@
#include "mail/mail-session.h"
#include "mail/em-popup.h"
#include "mail/em-menu.h"
+#include "mail/em-format-quote.h"
#include "e-msg-composer.h"
#include "e-composer-header-table.h"
@@ -480,6 +481,20 @@ msg_composer_subject_changed_cb (EMsgComposer *composer)
gtk_window_set_title (GTK_WINDOW (composer), subject);
}
+
+gpointer
+e_msg_composer_get_mail_editor (EMsgComposer *composer)
+{
+ EMsgComposerPrivate *p;
+
+ if (!composer)
+ return NULL;
+
+ p = E_MSG_COMPOSER_GET_PRIVATE (composer);
+
+ return p->html_editor;
+}
+
enum {
UPDATE_AUTO_CC,
UPDATE_AUTO_BCC,
@@ -1120,10 +1135,80 @@ em_composer_prefs_new_signature (GtkWindow *parent,
{
}
+static EDestination **
+em_utils_camel_address_to_destination (CamelInternetAddress *iaddr)
+{
+ EDestination *dest, **destv;
+ int n, i, j;
+
+ if (iaddr == NULL)
+ return NULL;
+
+ if ((n = camel_address_length ((CamelAddress *) iaddr)) == 0)
+ return NULL;
+
+ destv = g_malloc (sizeof (EDestination *) * (n + 1));
+ for (i = 0, j = 0; i < n; i++) {
+ const char *name, *addr;
+
+ if (camel_internet_address_get (iaddr, i, &name, &addr)) {
+ dest = e_destination_new ();
+ e_destination_set_name (dest, name);
+ e_destination_set_email (dest, addr);
+
+ destv[j++] = dest;
+ }
+ }
+
+ if (j == 0) {
+ g_free (destv);
+ return NULL;
+ }
+
+ destv[j] = NULL;
+
+ return destv;
+}
+
+gpointer
+reply_to_message (struct _CamelFolder *f, const char *uid, struct _CamelMimeMessage *message, int mode, struct _EMFormat *source)
+{
+ EMsgComposer *composer;
+ EComposerHeaderTable *table;
+ MailEditor *editor;
+ char *text;
+ CamelInternetAddress *to, *cc;
+ EDestination **tov, **ccv;
+
+ composer = e_msg_composer_new ();
+ editor = e_msg_composer_get_mail_editor(composer);
+
+ to = camel_internet_address_new();
+ cc = camel_internet_address_new();
+
+ text = em_utils_construct_composer_text (message, source);
+ mail_editor_set_text_html (editor, text, strlen (text));
+
+ em_utils_get_reply_sender (message, to, NULL);
+
+ tov = em_utils_camel_address_to_destination (to);
+// g_print ("\n %s is the address********\n", e_destination_get_address(tov[0]));
+ ccv = em_utils_camel_address_to_destination (cc);
+
+ table = e_msg_composer_get_header_table (composer);
+ e_composer_header_table_set_destinations_to (table, tov);
+ e_composer_header_table_set_destinations_cc (table, ccv);
+
+ g_free (text);
+ return composer;
+}
+
+/*
void
em_utils_reply_to_message (struct _CamelFolder *f, const char *uid, struct _CamelMimeMessage *message, int mode, struct _EMFormat *source)
{
}
+*/
void
em_utils_compose_new_message_with_mailto (const char *url, const char *fromuri)
{
diff --git a/src/e-msg-composer.h b/src/e-msg-composer.h
index 67b2214..907a810 100644
--- a/src/e-msg-composer.h
+++ b/src/e-msg-composer.h
@@ -98,6 +98,11 @@ EMsgComposer * e_msg_composer_new_from_url (const gchar *url);
EMsgComposer * e_msg_composer_new_redirect (CamelMimeMessage *message,
const gchar *resent_from);
+gpointer e_msg_composer_get_mail_editor (EMsgComposer *composer);
+gpointer reply_to_message (struct _CamelFolder *f,
+ const char *uid, struct _CamelMimeMessage *message,
+ int mode, struct _EMFormat *source);
+
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
diff --git a/src/mail-editor.c b/src/mail-editor.c
index edb41e2..8e00699 100644
--- a/src/mail-editor.c
+++ b/src/mail-editor.c
@@ -26,7 +26,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>
-
+#include <gdk/gdkkeysyms.h>
#define MAIL_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MAIL_EDITOR_TYPE, MailEditorPrivate))
@@ -296,10 +296,16 @@ mail_editor_init(MailEditor *editor)
{
MailEditorPrivate *priv;
gchar *index_html;
+ GtkWidget *scroller, *vbox;
priv = MAIL_EDITOR_GET_PRIVATE (editor);
priv->editor = webkit_web_view_new ();
+ scroller = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroller), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
/*Dummy html doc*/
index_html = "<html><body></body></html>";
@@ -314,9 +320,13 @@ mail_editor_init(MailEditor *editor)
priv->toolbar = mail_editor_construct_html_toolbar (editor);
gtk_widget_show_all (priv->toolbar);
- gtk_box_pack_start (GTK_CONTAINER (editor), priv->toolbar, FALSE, TRUE, 6);
- gtk_box_pack_start (GTK_CONTAINER (editor), priv->editor, TRUE, TRUE, 2);
-
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_start (vbox, priv->toolbar, FALSE, TRUE, 6);
+ gtk_box_pack_start (vbox, scroller, TRUE, TRUE, 2);
+ gtk_container_add (scroller, priv->editor);
+ gtk_widget_show (scroller);
+ gtk_container_add (GTK_CONTAINER (editor), vbox);
+ gtk_widget_show (vbox);
}
gchar *
@@ -357,14 +367,34 @@ mail_editor_run_command (MailEditor *editor, gchar *command)
}
+static gboolean
+key_press_cb (GtkWidget *w, GdkEventKey *event, gpointer web)
+{
+ gpointer frame = webkit_web_view_get_main_frame (web);
+
+ switch (event->keyval) {
+ case GDK_Return:
+ case GDK_KP_Enter:
+ if (!webkit_web_frame_is_cursor_at_blockquote (frame))
+ return FALSE;
+ webkit_web_frame_break_quote (frame);
+ return TRUE;
+ }
+ return FALSE;
+}
+
void
mail_editor_set_text_html (MailEditor *editor, gchar *text, gint length)
{
MailEditorPrivate *priv;
+ WebKitWebFrame* frame;
g_return_val_if_fail (IS_MAIL_EDITOR (editor), NULL);
priv = MAIL_EDITOR_GET_PRIVATE (editor);
+ frame = webkit_web_view_get_main_frame (priv->editor);
+ g_signal_connect (priv->editor, "key-press-event", key_press_cb, priv->editor);
+ webkit_web_frame_load_string (frame, text, NULL, NULL, "");
}
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 38303ce..8d20dbe 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -32,6 +32,7 @@
#include "misc/e-spinner.h"
#include <gdk/gdkkeysyms.h>
#include "e-util/e-icon-factory.h"
+#include "mail/em-composer-utils.h"
extern char *scolor_norm;
extern char *scolor_sel;
@@ -43,6 +44,7 @@ struct _MailMessageViewPrivate {
const char *uid;
GtkWidget *arrow;
GtkWidget *focus;
+// GtkWidget *focus_composer;
CamelMimeMessage *msg;
CamelMessageInfoBase *info;
GtkWidget *header_row;
@@ -169,6 +171,7 @@ mmv_show (MailMessageView *mmv)
}
gtk_widget_show (mmv->body);
gtk_widget_show_all (mmv->footer);
+ gtk_widget_hide (mmv->discard);
gtk_arrow_set (mmv->priv->arrow, GTK_ARROW_DOWN, GTK_SHADOW_NONE);
}
@@ -246,19 +249,34 @@ discard_composer_cb (GtkWidget *w, MailMessageView *mmv)
{
gtk_widget_hide (mmv->frame);
gtk_widget_hide (mmv->comp_view);
+ gtk_widget_hide (mmv->discard);
/* FIXME: Destroy the composer in here */
}
static void
invoke_composer_cb (GtkWidget *w, MailMessageView *mmv)
{
- /* All this should be moved to the composer code, if we intend to hide the headers
- for making the inline composer more sleek */
-// EComposerHeaderTable *table = e_msg_composer_get_header_table (E_MSG_COMPOSER(mmv->comp_view));
-// e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_FROM, FALSE);
-// e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_TO, FALSE);
-// e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_SUBJECT, FALSE);
+ MailEditor *editor;
+ EComposerHeaderTable *table;
+ if (!E_IS_MSG_COMPOSER (mmv->comp_view)) {
+ mmv->comp_view = (EMsgComposer *)reply_to_message (NULL, NULL, mmv->priv->msg, 0, NULL);
+ gtk_widget_set_size_request (mmv->comp_view, -1, 480);
+
+ /* Trying to focus on the editor */
+ editor = e_msg_composer_get_mail_editor (mmv->comp_view);
+
+ /* Hide most of the basic headers. We'll add an option for enabling them later.
+ Our objective is to make the inline composer as sleek as it can get.
+ */
+ table = e_msg_composer_get_header_table (mmv->comp_view);
+ e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_FROM, FALSE);
+// e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_TO, FALSE);
+ e_composer_header_table_set_header_visible (table, E_COMPOSER_HEADER_SUBJECT, FALSE);
+ gtk_container_add (mmv->frame, mmv->comp_view);
+ gtk_box_pack_start (mmv, mmv->frame, FALSE, FALSE, 18);
+ }
+ gtk_widget_show (mmv->discard);
gtk_widget_show (mmv->frame);
gtk_widget_show (mmv->comp_view);
@@ -726,19 +744,15 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
// EXPOSE(forward, bgcolor);
gtk_box_pack_start (mmview->footer, forward, FALSE, FALSE, 12);
- discard = gtk_link_button_new_with_label ("Discard", "Discard");
- g_signal_connect (discard, "clicked", G_CALLBACK (discard_composer_cb), mmview);
+ mmview->discard = gtk_link_button_new_with_label ("Discard", "Discard");
+ g_signal_connect (mmview->discard, "clicked", G_CALLBACK (discard_composer_cb), mmview);
// EXPOSE(discard, bgcolor);
- gtk_box_pack_end (mmview->footer, discard, FALSE, FALSE, 12);
+ /* Hide this one be default */
+ gtk_widget_hide (mmview->discard);
+ gtk_box_pack_end (mmview->footer, mmview->discard, FALSE, FALSE, 12);
mmview->frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (mmview->frame, GTK_SHADOW_IN);
-
- mmview->comp_view = e_msg_composer_new ();
- gtk_widget_set_size_request (mmview->comp_view, -1, 480);
- gtk_container_add (mmview->frame, mmview->comp_view);
- gtk_box_pack_start (mmview, mmview->frame, FALSE, FALSE, 18);
- gtk_widget_hide (mmview->comp_view);
if (!(info->flags & CAMEL_MESSAGE_SEEN))
mmv_show(mmview);
diff --git a/src/mail-message-view.h b/src/mail-message-view.h
index de030ef..d0ab795 100644
--- a/src/mail-message-view.h
+++ b/src/mail-message-view.h
@@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include "em-format-webkit-display.h"
+#include "e-msg-composer.h"
#define MAIL_MESSAGE_VIEW_TYPE (mail_message_view_get_type ())
#define MAIL_MESSAGE_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_MESSAGE_VIEW_TYPE, MailFolderView))
@@ -50,6 +51,7 @@ typedef struct _MailMessageView {
GtkWidget *footer;
GtkWidget *frame;
GtkWidget *comp_view;
+ GtkWidget *discard;
MailMessageViewPrivate *priv;
EMFormatWebKitDisplay *efwd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]