[anjal/inline-composer-quotes] Fix the hunk that broke New Mail. Also clean up the inline composer code as per the review comments.



commit 51c5a59387591db5211cd0898987fc0d3129dc2e
Author: Bharath Acharya <abharath novell com>
Date:   Wed Apr 8 12:20:54 2009 +0530

    Fix the hunk that broke New Mail. Also clean up the inline composer code as per the review comments.
---
 src/e-composer-header-table.c |    3 +-
 src/e-msg-composer.c          |    4 +-
 src/e-msg-composer.h          |    2 +-
 src/mail-conv-view.c          |   12 +++++++++++
 src/mail-editor.c             |   21 ++++++------------
 src/mail-message-view.c       |   45 ++++++++++++++++++++++++++++++++++------
 src/mail-message-view.h       |    1 +
 7 files changed, 63 insertions(+), 25 deletions(-)

diff --git a/src/e-composer-header-table.c b/src/e-composer-header-table.c
index 1f02318..f0ac312 100644
--- a/src/e-composer-header-table.c
+++ b/src/e-composer-header-table.c
@@ -236,7 +236,7 @@ composer_header_table_constructor (GType type,
 
 	/*Add the actions container.*/
 
-	for (ii = rows -1; ii > 0; ii--) {
+	for (ii = 0; ii < rows; ii++) {
 		if (priv->headers [ii] != NULL) {
 			gtk_table_attach (GTK_TABLE (object), priv->headers[ii]->title_widget,
 					  0, 1, ii, ii + 1, GTK_FILL, GTK_FILL, 0, 3);
@@ -244,6 +244,7 @@ composer_header_table_constructor (GType type,
 					  1, 4, ii, ii + 1, GTK_FILL | GTK_EXPAND, 0, 0, 3);
 
 			if (priv->headers [ii]->action_widget) {
+				/* Pack the widgets to the end. Helps formatting when hiding the From field */
 				gtk_box_pack_end (priv->actions_container, priv->headers[ii]->action_widget,
 						    FALSE, FALSE, 6);
 			}
diff --git a/src/e-msg-composer.c b/src/e-msg-composer.c
index b09c26b..83d364d 100644
--- a/src/e-msg-composer.c
+++ b/src/e-msg-composer.c
@@ -1171,7 +1171,7 @@ em_utils_camel_address_to_destination (CamelInternetAddress *iaddr)
 }
 
 gpointer
-reply_to_message (struct _CamelFolder *f, const char *uid, struct _CamelMimeMessage *message, int mode, struct _EMFormat *source)
+e_msg_composer_reply (struct _CamelFolder *f, const char *uid, struct _CamelMimeMessage *message, int mode, struct _EMFormat *source)
 {
 	EMsgComposer *composer;
 	EComposerHeaderTable *table;
@@ -1190,7 +1190,7 @@ reply_to_message (struct _CamelFolder *f, const char *uid, struct _CamelMimeMess
 	
 	text = em_utils_construct_composer_text (message, source);
 	mail_editor_set_text_html (editor, text, strlen (text));
-
+	
 	table = e_msg_composer_get_header_table (composer);
 
 	switch (mode) {
diff --git a/src/e-msg-composer.h b/src/e-msg-composer.h
index 907a810..8f0bd4e 100644
--- a/src/e-msg-composer.h
+++ b/src/e-msg-composer.h
@@ -99,7 +99,7 @@ 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, 
+gpointer 	e_msg_composer_reply		(struct _CamelFolder *f, 
 						const char *uid, struct _CamelMimeMessage *message, 
 						int mode, struct _EMFormat *source);
 
diff --git a/src/mail-conv-view.c b/src/mail-conv-view.c
index f9f699e..f551b0c 100644
--- a/src/mail-conv-view.c
+++ b/src/mail-conv-view.c
@@ -272,6 +272,17 @@ mcv_message_removed (MailMessageView *mmv, MailConvView *mcv)
 		g_warning ("Unable to find the deleted  mail in conversation\n");
 }
 
+static void
+mcv_message_reply (MailMessageView *mmv, MailConvView *mcv)
+{
+	int x, y, height, ret;
+	GtkAdjustment *adj = gtk_viewport_get_vadjustment(mcv->priv->viewport);
+
+	ret = gtk_widget_translate_coordinates (mmv->footer, mmv->comp_view, 0, 0, &x, &y);
+//	height = ((GtkContainer *)mmv->comp_view)->focus_child->allocation.height;
+	gtk_adjustment_clamp_page (adj, y, y+600);
+}
+
 void
 mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *array)
 {
@@ -304,6 +315,7 @@ mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *ar
 		mail_message_view_set_message (child, folder, array->pdata[i]);
 		g_signal_connect (child, "message-selected", G_CALLBACK(mcv_message_selected), mcv);
 		g_signal_connect (child, "message-removed", G_CALLBACK(mcv_message_removed), mcv);
+		g_signal_connect (child, "message-reply", G_CALLBACK(mcv_message_reply), mcv);
 		focus = g_list_prepend (focus, mail_message_view_get_focus_widget(child));
 	}
 
diff --git a/src/mail-editor.c b/src/mail-editor.c
index 8e00699..76aa5dc 100644
--- a/src/mail-editor.c
+++ b/src/mail-editor.c
@@ -367,20 +367,15 @@ mail_editor_run_command (MailEditor *editor, gchar *command)
 	
 }
 
-static gboolean
-key_press_cb (GtkWidget *w, GdkEventKey *event, gpointer web)
+WebKitWebView *
+mail_editor_get_webview (MailEditor *editor)
 {
-	gpointer frame = webkit_web_view_get_main_frame (web);
+	MailEditorPrivate *priv;
+
+	g_return_val_if_fail (IS_MAIL_EDITOR (editor), NULL);
 	
-	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;	
+	priv = MAIL_EDITOR_GET_PRIVATE (editor);
+	return priv->editor;
 }
 
 void
@@ -393,11 +388,9 @@ mail_editor_set_text_html (MailEditor *editor, gchar *text, gint length)
 
 	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, "");
 }
 
-
 gchar*
 mail_editor_get_html (MailEditor *editor, gsize *length)
 {
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 1e6d34f..79c498d 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -59,6 +59,7 @@ G_DEFINE_TYPE (MailMessageView, mail_message_view, GTK_TYPE_VBOX)
 enum {
 	MESSAGE_SELECTED,
 	MESSAGE_REMOVED,
+	MESSAGE_REPLY,
 	LAST_SIGNAL
 };
 
@@ -116,6 +117,14 @@ mail_message_view_class_init (MailMessageViewClass *klass)
 			      NULL, NULL,
 			      g_cclosure_marshal_VOID__VOID,
 			     G_TYPE_NONE, 0);
+	signals[MESSAGE_REPLY] =
+		g_signal_new ("message-reply",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (MailMessageViewClass , message_reply),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
 }
 
 static void
@@ -254,18 +263,37 @@ discard_composer_cb (GtkWidget *w, MailMessageView *mmv)
 	/* FIXME: Destroy the composer in here */
 }
 
