[anjal] Make messsage windows unique.



commit 7305320cc2d0efdab3ab798ee686881dd7cb0e55
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Tue Apr 21 18:11:29 2009 +0530

    Make messsage windows unique.
---
 src/mail-folder-view.c |   34 ++++++++++++++++++++++++----------
 src/mail-folder-view.h |    6 +++---
 src/mail-view.c        |   35 ++++++++++++++++++++++++++++++-----
 3 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 960e2f1..44c3844 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -30,6 +30,7 @@
 #include "mail/em-popup.h"
 #include "mail/mail-mt.h"
 #include "mail/mail-ops.h"
+#include "mail/em-marshal.h"
 #include "misc/e-spinner.h"
 #include "mail-sqlite-store.h"
 #include "em-tree-store.h"
@@ -450,8 +451,8 @@ mail_folder_view_class_init (MailFolderViewClass *klass)
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (MailFolderViewClass , message_new),
 			      NULL, NULL,
-			      g_cclosure_marshal_VOID__POINTER,
-			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+			      em_marshal_VOID__POINTER_POINTER,
+			      G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
 
 	mail_folder_view_parent_class = g_type_class_peek_parent (klass);
 	object_class->finalize = mail_folder_view_finalize;	
@@ -852,14 +853,20 @@ mfv_popup_open_new_tab (EPopup *ep, EPopupItem *pitem, void *data)
 	 GtkTreeIter iter;
 	 GPtrArray *uids;	 
 	 GtkTreeSelection *sel = gtk_tree_view_get_selection (mfv->tree);
-	 
+	 char *umid;
+
 	 gtk_tree_selection_get_selected (sel, NULL, &iter);
+	 uids = em_tree_store_get_child_sorted_tree (mfv->model, &iter);
+	
+	 if (!uids || uids->len <= 0)
+		 return;
+
+	 umid = g_strdup_printf("message://%s/%s", mfv->priv->folder->full_name, uids->pdata[0]);
 
-	 g_signal_emit (mfv, signals[MESSAGE_NEW], 0, &mcv);
+	 g_signal_emit (mfv, signals[MESSAGE_NEW], 0, &mcv, umid);
 	 if (!mcv)
-		  return FALSE;
-	 
-	 uids = em_tree_store_get_child_sorted_tree (mfv->model, &iter);
+		  return;
+
 	 mail_conv_view_set_thread (mcv, mfv->priv->folder, uids);
 }
 
@@ -991,12 +998,19 @@ mfv_button_clicked (GtkWidget *w, GdkEventButton *event, MailFolderView *mfv)
 		GtkTreeIter iter;
 		GPtrArray *uids;
 
-		g_signal_emit (mfv, signals[MESSAGE_NEW], 0, &mcv);
-		if (!mcv)
-			return FALSE;
 		if (gtk_tree_view_get_path_at_pos (mfv->tree, event->x, event->y, &path, NULL, NULL, NULL)) {
 			if (gtk_tree_model_get_iter (mfv->model, &iter, path)) {
+				char *umid = NULL;
+
 				uids = em_tree_store_get_child_sorted_tree (mfv->model, &iter);
+				if (uids && uids->len >0) {
+					umid = g_strdup_printf("message://%s/%s\n", mfv->priv->folder->full_name, uids->pdata[0]);
+					g_signal_emit (mfv, signals[MESSAGE_NEW], 0, &mcv, umid);
+					g_free(umid);
+
+					if (!mcv)
+						return TRUE;
+				}
 				mail_conv_view_set_thread (mcv, mfv->priv->folder, uids);
 			}
 			gtk_tree_path_free(path);
diff --git a/src/mail-folder-view.h b/src/mail-folder-view.h
index 21909ea..8c8d884 100644
--- a/src/mail-folder-view.h
+++ b/src/mail-folder-view.h
@@ -58,9 +58,9 @@ typedef struct _MailFolderView {
 typedef struct _MailFolderViewClass {
 	GtkVBoxClass parent_class;
  
-	void (* message_shown) (MailConvView *);
-	void (* view_close) (MailConvView *);
-	void (* message_new) (MailConvView *, gpointer);
+	void (*message_shown) (MailConvView *);
+	void (*view_close) (MailConvView *);
+	void (*message_new) (MailConvView *, gpointer, gpointer);
 } MailFolderViewClass;
 
 MailFolderView * mail_folder_view_new (void);
diff --git a/src/mail-view.c b/src/mail-view.c
index 23c27d6..d29d141 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -43,7 +43,8 @@ struct  _MailViewPrivate {
 #undef MV_NEW_TAB
 
 G_DEFINE_TYPE (MailView, mail_view, GTK_TYPE_NOTEBOOK)
-	 
+static MailConvView * mv_switch_message_view (MailView *mv, const char *uri);
+
 static void
 mail_view_init (MailView  *shell)
 {
@@ -104,7 +105,6 @@ mv_switch (GtkNotebook     *notebook,GtkNotebookPage *page, guint page_num, gpoi
 		else
 			 priv->current_view = node->data;
 		child = (MailViewChild *)priv->current_view;
-
 		if (child->type == MAIL_VIEW_COMPOSER)
 			 mail_composer_view_activate (child, shell->folder_tree, shell->check_mail, shell->sort_by, TRUE);
 		else if (child->type == MAIL_VIEW_MESSAGE)
@@ -235,9 +235,14 @@ mv_close_mcv (MailFolderView *mfv, MailView *mv)
 }
 
 static void
-mv_message_new (MailFolderView *mfv, gpointer data, MailView *mv)
+mv_message_new (MailFolderView *mfv, gpointer data, char *umid, MailView *mv)
 {
-	*(MailConvView **)data = (MailConvView *)mail_view_add_page (mv, MAIL_VIEW_MESSAGE);
+	MailConvView *conv = (MailConvView *)mv_switch_message_view(mv, umid);
+	*(MailConvView **)data = conv;
+	
+	if (conv)
+		conv->uri = g_strdup(umid);
+
 	return;
 }
 
@@ -320,6 +325,7 @@ mail_view_add_page (MailView *mv, guint16 type)
 		break;
 	case MAIL_VIEW_MESSAGE:
 		child = mail_view_add_message (mv);
+
 		break;
 	}
 	gtk_widget_grab_focus(child);
@@ -340,7 +346,7 @@ mv_switch_folder_view (MailView *mv, const char *uri)
 	 GList *tmp = mv->priv->children;
 	 while (tmp) {
 		  MailViewChild *child = tmp->data;
-		  if (child->type = MAIL_VIEW_FOLDER && !strcmp (uri, child->uri)) {
+		  if (child->type == MAIL_VIEW_FOLDER && !strcmp (uri, child->uri)) {
 			   gtk_notebook_set_current_page (mv, i);
 			   return;
 		  }
@@ -352,6 +358,25 @@ mv_switch_folder_view (MailView *mv, const char *uri)
 	 mail_folder_view_set_folder_uri (mv->priv->current_view, uri);
 }
 
+static MailConvView *
+mv_switch_message_view (MailView *mv, const char *uri)
+{
+	 int i=0;
+	 GList *tmp = mv->priv->children;
+	 while (tmp) {
+		  MailViewChild *child = tmp->data;
+		  if (child->type == MAIL_VIEW_MESSAGE && !strcmp (uri, child->uri)) {
+			   gtk_notebook_set_current_page (mv, i);
+			   mail_conv_view_activate (child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
+			   return NULL;
+		  }
+		  i++;
+		  tmp = tmp->next;
+	 }
+
+	 return mail_view_add_page (mv, MAIL_VIEW_MESSAGE);
+}
+
 void
 mail_view_set_folder_uri (MailView *mv, const char *uri)
 {



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