+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;	
+}
+
 static void
 construct_reply_composer (MailMessageView *mmv, int mode)
 {
 	MailEditor *editor;
 	EComposerHeaderTable *table;
-
+	WebKitWebView *web_view;
+	
 	if (!E_IS_MSG_COMPOSER (mmv->comp_view)) {
-		mmv->comp_view = (EMsgComposer *)reply_to_message (NULL, NULL, mmv->priv->msg, mode, NULL);
+		mmv->comp_view = (EMsgComposer *)e_msg_composer_reply (NULL, NULL, mmv->priv->msg, mode, 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);
+		web_view = mail_editor_get_webview (editor);
+		g_signal_connect (web_view, "key-press-event", key_press_cb, web_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. 
@@ -281,7 +309,7 @@ construct_reply_composer (MailMessageView *mmv, int mode)
 	gtk_widget_show (mmv->frame);
 	gtk_widget_show (mmv->comp_view);
 
-	/* Need to handle individual cases for Reply, Reply All and Forward */
+	g_signal_emit (mmv, signals[MESSAGE_REPLY], 0);
 }
 
 static void
@@ -745,7 +773,10 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	mmview->footer = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start (mmview, mmview->footer, FALSE, FALSE, 0);
 	
-	str = g_strdup_printf ("Reply to %s", *strv);
+	/* To translators: Reply to the sender. The format is replaced by the 
+	   name of the sender.
+	*/
+	str = g_strdup_printf (_("Reply to %s"), *strv);
 	reply = gtk_button_new_with_label (str);
 	g_free (str);
 	g_strfreev(strv);
@@ -753,17 +784,17 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 //	EXPOSE(reply, bgcolor);
 	gtk_box_pack_start (mmview->footer, reply, FALSE, FALSE, 12);
 
-	reply_all = gtk_button_new_with_label ("Reply All");
+	reply_all = gtk_button_new_with_label (_("Reply All"));
 	g_signal_connect (reply_all, "clicked", G_CALLBACK (invoke_reply_all_composer_cb), mmview);
 //	EXPOSE(reply_all, bgcolor);
 	gtk_box_pack_start (mmview->footer, reply_all, FALSE, FALSE, 12);
 
-	forward = gtk_button_new_with_label ("Forward");
+	forward = gtk_button_new_with_label (_("Forward"));
 	g_signal_connect (forward, "clicked", G_CALLBACK (invoke_forward_composer_cb), mmview);	
 //	EXPOSE(forward, bgcolor);
 	gtk_box_pack_start (mmview->footer, forward, FALSE, FALSE, 12);
 
-	mmview->discard = gtk_button_new_with_label ("Discard");
+	mmview->discard = gtk_button_new_with_label (_("Discard"));
 	g_signal_connect (mmview->discard, "clicked", G_CALLBACK (discard_composer_cb), mmview);
 //	EXPOSE(discard, bgcolor);
 	/* Hide this one be default */
diff --git a/src/mail-message-view.h b/src/mail-message-view.h
index d0ab795..bf2cd6a 100644
--- a/src/mail-message-view.h
+++ b/src/mail-message-view.h
@@ -62,6 +62,7 @@ typedef struct _MailMessageViewClass {
 
 	void (*message_selected) (MailMessageView *);
 	 void (*message_removed) (MailMessageView *);
+	 void (*message_reply)	 (MailMessageView *);
 } MailMessageViewClass;
 
 MailMessageView * mail_message_view_new (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]