[anjal] Code drop for anjal to compile evo 2.30 (anjal-evo-2-30)



commit 0a5af51b3bc604450bf7bc8af7e65cdbb9be8660
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Mon Nov 30 00:20:47 2009 +0530

    Code drop for anjal to compile evo 2.30 (anjal-evo-2-30)

 configure.ac                 |    8 +-
 src/Makefile.am              |   33 ++--
 src/em-format-mail-display.c |   48 ++++--
 src/em-format-mail.c         |   50 +++--
 src/em-format-mail.h         |    8 +-
 src/mail-account-view.c      |   24 ++--
 src/mail-decoration.c        |    1 -
 src/mail-float-bar.c         |   24 +--
 src/mail-folder-view.c       |   77 ++++----
 src/mail-message-view.c      |   17 +-
 src/mail-settings-view.c     |   13 +-
 src/mail-shell.c             |  420 +++++++++++++++++++++++++++++++++++------
 src/mail-shell.h             |   11 +-
 src/mail-view.c              |   72 +++++--
 src/mail-view.h              |   15 +-
 src/main.c                   |  232 +++++++++++++++---------
 16 files changed, 748 insertions(+), 305 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3e4f163..a60e729 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,12 @@ AC_SUBST(imagesdir)
 
 evolutioncomponentdir=`pkg-config --variable=componentdir evolution-shell`
 AC_SUBST(evolutioncomponentdir)
+evolutionmoduledir=`pkg-config --variable=moduledir evolution-shell`
+AC_SUBST(evolutionmoduledir)
+evolutionprivdir=`pkg-config --variable=privlibdir evolution-shell`
+AC_SUBST(evolutionprivdir)
+
+
 
 evolutiondatadir=`pkg-config --variable=datadir evolution-shell`
 AC_SUBST(evolutiondatadir)
@@ -47,7 +53,7 @@ AM_PROG_LIBTOOL
 
 
 
-PKG_CHECK_MODULES(ANJAL, [gtk+-2.0 >= 2.8 libglade-2.0 >= 2.6.0 glib-2.0 gconf-2.0 libedataserver-1.2 libedataserverui-1.2 libebook-1.2 camel-1.2 evolution-shell >= 2.27.5 evolution-plugin libxml-2.0 sqlite3 libgtkhtml-3.14 gtkhtml-editor])
+PKG_CHECK_MODULES(ANJAL, [gtk+-2.0 >= 2.8 libglade-2.0 >= 2.6.0 glib-2.0 gconf-2.0 libedataserver-1.2 libedataserverui-1.2 libebook-1.2 camel-1.2 evolution-shell >= 2.27.5 evolution-plugin libxml-2.0 sqlite3 libgtkhtml-3.14 gtkhtml-editor dbus-1])
 EVO_VERSION="`$PKG_CONFIG --variable=execversion evolution-shell`"
 
 if test "x$EVO_VERSION" = "x2.26"; then
diff --git a/src/Makefile.am b/src/Makefile.am
index 72dec27..7920ce5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
 	-DEVOLUTION226_PRIVDATADIR=\""$(evolutiondatadir)/evolution/2.26/"\" \
 	-DEVOLUTION228_PRIVDATADIR=\""$(evolutiondatadir)/evolution/2.28/"\" \
 	-DANJAL_IMAGEDIR=\""$(datadir)/anjal/images/"\" \
+	-DANJAL_MODULEDIR=\""$(evolutionprivdir)/anjal/"\" \
 	$(ANJAL_CFLAGS)	-I. \
 	$(MOZILLA_CFLAGS) \
 	$(WEBKIT_CFLAGS) \
@@ -24,14 +25,14 @@ anjal_SOURCES = \
 	main.c \
 	mail-shell.c \
 	mail-shell.h \
-	mail-component.c \
-	mail-component.h \
-	mail-sqlite-store.c \
-	mail-sqlite-store.h \
+	mail-decoration.c \
+	mail-decoration.h \
 	mail-view.c \
 	mail-view.h \
 	mail-folder-view.c \
 	mail-folder-view.h \
+	mail-sqlite-store.c \
+	mail-sqlite-store.h \
 	mail-composer-view.c \
 	mail-composer-view.h \
 	custom-cell-renderer-hbox.c \
@@ -47,19 +48,11 @@ anjal_SOURCES = \
 	mail-message-view.c \
 	mail-message-view.h \
 	mail-message-view.h \
-	em-format-webkit.c \
-	em-format-webkit.h \
-	em-format-webkit-display.c \
-	em-format-webkit-display.h \
 	gconf-bridge.h \
 	mail-account-view.c \
 	mail-account-view.h \
 	mail-settings-view.c \
 	mail-settings-view.h \
-	mail-search.c \
-	mail-search.h \
-	mail-decoration.c \
-	mail-decoration.h \
 	mail-utils.c	\
 	mail-utils.h	\
 	em-format-mail.c \
@@ -69,6 +62,15 @@ anjal_SOURCES = \
 	mail-float-bar.c \
 	mail-float-bar.h
 
+#	mail-search.c \
+#	mail-search.h \
+#	mail-component.c \
+#	mail-component.h 
+#	em-format-webkit.c \
+#	em-format-webkit.h \
+#	em-format-webkit-display.c \
+#	em-format-webkit-display.h 
+
 if ENABLE_WEBKIT
 anjal_SOURCES += em-webkit-stream.c \
 		 em-webkit-stream.h 
@@ -97,8 +99,11 @@ anjal_LDADD = $(ANJAL_LIBS) \
 	$(ANERLEY_LIBS) \
 	-lemiscwidgets \
 	-lfilter \
-	-lefilterbar \
-	-L$(evolutioncomponentdir) -levolution-mail-shared $(MOZ_ADD_LIBS)
+	-L"$(evolutionprivdir)/anjal" -levolution-module-anjal
+
+#-lefilterbar 
+	
+#-L$(evolutioncomponentdir) -levolution-mail-shared $(MOZ_ADD_LIBS)
 
 
 EXTRA_DIST = $(glade_DATA) \
diff --git a/src/em-format-mail-display.c b/src/em-format-mail-display.c
index c0a5fa8..e2364a4 100644
--- a/src/em-format-mail-display.c
+++ b/src/em-format-mail-display.c
@@ -73,10 +73,7 @@
 #include "misc/e-attachment-view.h"
 #include "mail/e-mail-attachment-bar.h"
 #include "em-format-mail-display.h"
-#include "mail/em-icon-stream.h"
 #include "mail/em-utils.h"
-#include "mail/em-popup.h"
-#include "misc/e-icon-entry.h"
 #include "misc/e-spinner.h"
 #include "mail-message-view.h"
 #include "mail-utils.h"
@@ -893,6 +890,7 @@ efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Came
 	}
 }
 
+#if 0
 static void
 efhd_image(EMFormatMail *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *handle)
 {
@@ -923,10 +921,11 @@ efhd_image(EMFormatMail *efh, CamelStream *stream, CamelMimePart *part, EMFormat
 	efwd_draw_in_main_thread ((EMFormatMailDisplay *)efh, pobject);
 	g_free(classid);
 }
-
+#endif
 /* ********************************************************************** */
 
 static EMFormatHandler type_builtin_table[] = {
+#if 0	
 	{ (gchar *) "image/gif", (EMFormatFunc)efhd_image },
 	{ (gchar *) "image/jpeg", (EMFormatFunc)efhd_image },
 	{ (gchar *) "image/png", (EMFormatFunc)efhd_image },
@@ -949,7 +948,7 @@ static EMFormatHandler type_builtin_table[] = {
 
 	{ (gchar *) "image/jpg", (EMFormatFunc)efhd_image },
 	{ (gchar *) "image/pjpeg", (EMFormatFunc)efhd_image },
-
+#endif
 	{ (gchar *) "x-evolution/message/prefix", (EMFormatFunc)efhd_message_prefix },
 	{ (gchar *) "x-evolution/message/post-header", (EMFormatFunc)efhd_message_add_bar }
 };
@@ -1119,10 +1118,29 @@ efwd_set_inline (struct _attach_puri *info)
 	m = mail_msg_new (&inline_render_info);
 	m->info = info;
 	mail_msg_unordered_push (m);
-	printf("Pushed %pn", info);
 }
 
+static void
+efhd_attachment_show(gpointer f, gpointer b, gpointer data)
+{
+	struct _attach_puri *info = data;
+
+	printf("show attachment button called %p:%d %d\n", info, info->shown, info->rendered);
+
+	if (info->shown) {
+		gtk_widget_hide (info->child_box);
+		info->shown = FALSE;
+	} else {
+		gtk_widget_show (info->child_box);
+		info->shown = TRUE;
+	}
 
+	if (!info->rendered && info->child_box) {
+		efwd_set_inline(info);
+		info->rendered = TRUE;
+	}
+}
+#if 0
 /* if it hasn't been processed yet, format the attachment */
 static void
 efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data)
@@ -1144,6 +1162,8 @@ efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data)
 		info->rendered = TRUE;
 	}
 }
+#endif
+#warning "handle epopup"
 
 static void
 efhd_attachment_button_expanded (GtkWidget *widget,
@@ -1155,6 +1175,7 @@ efhd_attachment_button_expanded (GtkWidget *widget,
 
 	efhd_attachment_show (NULL, NULL, info);
 }
+#if 0
 
 static void
 efhd_image_fit(EPopup *ep, EPopupItem *item, gpointer data)
@@ -1188,7 +1209,7 @@ efhd_menu_items_free(EPopup *ep, GSList *items, gpointer data)
 {
 	g_slist_free(items);
 }
-
+#endif
 static void
 efhd_popup_place_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
 {
@@ -1199,6 +1220,7 @@ efhd_popup_place_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpoi
 	*y += w->allocation.y;
 }
 
+#if 0
 static gboolean
 efhd_attachment_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri *info)
 {
@@ -1253,20 +1275,20 @@ efhd_attachment_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri *
 
 	return TRUE;
 }
-
+#endif
 static gboolean
 efhd_image_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri *info)
 {
 	if (event && event->button != 3)
 		return FALSE;
 
-	return efhd_attachment_popup(w, event, info);
+	//return efhd_attachment_popup(w, event, info);
 }
-
+#warning "handle attachment popup"
 static gboolean
 efhd_attachment_popup_menu(GtkWidget *w, struct _attach_puri *info)
 {
-	return efhd_attachment_popup(w, NULL, info);
+	//return efhd_attachment_popup(w, NULL, info);
 }
 
 /* ********************************************************************** */
@@ -1339,7 +1361,7 @@ efhd_drag_data_delete(GtkWidget *w, GdkDragContext *drag, EMFormatMailPObject *p
 		g_object_set_data((GObject *)w, "e-drag-uri", NULL);
 	}
 }
-
+#if 0
 static void
 efhd_write_icon_job(struct _EMFormatMailJob *job, gint cancelled)
 {
@@ -1496,7 +1518,7 @@ efhd_attachment_image(EMFormatMail *efh, GtkWidget *eb, EMFormatMailPObject *pob
 
 	return eb;
 }
-
+#endif
 static void
 efmd_attachment_save_handle_error (EAttachment *attachment,
                                 GAsyncResult *result,
diff --git a/src/em-format-mail.c b/src/em-format-mail.c
index 4b5bb73..047d426 100644
--- a/src/em-format-mail.c
+++ b/src/em-format-mail.c
@@ -152,6 +152,8 @@ efh_init(GObject *o)
 	guint32 rgb;
 
 	efh->priv = g_malloc0(sizeof(*efh->priv));
+	efh->show_photo = FALSE; /* Default photo isn't shown */
+	efh->local_only_photo = TRUE; /* Default photo isn't shown */
 
 	e_dlist_init(&efh->pending_object_list);
 	e_dlist_init(&efh->priv->pending_jobs);
@@ -278,7 +280,6 @@ em_format_mail_get_type(void)
 		//gchar *path;
 
 		/* Trigger creation of mail component. */
-		mail_component_peek ();
 
 		efh_parent = g_type_class_ref(em_format_get_type());
 		type = g_type_register_static(em_format_get_type(), "EMFormatMail", &info, 0);
@@ -1071,20 +1072,28 @@ emfh_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
 static void
 emfh_multipart_related_check(struct _EMFormatMailJob *job, gint cancelled)
 {
-	struct _EMFormatPURITree *ptree;
-	EMFormatPURI *puri, *purin;
 	gchar *oldpartid;
+	GList *link;
+	EMFormat *format;
 
 	if (cancelled)
 		return;
+	
+	format = EM_FORMAT (job->format);
 
 	d(printf(" running multipart/related check task\n"));
 	oldpartid = g_strdup(((EMFormat *)job->format)->part_id->str);
 
-	ptree = job->puri_level;
-	puri = (EMFormatPURI *)ptree->uri_list.head;
-	purin = puri->next;
-	while (purin) {
+	link = g_queue_peek_head_link (job->puri_level->data);
+	if (!link) {
+		g_string_printf (format->part_id, "%s", oldpartid);
+		g_free (oldpartid);
+		return;
+	}
+
+	while (link->next != NULL) {
+		EMFormatPURI *puri = link->data;
+
 		if (puri->use_count == 0) {
 			d(printf("part '%s' '%s' used '%d'\n", puri->uri?puri->uri:"", puri->cid, puri->use_count));
 			if (puri->func == emfh_write_related) {
@@ -1093,8 +1102,8 @@ emfh_multipart_related_check(struct _EMFormatMailJob *job, gint cancelled)
 			}
 			/* else it was probably added by a previous format this loop */
 		}
-		puri = purin;
-		purin = purin->next;
+
+		link = g_list_next (link);
 	}
 
 	g_string_printf(((EMFormat *)job->format)->part_id, "%s", oldpartid);
@@ -1199,6 +1208,7 @@ efh_image(EMFormatMail *efh, CamelStream *stream, CamelMimePart *part, EMFormatH
 }
 
 static EMFormatHandler type_builtin_table[] = {
+#if 0
 	{ (gchar *) "image/gif", (EMFormatFunc)efh_image },
 	{ (gchar *) "image/jpeg", (EMFormatFunc)efh_image },
 	{ (gchar *) "image/png", (EMFormatFunc)efh_image },
@@ -1214,6 +1224,7 @@ static EMFormatHandler type_builtin_table[] = {
 	{ (gchar *) "image/x-portable-graymap", (EMFormatFunc)efh_image },
 	{ (gchar *) "image/x-portable-pixmap", (EMFormatFunc)efh_image },
 	{ (gchar *) "image/x-xpixmap", (EMFormatFunc)efh_image },
+#endif	
 	{ (gchar *) "text/enriched", (EMFormatFunc)efh_text_enriched },
 	{ (gchar *) "text/plain", (EMFormatFunc)efh_text_plain },
 	{ (gchar *) "text/html", (EMFormatFunc)efh_text_html },
@@ -1226,10 +1237,10 @@ static EMFormatHandler type_builtin_table[] = {
 	/* This is where one adds those busted, non-registered types,
 	   that some idiot mailer writers out there decide to pull out
 	   of their proverbials at random. */
-
+#if 0
 	{ (gchar *) "image/jpg", (EMFormatFunc)efh_image },
 	{ (gchar *) "image/pjpeg", (EMFormatFunc)efh_image },
-
+#endif
 	/* special internal types */
 
 	{ (gchar *) "x-evolution/message/rfc822", (EMFormatFunc)efh_format_message }
@@ -1268,7 +1279,7 @@ static void
 efh_format_exec (struct _format_msg *m)
 {
 	struct _EMFormatMailJob *job;
-	struct _EMFormatPURITree *puri_level;
+	GNode *puri_level;
 	gint cancelled = FALSE;
 	CamelURL *base;
 
@@ -1874,7 +1885,6 @@ static void
 efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 {
 	EMFormat *emf = (EMFormat *) efh;
-	EMFormatHeader *h;
 	const gchar *charset;
 	CamelContentType *ct;
 	struct _camel_header_raw *header;
@@ -1964,7 +1974,6 @@ efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 		camel_stream_printf (stream, "<tr><td><table border=0 cellpadding=\"0\">\n");
 
 	/* dump selected headers */
-	h = (EMFormatHeader *)emf->header_list.head;
 	if (emf->mode == EM_FORMAT_ALLHEADERS) {
 		header = ((CamelMimePart *)part)->headers;
 		while (header) {
@@ -1972,8 +1981,12 @@ efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 			header = header->next;
 		}
 	} else {
+		GList *link;
 		gint mailer_shown = FALSE;
-		while (h->next) {
+
+		link = g_queue_peek_head_link (&emf->header_list);
+		while (link != NULL) {
+			EMFormatHeader *h = link->data;
 			gint mailer, face;
 
 			header = ((CamelMimePart *)part)->headers;
@@ -1981,7 +1994,7 @@ efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 			face = !g_ascii_strcasecmp (h->name, "Face");
 
 			while (header) {
-				if (emf->show_photo && !photo_name && !g_ascii_strcasecmp (header->name, "From"))
+				if (efh->show_photo&& !photo_name && !g_ascii_strcasecmp (header->name, "From"))
 					photo_name = header->value;
 
 				if (!mailer_shown && mailer && (!g_ascii_strcasecmp (header->name, "X-Mailer") ||
@@ -2029,7 +2042,7 @@ efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 
 				header = header->next;
 			}
-			h = h->next;
+			link = g_list_next (link);
 		}
 	}
 
@@ -2042,7 +2055,7 @@ efh_format_headers(EMFormatMail *efh, CamelStream *stream, CamelMedium *part)
 
 			cia = camel_internet_address_new();
 			camel_address_decode((CamelAddress *) cia, (const gchar *) photo_name);
-			photopart = em_utils_contact_photo (cia, emf->photo_local);
+			photopart = em_utils_contact_photo (cia, efh->local_only_photo);
 
 			if (photopart) {
 				contact_has_photo = TRUE;
@@ -2174,7 +2187,6 @@ static void efh_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart
 static void
 efh_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type, const EMFormatHandler *handle)
 {
-	gchar *text, *html;
 #if 0
 	/* we display all inlined attachments only */
 
diff --git a/src/em-format-mail.h b/src/em-format-mail.h
index f2b167d..43721d5 100644
--- a/src/em-format-mail.h
+++ b/src/em-format-mail.h
@@ -29,7 +29,7 @@
 #ifndef EM_FORMAT_MAIL_H
 #define EM_FORMAT_MAIL_H
 
-#include <mail/em-format.h>
+#include <em-format/em-format.h>
 #include <mail/mail-config.h>
 #include <camel/camel-medium.h>
 #include <camel/camel-mime-part.h>
@@ -37,7 +37,7 @@
 #include <camel/camel-url.h>
 
 #include "mail-message-view.h"
-
+#include <libedataserver/e-msgport.h>
 /* Standard GObject macros */
 #define EM_TYPE_FORMAT_MAIL \
 	(em_format_mail_get_type ())
@@ -121,7 +121,7 @@ struct _EMFormatMailJob {
 
 	/* We need to track the state of the visibility tree at
 	   the point this uri was generated */
-	struct _EMFormatPURITree *puri_level;
+	GNode *puri_level;
 	CamelURL *base;
 
 	void (*callback)(EMFormatMailJob *job, gint cancelled);
@@ -240,6 +240,8 @@ struct _EMFormatMail {
 	guint32 header_wrap_flags;
 
 	EMFormatMailState state; /* actual state of the object */
+	gboolean show_photo;
+	gboolean local_only_photo;
 };
 
 struct _EMFormatMailClass {
diff --git a/src/mail-account-view.c b/src/mail-account-view.c
index 4e54dae..a088d68 100644
--- a/src/mail-account-view.c
+++ b/src/mail-account-view.c
@@ -178,8 +178,8 @@ save_identity (MailAccountView *view)
 static int
 validate_identity (MailAccountView *view)
 {
-	char *user = (char *)e_account_get_string(view->edit->account, E_ACCOUNT_ID_NAME);
-	char *email = (char *)e_account_get_string(view->edit->account, E_ACCOUNT_ID_ADDRESS);
+	char *user = (char *)e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_ID_NAME);
+	char *email = (char *)e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_ID_ADDRESS);
 	char *tmp;
 
 	if (!user || !*user)
@@ -215,7 +215,7 @@ create_review (MailAccountView *view)
 	char *enc;
 	CamelURL *url;
 
-	uri = (char *)e_account_get_string(view->edit->account, E_ACCOUNT_SOURCE_URL);
+	uri = (char *)e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_SOURCE_URL);
 	if (!uri  || (url = camel_url_new(uri, NULL)) == NULL)
 		return NULL;
 
@@ -232,7 +232,7 @@ create_review (MailAccountView *view)
 	gtk_widget_show (label);
 	PACK_BOX(label);
 	gtk_table_attach ((GtkTable *)table, box, 0, 1, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-	entry = gtk_label_new(e_account_get_string(view->edit->account, E_ACCOUNT_ID_NAME));
+	entry = gtk_label_new(e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_ID_NAME));
 	gtk_widget_show(entry);
 	PACK_BOX(entry)
 	gtk_table_attach ((GtkTable *)table, box, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
@@ -241,7 +241,7 @@ create_review (MailAccountView *view)
 	gtk_widget_show (label);
 	PACK_BOX(label)
 	gtk_table_attach ((GtkTable *)table, box, 0, 1, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-	entry = gtk_label_new (e_account_get_string(view->edit->account, E_ACCOUNT_ID_ADDRESS));
+	entry = gtk_label_new (e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_ID_ADDRESS));
 	gtk_widget_show(entry);
 	PACK_BOX(entry)
 	gtk_table_attach ((GtkTable *)table, box, 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
@@ -292,7 +292,7 @@ create_review (MailAccountView *view)
 
 
 	camel_url_free(url);
-	uri =(char *) e_account_get_string(view->edit->account, E_ACCOUNT_TRANSPORT_URL);
+	uri =(char *) e_account_get_string(em_account_editor_get_modified_account(view->edit), E_ACCOUNT_TRANSPORT_URL);
 	if (!uri  || (url = camel_url_new(uri, NULL)) == NULL)
 		return NULL;
 
@@ -423,20 +423,20 @@ mav_next_pressed (GtkButton *button, MailAccountView *mav)
 	}
 
 	if (mav->current_page == MAV_LAST - 1) {
-		char *uri = (char *)e_account_get_string(mav->edit->account, E_ACCOUNT_SOURCE_URL);
+		char *uri = (char *)e_account_get_string(em_account_editor_get_modified_account(mav->edit), E_ACCOUNT_SOURCE_URL);
 		CamelURL *url;
 
-		e_account_set_string (mav->edit->account, E_ACCOUNT_NAME, e_account_get_string(mav->edit->account, E_ACCOUNT_ID_ADDRESS));
+		e_account_set_string (em_account_editor_get_modified_account(mav->edit), E_ACCOUNT_NAME, e_account_get_string(em_account_editor_get_modified_account(mav->edit), E_ACCOUNT_ID_ADDRESS));
 		if (uri != NULL && (url = camel_url_new(uri, NULL)) != NULL) {
 			camel_url_set_param(url, "check_all", "1");
 			camel_url_set_param(url, "sync_offline", "1");
 
 			if (!mav->original && strcmp(url->protocol, "pop") == 0) {
-				e_account_set_bool (mav->edit->account, E_ACCOUNT_SOURCE_KEEP_ON_SERVER, TRUE);
+				e_account_set_bool (em_account_editor_get_modified_account(mav->edit), E_ACCOUNT_SOURCE_KEEP_ON_SERVER, TRUE);
 			}
 
 			uri = camel_url_to_string(url, 0);
-			e_account_set_string(mav->edit->account, E_ACCOUNT_SOURCE_URL, uri);
+			e_account_set_string(em_account_editor_get_modified_account(mav->edit), E_ACCOUNT_SOURCE_URL, uri);
 			g_free(uri);
 			camel_url_free(url);
 		}
@@ -595,8 +595,8 @@ mail_account_view_construct (MailAccountView *view)
 	gtk_box_pack_start ((GtkBox *)view, view->scroll, TRUE, TRUE, 0);
 	view->edit = em_account_editor_new_for_pages (view->original, EMAE_PAGES, "org.gnome.evolution.mail.config.accountWizard", view->wpages);
 	if (!view->original) {
-		e_account_set_bool (view->edit->account, E_ACCOUNT_SOURCE_SAVE_PASSWD, TRUE);
-		e_account_set_bool (view->edit->account, E_ACCOUNT_TRANSPORT_SAVE_PASSWD, TRUE);
+		e_account_set_bool (em_account_editor_get_modified_account(view->edit), E_ACCOUNT_SOURCE_SAVE_PASSWD, TRUE);
+		e_account_set_bool (em_account_editor_get_modified_account(view->edit), E_ACCOUNT_TRANSPORT_SAVE_PASSWD, TRUE);
 	}
 	em_account_editor_check (view->edit, mail_account_pages[0].path);
 	view->pages[0]->done = TRUE;
diff --git a/src/mail-decoration.c b/src/mail-decoration.c
index 9eebbe8..689bb83 100644
--- a/src/mail-decoration.c
+++ b/src/mail-decoration.c
@@ -231,7 +231,6 @@ md_size_allocate_event (GtkWidget *widget, GtkAllocation *allocation, gpointer u
 		md->priv->window_width = width;
 		gconf_client_set_int (client, "/apps/anjal/window_width", width, NULL);
 		gconf_client_set_int (client, "/apps/anjal/window_height", height, NULL);
-		printf("Setting %d %d\n", width, height);
 		g_object_unref(client);
 	}
 
diff --git a/src/mail-float-bar.c b/src/mail-float-bar.c
index 9e952e8..e8e3850 100644
--- a/src/mail-float-bar.c
+++ b/src/mail-float-bar.c
@@ -84,8 +84,6 @@ static void
 mail_float_bar_init(MailFloatBar *editor)
 {
 	MailFloatBarPrivate *priv;
-	gchar *index_html;
-	GtkWidget *scroller, *vbox;
 
 	priv = MAIL_FLOAT_BAR_GET_PRIVATE (editor);
 }
@@ -96,7 +94,7 @@ mfb_construct (MailFloatBar *bar, GtkWidget *top)
 	GtkWidget *toolbar;
 	GtkToolItem *item;
 	GtkWidget *window = gtk_window_new (GTK_WINDOW_POPUP), *box;
-	int pos = 0, x, y;
+	int x, y;
 
 	MailFloatBarPrivate *priv;
 
@@ -106,27 +104,27 @@ mfb_construct (MailFloatBar *bar, GtkWidget *top)
 
 	/*Create items.*/
 	item = gtk_tool_button_new (gtk_label_new(_("Hide Folder Tree")), NULL);
-	gtk_box_pack_start (toolbar, item, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)toolbar, (GtkWidget *)item, FALSE, FALSE, 0);
 
 	item = gtk_tool_button_new (gtk_image_new_from_icon_name("go-previous", GTK_ICON_SIZE_MENU), NULL);
-	gtk_box_pack_start (toolbar, item, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)toolbar, (GtkWidget *)item, FALSE, FALSE, 0);
 
 	item = gtk_tool_button_new (gtk_image_new_from_icon_name("go-next", GTK_ICON_SIZE_MENU), NULL);
-	gtk_box_pack_start (toolbar, item, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)toolbar, (GtkWidget *)item, FALSE, FALSE, 0);
 
 	item = gtk_tool_button_new (gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_MENU), NULL);
-	gtk_box_pack_start (toolbar, item, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)toolbar, (GtkWidget *)item, FALSE, FALSE, 0);
 
 	box = gtk_hbox_new (FALSE, 0);
-	gtk_box_pack_start (box, toolbar, TRUE, TRUE, 4);
+	gtk_box_pack_start ((GtkBox *)box, toolbar, TRUE, TRUE, 4);
 	gtk_widget_set_size_request (box, 200, 32);
-	gtk_window_set_default_size (window, 250, 32);
-	gtk_container_add(window, box);
-	gtk_window_set_transient_for (window, top);
+	gtk_window_set_default_size ((GtkWindow *)window, 250, 32);
+	gtk_container_add((GtkContainer *)window, box);
+	gtk_window_set_transient_for ((GtkWindow *)window, (GtkWindow *)top);
 	gtk_widget_show_all(window);
-	gtk_window_get_position (top, &x, &y);
+	gtk_window_get_position ((GtkWindow *)top, &x, &y);
 
-	gtk_window_move (window, x - 125 + (top->allocation.width/2), y + top->allocation.height-32);
+	gtk_window_move ((GtkWindow *)window, x - 125 + (top->allocation.width/2), y + top->allocation.height-32);
 }
 MailFloatBar * mail_float_bar_new(GtkWidget *top)
 {
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 3ee3aa6..bc4db31 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -28,7 +28,6 @@
 #include "mail-view.h"
 #include "mail-folder-view.h"
 #include "mail/em-folder-tree.h"
-#include "mail/em-popup.h"
 #include "mail/mail-mt.h"
 #include "mail/mail-ops.h"
 #include "mail/em-utils.h"
@@ -40,7 +39,6 @@
 #include <e-util/e-marshal.h>
 #endif
 #include "misc/e-spinner.h"
-#include "mail-sqlite-store.h"
 #include "em-tree-store.h"
 #include "custom-cell-renderer-hbox.h"
 #include "custom-cell-renderer-vbox.h"
@@ -49,6 +47,7 @@
 #include "mail-utils.h"
 #include "mail-composer-view.h"
 #include "mail-shell.h"
+#include "mail-sqlite-store.h"
 
 #include <gdk/gdkkeysyms.h>
 
@@ -72,7 +71,7 @@ struct  _MailFolderViewPrivate {
 	GtkWidget *view_scroller;
 	GtkWidget *info_bar;
 	GtkWidget *info_spinner;
-	CamelOperation *cancel;
+	gint cancel;
 	GtkCellRenderer *from_to;
 	GtkTreeViewColumn *cols[3];
 
@@ -261,7 +260,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;
+	shell->priv->cancel = 0;
 	if (shell->priv->light) 
 		shell->model = mail_sqlite_store_new ();
 	else {
@@ -312,7 +311,7 @@ mail_folder_view_finalize (GObject *object)
 		 g_free (mfv->priv->folder_name);
 
 	 if (mfv->priv->cancel) {
-		camel_operation_cancel(mfv->priv->cancel);
+		mail_msg_cancel (mfv->priv->cancel);
 	 }
 	 if (mfv->search_state) {
 		 g_free(mfv->search_state);
@@ -463,6 +462,7 @@ mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri)
 	if (uri && mfv->uri && !strcmp(uri, mfv->uri))
 		 return;
 
+	printf("%s %s\n", uri, mfv->uri);
 	if (mfv->uri)
 		 g_free(mfv->uri);
 	mfv->uri = g_strdup(uri);
@@ -1039,6 +1039,27 @@ mfv_get_selected_threads (MailFolderView *mfv)
 }
 
 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 = 0;
+	composer = (EMsgComposer *)em_utils_edit_message (msg, folder);
+	mcv = (MailComposerView *)mail_shell_create_composer ();
+	mail_composer_view_replace_composer ((struct _MailComposerView *)mcv, (GtkWidget *)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);
+}
+
+#if 0
+static void
 mfv_popup_open_new_tab (EPopup *ep, EPopupItem *pitem, void *data)
 {
 	 MailFolderView *mfv = (MailFolderView *)data;
@@ -1120,25 +1141,7 @@ 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 = (EMsgComposer *)em_utils_edit_message (msg, folder);
-	mcv = (MailComposerView *)mail_shell_create_composer ();
-	mail_composer_view_replace_composer ((struct _MailComposerView *)mcv, (GtkWidget *)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 },
@@ -1164,15 +1167,15 @@ mfv_popup_items_free(EPopup *ep, GSList *items, void *data)
 {
 	g_slist_free(items);
 }
-
+#endif
 static void
 mfv_popup (MailFolderView *mfv, GdkEvent *event)
 {
-	GSList *menus = NULL;
-	GtkMenu *menu;
-	EMPopup *emp;
-	EMPopupTargetSelect *t;
-	int i;
+//	GSList *menus = NULL;
+//	GtkMenu *menu;
+//	EMPopup *emp;
+//	EMPopupTargetSelect *t;
+//	int i;
 	GtkTreePath *path = NULL;
 
 	if (gtk_tree_view_get_path_at_pos (mfv->tree, event->button.x, event->button.y, &path, NULL, NULL, NULL)) {
@@ -1190,7 +1193,8 @@ mfv_popup (MailFolderView *mfv, GdkEvent *event)
 	 *
 	 * This is the context menu shown on the message list.
 	 */
-	emp = em_popup_new("org.gnome.evolution.anjal.mail.folderview.popup");
+#warning "show-popup"	
+/*	emp = em_popup_new("org.gnome.evolution.anjal.mail.folderview.popup");
 	t = em_popup_target_new_select(emp, mfv->priv->folder, mfv->uri, mfv_get_selected_threads(mfv));
 	t->target.widget = (GtkWidget *)mfv;
 
@@ -1201,7 +1205,7 @@ mfv_popup (MailFolderView *mfv, GdkEvent *event)
 	menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)t, 0);
 
 	gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time);
-	
+*/	
 }
 
 static gboolean
@@ -1318,8 +1322,9 @@ mfv_tree_resize (GtkWidget *w, GtkAllocation *req, GtkTreeViewColumn *col)
 
 	gtk_tree_view_column_set_fixed_width (shell->priv->cols[2], 24);
 	/* gtk_tree_view_column_set_sizing (shell->priv->cols[2], GTK_TREE_VIEW_COLUMN_AUTOSIZE); */
+//	if ((req->width - (gtk_tree_view_column_get_fixed_width(col)+56) > 1) && GTK_WIDGET_VISIBLE(shell->priv->folder_pane)) 
 
-	if ((req->width - (gtk_tree_view_column_get_fixed_width(col)+56) > 1) && GTK_WIDGET_VISIBLE(shell->priv->folder_pane)) 
+	if ((req->width - (gtk_tree_view_column_get_fixed_width(col)+56) > 1)) 
 		gtk_tree_view_column_set_fixed_width (shell->priv->cols[1], req->width - 80);
 	gtk_tree_view_column_set_fixed_width (shell->priv->cols[2], 16);
 
@@ -1928,16 +1933,14 @@ mail_folder_view_show_sort_popup  (MailFolderView *mfv, GtkWidget *button)
 void
 mail_folder_view_activate (MailFolderView *mfv, GtkWidget *tree, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, GtkWidget *slider, gboolean act)
 {
-	 if (!folder_tree || !check_mail || !sort_by)
+	 if (!check_mail || !sort_by)
 		  return;
 	 if (mfv->priv->message_shown) {
-		  gtk_widget_show (folder_tree);
 		  g_signal_emit (mfv, signals[MESSAGE_SHOWN], 0);
 	 } else {
-		  gtk_widget_show(folder_tree);
-		  gtk_widget_hide (slider);
+		  ; //gtk_widget_hide (slider);
 	 }
-	 gtk_widget_set_sensitive (folder_tree, act);
+	 /* gtk_widget_set_sensitive (folder_tree, act);*/
 	 gtk_widget_set_sensitive (check_mail, act);
 	 gtk_widget_set_sensitive (sort_by, act);
 	 if (mfv->priv->folder) {
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 930b48c..801fb1a 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -72,7 +72,7 @@ struct  _MailMessageViewPrivate {
 	GtkWidget *unread_image;
 	char *bold[2];
 	char *normal[2];
-	CamelOperation *cancel;
+	gint cancel;
 	gboolean show_composer;
 	GtkWidget *attach_area;
 	GtkWidget *html_headers;
@@ -110,7 +110,7 @@ mail_message_view_init (MailMessageView  *shell)
 {
 	shell->priv = g_new0(MailMessageViewPrivate, 1);
 	shell->priv->spinner = NULL;
-	shell->priv->cancel = NULL;
+	shell->priv->cancel = 0;
 	shell->type = MAIL_VIEW_MESSAGE;
 	shell->uri = "mail://";
 	shell->priv->mode = -2;
@@ -129,7 +129,7 @@ mail_message_view_finalize (GObject *object)
 	MailMessageViewPrivate *priv = shell->priv;
 	
 	if (shell->priv->cancel) {
-		camel_operation_cancel(shell->priv->cancel);
+		mail_msg_cancel(shell->priv->cancel);
 	}
 	if (shell->composer)
 		gtk_widget_destroy (shell->composer);
@@ -204,8 +204,9 @@ static void
 mmv_message_opened(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data, CamelException *ex)
 {
 	MailMessageView *shell = (MailMessageView *)data;
-	shell->priv->cancel = NULL;
-	mail_indicate_new_mail (FALSE);
+	shell->priv->cancel = 0;
+#warning "indicate new mail"	
+//	mail_indicate_new_mail (FALSE);
 	//gtk_widget_hide (shell->priv->table_headers);
 	//gtk_widget_show (shell->priv->html_headers);
 	em_format_mail_set_message_view ((EMFormatMail *)shell->efwd, shell, shell->body, shell->priv->html_headers);
@@ -523,7 +524,7 @@ construct_reply_composer (MailMessageView *mmv, int mode)
 		gtk_widget_show(box);
 		
 		if (mode != -1)
-			mmv->composer = (GtkWidget *)em_utils_reply_to_message (mmv->priv->folder, mmv->priv->uid, mmv->priv->msg, mode, mmv->efwd);
+			mmv->composer = (GtkWidget *)em_utils_reply_to_message (mmv->priv->folder, mmv->priv->uid, mmv->priv->msg, mode, (EMFormat *)mmv->efwd);
 		else 
 			mmv->composer = (GtkWidget *)em_utils_forward_message (mmv->priv->msg, mmv->priv->folder_uri);
 		g_assert (mmv->composer);
@@ -1436,9 +1437,9 @@ mail_message_view_construct (MailMessageView *mmview)
 {
 	GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
 	mmview->efwd = (GtkWidget *)em_format_mail_display_new ();
-	((EMFormat *)mmview->efwd)->show_photo = FALSE;
+
+	((EMFormatMail *)mmview->efwd)->show_photo = FALSE;
 	em_format_mail_display_set_attachment_pane ((EMFormatMailDisplay *)mmview->efwd, vbox);
-	em_format_set_session ((EMFormat *)mmview->efwd, session);
 	gtk_box_set_spacing ((GtkBox *)mmview, 0);
 	mmview->priv->attach_area = vbox;
 }
diff --git a/src/mail-settings-view.c b/src/mail-settings-view.c
index 55f8026..1fe6707 100644
--- a/src/mail-settings-view.c
+++ b/src/mail-settings-view.c
@@ -30,7 +30,7 @@
 #include <libedataserver/e-account-list.h>
 #include "mail-view.h"
 #include "mail/mail-config.h"
-
+#include <e-util/e-account-utils.h>
 extern gboolean anjal_icon_decoration;
 
 struct _MailSettingsViewPrivate {
@@ -109,11 +109,12 @@ static void
 msv_delete_account(GtkButton *button, MailSettingsView *msv)
 {
 	EAccount *account = g_object_get_data((GObject *)button, "account");
+	EAccountList *account_list = e_get_account_list ();
+
+	e_account_list_remove (account_list, account);
+
+	e_account_list_save (account_list);
 
-	if (account->enabled && account->source && account->source->url)
-		mail_component_remove_store_by_uri (mail_component_peek (), account->source->url);
-	mail_config_remove_account (account);
-	mail_config_write ();
 	msv_regen_view (msv);
 
 }
@@ -207,7 +208,7 @@ mail_settings_view_construct (MailSettingsView *acview)
 	gtk_widget_show (acview->priv->box);
 	gtk_scrolled_window_add_with_viewport ((GtkScrolledWindow *)acview->priv->scroll, acview->priv->box);
 
-	acview->priv->accounts = mail_config_get_accounts ();
+	acview->priv->accounts = e_get_account_list ();
 	g_signal_connect (acview->priv->accounts, "account-added", G_CALLBACK(msv_account_added), acview);
 	msv_regen_view (acview);
 	gtk_widget_show((GtkWidget *)acview);
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 3f10b9a..1e6e237 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -38,6 +38,10 @@
 #include <mail/em-utils.h>
 #include <mail/em-composer-utils.h>
 #include <e-util/e-util.h>
+#include <shell/e-shell.h>
+#include <shell/e-shell-window-actions.h>
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-taskbar.h>
 
 enum {
 	BACKSPACE_PRESSED,
@@ -62,8 +66,17 @@ char *scolor_norm;
 GdkColor *pcolor_fg_norm;
 char *scolor_fg_norm;
 
+static MailShell * default_shell;
+
 static guint mail_shell_signals[LAST_SIGNAL];
 
+/* Hacks :-( */
+void anjal_shell_view_set_mail_view (EShellView *view, MailView *mview);
+GtkWidget * anjal_shell_content_get_search_entry (EShellContent *);
+void anjal_shell_content_pack_view (EShellContent *, MailView *);
+void e_shell_window_private_constructed (EShellWindow *);
+static gboolean ms_check_new (void);
+
 extern gboolean windowed;
 
 struct  _MailShellPrivate {
@@ -75,6 +88,9 @@ struct  _MailShellPrivate {
 	GtkWidget *message_pane;
 	GtkWidget *bottom_bar;
 	GtkWidget *folder_pane;
+
+	MailView *view;
+
 	/* Top Bar */
 	GtkWidget *action_bar;
 	GtkWidget *search_bar;
@@ -84,6 +100,7 @@ struct  _MailShellPrivate {
 	GtkWidget *new_mail;
 
 	GtkWidget *search_entry;
+	GtkWidget *search_box;
 
 	GtkWidget *sort;
 	GtkWidget *settings;
@@ -93,29 +110,323 @@ struct  _MailShellPrivate {
 	MailViewChild *people;
 	MailViewChild *settings_view;
 
+	EShellTaskbar *task_bar;
+	GtkWidget *status_bar;
+	
+	guint task_bar_id;
+
 	char **args;
 };
 
 static void mail_shell_quit (MailShell *shell);
+static void new_email_btn_clicked (GtkButton *button G_GNUC_UNUSED, gpointer data);
+
+G_DEFINE_TYPE (MailShell, mail_shell, E_TYPE_SHELL_WINDOW)
+#define PACK_IN_TOOL(wid,icon)	{ GtkWidget *tbox; tbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *)tbox, gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_BUTTON), FALSE, FALSE, 0); wid = (GtkWidget *)gtk_tool_button_new (tbox, NULL); }
 
-G_DEFINE_TYPE (MailShell, mail_shell, GTK_TYPE_WINDOW)
 
 static void setup_abooks (void);
+static int color_expose (GtkWidget *w, GdkEventExpose *event G_GNUC_UNUSED, gpointer data);
+static void ms_check_mail  (GtkButton *button G_GNUC_UNUSED, gpointer data);
+static void popup_sort (GtkButton *b, MailShell *shell);
+static void settings_btn_clicked (GtkButton *button G_GNUC_UNUSED, gpointer data);
+static void mail_shell_quit_cb (GtkWidget *w G_GNUC_UNUSED, MailShell *shell);
+static void ms_delete_event (MailShell *shell, GdkEvent *event G_GNUC_UNUSED, gpointer data G_GNUC_UNUSED);
+static void ms_init_style (GtkStyle *style);
+
+static void
+ms_remove_settings  (MailViewChild *mvc G_GNUC_UNUSED,
+		     MailShell *shell)
+{
+	shell->priv->settings_view = NULL;
+}
+
+#if 0
+static void
+ms_construct_content_area (EShellWindow *shell)
+{
+
+}
+#endif
+
+static gboolean
+cleanup_status (EShellWindow *eshell)
+{
+	MailShell *shell = (MailShell *)eshell;
+	int count = e_shell_taskbar_get_task_count (shell->priv->task_bar);
+
+	if (count == 0 && GTK_WIDGET_VISIBLE(shell->priv->status_bar))
+		gtk_widget_hide (shell->priv->status_bar);
+
+
+	return TRUE;
+}
+
+static void
+ms_activity_added (EShellWindow *window, EActivity *activity)
+{
+	gtk_widget_show (((MailShell *)window)->priv->status_bar);
+}
+
+static void
+handle_cmdline (MailView *mv, MailShell *shell)
+{
+	g_signal_handlers_block_by_func (mv, handle_cmdline, shell);
+	mail_shell_handle_cmdline (shell);
+}
+
+static void
+ms_show_post_druid (MailViewChild *mfv G_GNUC_UNUSED,
+		    MailShell *shell)
+{
+	gtk_widget_show (shell->priv->view->folder_tree);
+	if (shell->priv->settings_view)
+		mail_view_switch_to_settings ((MailView *)shell->priv->view, (MailViewChild *)shell->priv->settings_view);
+	else {
+		shell->priv->settings_view = mail_view_add_page ((MailView *)shell->priv->view, MAIL_VIEW_SETTINGS, NULL);
+		g_signal_connect (shell->priv->settings_view, "view-close", G_CALLBACK(ms_remove_settings), shell);
+	}
+
+}
+
+static gboolean
+idle_cb (EShellWindow *eshell)
+{
+	GConfClient *client = gconf_client_get_default();
+	const gchar *key;
+	GError *error = NULL;
+	EShellView *shell_view;
+	MailShell *shell = (MailShell *)eshell;
+	MailShellPrivate *priv = shell->priv;
+	MailView *view = mail_view_new ();
+	EShell *es;
+	EShellBackend *backend;
+
+	shell->priv->view = view;
+	//client = e_shell_get_gconf_client (shell);
+	key = "/apps/evolution/shell/view_defaults/component_id";
+	gconf_client_set_string (client, key, "anjal", &error);
+	e_shell_window_set_active_view (eshell, "anjal");
+	//e_shell_window_switch_to_view (eshell, "mail");
+	g_object_unref (client);
+	g_signal_connect ((GObject *)view, "view-new", G_CALLBACK(handle_cmdline), shell);
+
+	shell_view = e_shell_window_get_shell_view (eshell, "anjal");
+	mail_view_set_shell_view (view, shell_view);
+	anjal_shell_view_set_mail_view (shell_view, view);
+	//((MailSearch *)priv->search_entry)->shell = shell;
+	//gtk_widget_show (priv->search_entry);
+	priv->search_entry = anjal_shell_content_get_search_entry (e_shell_view_get_shell_content(shell_view));
+	mail_view_set_search_entry (view, priv->search_entry);
+	mail_view_set_sort_by (view, priv->sort);
+	mail_view_set_check_email (view, priv->check_mail);
+
+	gtk_box_pack_start ((GtkBox *)priv->search_box, priv->search_entry, TRUE, FALSE, 0);
+//	anjal_shell_content_set_view (e_shell_view_get_shell_content(shell_view), view);
+//	gtk_container_add (e_shell_view_get_shell_content(shell_view), view);
+	anjal_shell_content_pack_view (e_shell_view_get_shell_content(shell_view), view);
+	gtk_widget_show ((GtkWidget *)view);
+	
+	shell->priv->task_bar = e_shell_view_get_shell_taskbar (shell_view);
+	shell->priv->status_bar = e_shell_window_get_status_area (eshell);
+	shell->priv->task_bar_id = g_timeout_add (10 * 1000, (GSourceFunc) cleanup_status, eshell);
+	gtk_widget_hide (shell->priv->status_bar);
+	es = e_shell_get_default ();
+	backend = e_shell_get_backend_by_name (es, "anjal");
+	g_signal_connect_swapped (backend, "activity-added", G_CALLBACK(ms_activity_added), eshell);
+
+	if (ms_check_new()) {
+		MailViewChild *mc;
+		char *pdir = g_build_filename (g_get_home_dir(), ".gnome2_private", NULL);
+
+		//gtk_widget_hide (((MailView *) shell->mail_component->mail_view)->folder_tree);
+		mc = mail_view_add_page ((MailView *)view, MAIL_VIEW_ACCOUNT, NULL);
+		g_signal_connect (mc, "view-close", G_CALLBACK(ms_show_post_druid), shell);
+		setup_abooks ();
+		if (!g_file_test(pdir, G_FILE_TEST_EXISTS)) {
+			g_mkdir (pdir, 0700);
+		}
+		g_free (pdir);
+	}	
+	return FALSE;
+}
+
+static void
+ms_construct_toolbar (EShellWindow *eshell, GtkWidget *container)
+{
+	MailShell *shell = (MailShell *)eshell;
+	MailShellPrivate *priv;
+	GtkWidget *box, *tmp, *lbl, *ar1;
+	
+	/* Argh, its constructed even before init. Fix the design */
+	priv = shell->priv = g_new0(MailShellPrivate, 1);
+
+	priv->top_bar = gtk_toolbar_new ();
+	gtk_box_pack_start ((GtkBox *)container, priv->top_bar, FALSE, FALSE, 0);
+	gtk_widget_show_all (priv->top_bar);
+	if (g_getenv("ANJAL_NO_MAX") || windowed) {
+		gtk_container_set_border_width (GTK_CONTAINER (shell), 1);
+		g_signal_connect (priv->top_bar, "expose-event",
+						  G_CALLBACK (color_expose),
+						  shell);
+		/* Leave it to the theme to decide the height */
+		/* gtk_widget_set_size_request (priv->top_bar, -1, 42);	*/
+	}
+
+	/* Check mail button and the spinner */
+	priv->check_mail = (GtkWidget *)gtk_tool_button_new (NULL, NULL);
+	gtk_widget_set_tooltip_text (priv->check_mail, _("Check Mail"));
+	box = gtk_hbox_new (FALSE, 0);
+	tmp = e_spinner_new_spinning_small_shown();
+	gtk_widget_hide(tmp);
+	g_object_set_data ((GObject *)priv->check_mail, "spinner", tmp);
+	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 0);
+	tmp = gtk_image_new_from_icon_name("mail-send-receive", GTK_ICON_SIZE_BUTTON);
+	gtk_widget_show(tmp);
+	g_object_set_data ((GObject *)priv->check_mail, "icon", tmp);
+	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 0);
+	gtk_widget_show(box);
+	gtk_tool_button_set_icon_widget ((GtkToolButton *)priv->check_mail, box);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->check_mail, 0);
+	gtk_widget_show (priv->check_mail);
+	g_signal_connect (priv->check_mail, "clicked", G_CALLBACK(ms_check_mail), shell);
+
+	/* New mail tool button */
+	PACK_IN_TOOL(priv->new_mail, "mail-message-new");
+	gtk_widget_set_tooltip_text (priv->new_mail, _("New Mail"));
+	gtk_widget_show_all (priv->new_mail);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->new_mail, 1);
+	g_signal_connect (priv->new_mail, "clicked", G_CALLBACK (new_email_btn_clicked), shell);
+
+	/* Separator before Search */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 2);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
+	gtk_widget_set_size_request (tmp, 20, -1);
+	gtk_widget_show (tmp);
+
+	/* Search bar */
+	priv->search_bar = (GtkWidget *)gtk_tool_item_new ();
+	gtk_tool_item_set_expand ((GtkToolItem *)priv->search_bar, TRUE);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->search_bar, 3);
+	gtk_widget_show (priv->search_bar);
+	tmp = gtk_vbox_new (FALSE, 0);
+	gtk_widget_show (tmp);
+	priv->search_box = tmp;
+	//priv->search_entry = (GtkWidget *)mail_search_new ();
+	//((MailSearch *)priv->search_entry)->shell = shell;
+	//gtk_widget_show (priv->search_entry);
+	//gtk_box_pack_start ((GtkBox *)tmp, priv->search_entry, TRUE, FALSE, 0);
+	gtk_container_add ((GtkContainer *)priv->search_bar, tmp);
+
+	/* Post search separator */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 4);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
+	gtk_widget_set_size_request (tmp, 20, -1);
+	gtk_widget_show (tmp);
+
+	/* Sort combo */
+	tmp = gtk_hbox_new (FALSE, 0);
+	lbl =  gtk_label_new (_("Sort By"));
+	ar1 = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+
+#if 0	
+	if (windowed ||  g_getenv("ANJAL_NO_MAX") != NULL) {
+		GdkColor color;
+
+		gdk_color_parse ("#000000", &color);
+		gtk_widget_modify_fg (lbl, GTK_STATE_SELECTED, &color);
+		gtk_widget_modify_fg (lbl, GTK_STATE_ACTIVE, &color);
+		gtk_widget_modify_fg (lbl, GTK_STATE_PRELIGHT, &color);
+
+		gdk_color_parse ("#ffffff", &color);
+		gtk_widget_modify_fg (lbl, GTK_STATE_NORMAL, &color);
+	}
+#endif
+
+	gtk_box_pack_start ((GtkBox *)tmp, lbl, FALSE, FALSE, 6);
+	gtk_box_pack_start ((GtkBox *)tmp, ar1, FALSE, FALSE, 0);
+	gtk_widget_show_all (tmp);
+	priv->sort = (GtkWidget *)gtk_tool_button_new  (tmp, NULL);
+	gtk_widget_show_all (priv->sort);
+	g_signal_connect (priv->sort, "clicked", G_CALLBACK(popup_sort), shell);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->sort, 5);
+
+	/* Settings button */
+	PACK_IN_TOOL(priv->settings, "preferences-system");
+	gtk_widget_set_tooltip_text(priv->settings, _("Settings"));
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->settings, 6);
+	gtk_widget_show_all (priv->settings);
+	g_signal_connect (priv->settings, "clicked", G_CALLBACK (settings_btn_clicked), shell);
+
+	/* Post Settings separator */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 7);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
+	gtk_widget_show (tmp);
+	
+	/* Close button */
+	PACK_IN_TOOL(priv->quit, "gtk-close");
+	gtk_widget_set_tooltip_text(priv->quit, _("Quit"));
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->quit, 8);
+	gtk_widget_show_all (priv->quit);
+	g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_shell_quit_cb), shell);
+	
+	g_idle_add ((GSourceFunc)idle_cb, shell);
+}
+
+
+static void
+ms_constructed (GObject *object)
+{
+	MailShell *shell = (MailShell *)object;
+	GtkStyle *style = gtk_widget_get_default_style ();
+	int window_width = 1024;
+
+	e_shell_window_private_constructed (E_SHELL_WINDOW (object));
+	gtk_window_set_icon_name ((GtkWindow *)shell, "evolution");
+	ms_init_style (style);
+	g_signal_connect ((GObject *)shell, "delete-event", G_CALLBACK (ms_delete_event), NULL);
+	gtk_window_set_type_hint ((GtkWindow *)shell, GDK_WINDOW_TYPE_HINT_NORMAL);
+	if (g_getenv("ANJAL_NO_MAX") == NULL && !windowed) {
+		 GdkScreen *scr = gtk_widget_get_screen ((GtkWidget *)shell);
+		 window_width = gdk_screen_get_width(scr);
+		 gtk_window_set_default_size ((GtkWindow *)shell, gdk_screen_get_width(scr), gdk_screen_get_height (scr));
+		 gtk_window_set_decorated ((GtkWindow *)shell, FALSE);
+	} else  {
+		mail_decoration_new ((GtkWindow *)shell);
+	}
+}
 
 static void
 mail_shell_init (MailShell  *shell)
 {
-	shell->priv = g_new0(MailShellPrivate, 1);
+	GtkWidget *widget;
+	GConfClient *client = gconf_client_get_default();
 	shell->priv->people = NULL;
 	shell->priv->settings_view = NULL;
+
+	widget = e_shell_window_get_managed_widget (
+		(EShellWindow *)shell, "/main-menu");
+	gtk_widget_hide (widget);
+
+	widget = e_shell_window_get_managed_widget (
+		(EShellWindow *)shell, "/main-toolbar");
+	gtk_widget_hide (widget);
+	gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/buttons_visible", FALSE, NULL);
+	g_object_unref (client);
+	
 }
 
 static void
 mail_shell_finalize (GObject *object)
 {
+	//FIXME: Unintialize the cleanup timeout.
+	//
 	G_OBJECT_CLASS (mail_shell_parent_class)->finalize (object);
 }
-
+#if 0
 static void
 ms_backspace_pressed (MailShell *shell)
 {
@@ -157,20 +468,25 @@ ms_ctrl_q_pressed (MailShell *shell)
 {
 	mail_shell_quit (shell);
 }	
-
+#endif
 static void
 mail_shell_class_init (MailShellClass *klass)
 {
 	GObjectClass * object_class = G_OBJECT_CLASS (klass);
+	EShellWindowClass *shell_class;
 	GtkBindingSet *binding_set;
 
-	mail_shell_parent_class = g_type_class_peek_parent (klass);
+	shell_class = mail_shell_parent_class = g_type_class_peek_parent (klass);
 	object_class->finalize = mail_shell_finalize;
-	klass->backspace_pressed = ms_backspace_pressed;
-	klass->ctrl_w_pressed = ms_ctrl_w_pressed;
-	klass->slash_pressed = ms_slash_pressed;
-	klass->f5_pressed = ms_f5_pressed;
-	klass->ctrl_q_pressed = ms_ctrl_q_pressed;
+	//shell_class->construct_content_area = ms_construct_content_area;
+	shell_class->construct_toolbar = ms_construct_toolbar;
+	object_class->constructed = ms_constructed;
+
+//	klass->backspace_pressed = ms_backspace_pressed;
+//	klass->ctrl_w_pressed = ms_ctrl_w_pressed;
+//	klass->slash_pressed = ms_slash_pressed;
+//	klass->f5_pressed = ms_f5_pressed;
+//	klass->ctrl_q_pressed = ms_ctrl_q_pressed;
 
 	mail_shell_signals [BACKSPACE_PRESSED] =
 		g_signal_new ("backspace_pressed",
@@ -258,7 +574,7 @@ color_expose (GtkWidget *w,
 static void
 popup_sort (GtkButton *b, MailShell *shell)
 {
-	mail_view_show_sort_popup ((MailView *)shell->mail_component->mail_view, (GtkWidget *)b);
+	mail_view_show_sort_popup ((MailView *)shell->priv->view, (GtkWidget *)b);
 }
 
 static void
@@ -266,7 +582,7 @@ new_email_btn_clicked (GtkButton *button G_GNUC_UNUSED,
 		       gpointer data)
 {
 	MailShell *shell = (MailShell *) data;
-	MailView *view = (MailView *)shell->mail_component->mail_view;
+	MailView *view = (MailView *)shell->priv->view;
 
 	mail_view_add_page ((MailView *)view, MAIL_VIEW_COMPOSER, NULL);
 }
@@ -274,8 +590,7 @@ new_email_btn_clicked (GtkButton *button G_GNUC_UNUSED,
 MailViewChild *
 mail_shell_create_composer (void)
 {
-	MailComponent *mc = mail_component_peek ();
-	MailView *view = (MailView *)mc->mail_view;
+	MailView *view = (MailView *)default_shell->priv->view;
 
 	return mail_view_add_page ((MailView *)view, MAIL_VIEW_COMPOSER, NULL);
 }
@@ -283,8 +598,7 @@ mail_shell_create_composer (void)
 MailViewChild *
 mail_shell_create_composer_mailto (const char *uri)
 {
-	MailComponent *mc = mail_component_peek ();
-	MailView *view = (MailView *)mc->mail_view;
+	MailView *view = (MailView *)default_shell->priv->view;
 	GtkWidget *composer = (GtkWidget *) em_utils_compose_new_message_with_mailto (uri, NULL);
 	gtk_widget_show (view->folder_tree);
 
@@ -295,24 +609,19 @@ ms_check_mail  (GtkButton *button G_GNUC_UNUSED,
 		gpointer data)
 {
 	MailShell *shell = (MailShell *) data;
-	MailView *view = (MailView *)shell->mail_component->mail_view;
+	MailView *view = (MailView *)shell->priv->view;
 
 	mail_view_check_mail ((MailView *)view, TRUE);
 }
 
-static void
-ms_remove_settings  (MailViewChild *mvc G_GNUC_UNUSED,
-		     MailShell *shell)
-{
-	shell->priv->settings_view = NULL;
-}
+
 
 static void
 settings_btn_clicked (GtkButton *button G_GNUC_UNUSED,
 		      gpointer data)
 {
 	MailShell *shell = (MailShell *) data;
-	MailView *view = (MailView *)shell->mail_component->mail_view;
+	MailView *view = (MailView *)shell->priv->view;
 
 	if (shell->priv->settings_view) {
 		mail_view_switch_to_settings ((MailView *)view, (MailViewChild *)shell->priv->settings_view);
@@ -342,15 +651,20 @@ ms_init_style (GtkStyle *style)
 }
 
 static void
-mail_shell_quit (MailShell *shell)
+mail_shell_quit (MailShell *mshell)
 {
+	EShell *shell;
+
+	shell = e_shell_window_get_shell ((EShellWindow *)mshell);
+	e_shell_quit (shell);
+	
 	/* What other clean ups ?*/
-	gboolean quit = mail_component_can_quit (shell->mail_component);
-	if (quit) {
-		mail_view_save((MailView *)shell->mail_component->mail_view); 
-		mail_component_quit (shell->mail_component);
-		gtk_main_quit();
-	}
+	//gboolean quit = 0;//mail_component_can_quit (shell->mail_component);
+	//if (quit) {
+	//	mail_view_save((MailView *)shell->mail_component->mail_view); 
+	//	mail_component_quit (shell->mail_component);
+	//	gtk_main_quit();
+	//}
 }
 
 static void
@@ -369,7 +683,7 @@ ms_delete_event (MailShell *shell,
 }
 
 static gboolean 
-ms_check_new ()
+ms_check_new (void)
 {
 	GConfClient *client;
 	GSList *accounts;
@@ -401,37 +715,18 @@ ms_show_people (GtkButton *button G_GNUC_UNUSED,
 		MailShell *shell)
 {
 	if (!shell->priv->people) {
-		shell->priv->people = mail_view_add_page ((MailView *)shell->mail_component->mail_view, MAIL_VIEW_PEOPLE, NULL);
+	//	shell->priv->people = mail_view_add_page ((MailView *)shell->mail_component->mail_view, MAIL_VIEW_PEOPLE, NULL);
 		g_signal_connect(shell->priv->people, "view-close", G_CALLBACK(ms_unlink_people), shell);
 	} else {
-		mail_view_switch_to_people ((MailView *)shell->mail_component->mail_view, shell->priv->people);
+	//	mail_view_switch_to_people ((MailView *)shell->mail_component->mail_view, shell->priv->people);
 	}
 }
 #endif
 
-static void
-ms_show_post_druid (MailViewChild *mfv G_GNUC_UNUSED,
-		    MailShell *shell)
-{
-	gtk_widget_show (((MailView *) shell->mail_component->mail_view)->folder_tree);
-	if (shell->priv->settings_view)
-		mail_view_switch_to_settings ((MailView *)shell->mail_component->mail_view, (MailViewChild *)shell->priv->settings_view);
-	else {
-		shell->priv->settings_view = mail_view_add_page ((MailView *)shell->mail_component->mail_view, MAIL_VIEW_SETTINGS, NULL);
-		g_signal_connect (shell->priv->settings_view, "view-close", G_CALLBACK(ms_remove_settings), shell);
-	}
 
-}
 
-#define PACK_IN_TOOL(wid,icon)	{ GtkWidget *tbox; tbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *)tbox, gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_BUTTON), FALSE, FALSE, 0); wid = (GtkWidget *)gtk_tool_button_new (tbox, NULL); }
-
-static void
-handle_cmdline (MailView *mv, MailShell *shell)
-{
-	g_signal_handlers_block_by_func (mv, handle_cmdline, shell);
-	mail_shell_handle_cmdline (shell);
-}
 
+#if 0
 void
 mail_shell_construct (MailShell *shell)
 {
@@ -642,6 +937,7 @@ mail_shell_construct (MailShell *shell)
 		g_free (pdir);
 	}
 }
+#endif
 
 int
 mail_shell_toolbar_height (MailShell *shell)
@@ -650,10 +946,12 @@ mail_shell_toolbar_height (MailShell *shell)
 }
 
 MailShell *
-mail_shell_new ()
+mail_shell_new (EShell *eshell, gboolean mode)
 {
-	MailShell *shell = g_object_new (MAIL_SHELL_TYPE, NULL);
-	mail_shell_construct (shell);
+	MailShell *shell = g_object_new (MAIL_SHELL_TYPE, "shell", eshell, "safe-mode", mode, NULL);
+
+	default_shell = shell;
+	//mail_shell_construct (shell);
 
 	return shell;
 }
@@ -761,17 +1059,15 @@ mail_shell_handle_cmdline (MailShell *shell)
 	for (i=0; shell->priv->args[i]; i++) {
 		if (strncmp (shell->priv->args[i], "mailto:";, 7) == 0) {
 			/* Handle mailto:// */
-			if (em_utils_check_user_can_send_mail(NULL)) {
+			if (em_utils_check_user_can_send_mail()) {
 				GtkWidget *composer = (GtkWidget *) em_utils_compose_new_message_with_mailto ((const char *)shell->priv->args[i], NULL);
-				//MailViewChild *child = 
-				mail_view_add_page ((MailView *)shell->mail_component->mail_view, MAIL_VIEW_COMPOSER, (gpointer)composer);
-				//child->flags |= MAIL_VIEW_HOLD_FOCUS;
+				MailViewChild *child = mail_view_add_page ((MailView *)shell->priv->view, MAIL_VIEW_COMPOSER, (gpointer)composer);
+				child->flags |= MAIL_VIEW_HOLD_FOCUS;
 			} else {
 				g_message ("Please configure an account before anything else");
 			}
 		}
 	}
-	
 	/* FIXME: Check who own the memory? GOptionContext or me ? */
 	shell->priv->args = NULL;
 }
diff --git a/src/mail-shell.h b/src/mail-shell.h
index fc270b6..d04cfdb 100644
--- a/src/mail-shell.h
+++ b/src/mail-shell.h
@@ -23,7 +23,7 @@
 #ifndef _MAIL_SHELL_H_
 #define _MAIL_SHELL_H_
 
-#include <gtk/gtk.h>
+#include <shell/e-shell-window.h>
 #include "mail-component.h"
 #include "mail-view.h"
 
@@ -37,14 +37,15 @@
 typedef struct _MailShellPrivate MailShellPrivate;
 
 typedef struct _MailShell {
-	GtkWindow parent;
-	MailComponent *mail_component;
+	EShellWindow parent;
+	/* GtkWindow parent; */
+	//MailComponent *mail_component;
 	
 	MailShellPrivate *priv;
 } MailShell;
 
 typedef struct _MailShellClass {
-	GtkWindowClass parent_class;
+	EShellWindowClass parent_class;
 
 	void (* backspace_pressed)    (MailShell *class);
 	void (* ctrl_w_pressed)    (MailShell *class);
@@ -54,7 +55,7 @@ typedef struct _MailShellClass {
 
 } MailShellClass;
 
-MailShell * mail_shell_new (void);
+MailShell * mail_shell_new (EShell *shell, gboolean safe);
 MailViewChild *mail_shell_create_composer (void);
 void mail_shell_set_cmdline_args (MailShell *shell, char **args);
 void mail_shell_handle_cmdline (MailShell *shell);
diff --git a/src/mail-view.c b/src/mail-view.c
index 65d54e6..d64d558 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -27,6 +27,7 @@
 #include "mail/em-utils.h"
 #include "mail/mail-send-recv.h"
 #include "mail/mail-ops.h"
+#include <mail/anjal-mail-view.h>
 #include "mail-view.h"
 #include "mail-folder-view.h"
 #include "mail-composer-view.h"
@@ -47,6 +48,7 @@ struct  _MailViewPrivate {
 	MailViewChild *current_view;
 	GtkWidget *new;
 	MailSearch *search;
+	GtkWidget *search_entry;
 };
 
 enum {
@@ -58,8 +60,9 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #undef MV_NEW_TAB
 
-G_DEFINE_TYPE (MailView, mail_view, GTK_TYPE_NOTEBOOK)
+G_DEFINE_TYPE (MailView, mail_view, ANJAL_MAIL_VIEW_TYPE)
 static MailConvView * mv_switch_message_view (MailView *mv, const char *uri);
+void anjal_shell_view_restore_state (EShellView *view, const char *uri);
 
 static void
 mail_view_init (MailView  *shell)
@@ -85,10 +88,27 @@ mail_view_finalize (GObject *object)
 }
 
 static void
+mv_set_folder_uri (AnjalMailView *mv, const char *uri)
+{
+	mail_view_set_folder_uri ((MailView *)mv, uri);
+}
+
+static void set_folder_tree (AnjalMailView *mv, EMFolderTree *tree)
+{
+	mail_view_set_folder_tree ((MailView *)mv, (GtkWidget *)tree);
+}
+
+static void
+set_search (AnjalMailView *mv, const char *search)
+{
+	mail_view_set_search ((MailView *)mv, search);
+}
+
+static void
 mail_view_class_init (MailViewClass *klass)
 {
 	GObjectClass * object_class = G_OBJECT_CLASS (klass);
-
+	AnjalMailViewClass *pclass;
 	signals[VIEW_NEW] =
 		g_signal_new ("view-new",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -98,7 +118,11 @@ mail_view_class_init (MailViewClass *klass)
 			      g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
 
-	mail_view_parent_class = g_type_class_peek_parent (klass);
+	pclass = mail_view_parent_class = g_type_class_peek_parent (klass);
+	((AnjalMailViewClass *)klass)->set_folder_uri = mv_set_folder_uri;
+	((AnjalMailViewClass *)klass)->set_folder_tree = set_folder_tree;
+	((AnjalMailViewClass *)klass)->set_search = set_search;
+
 	object_class->finalize = mail_view_finalize;
 
 };
@@ -141,8 +165,7 @@ mv_switch (GtkNotebook     *notebook,GtkNotebookPage *page, guint page_num, gpoi
 			 mail_conv_view_activate ((MailConvView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, FALSE);
 		else if (child->type == MAIL_VIEW_FOLDER)  {
 			 mail_folder_view_activate ((MailFolderView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, shell->slider, TRUE);
-		 	mail_search_set_state (shell->priv->search, ((MailFolderView *)child)->search_str, ((MailFolderView *)child)->search_state);
-
+			 anjal_shell_view_restore_state (shell->shell_view, child->uri);
 		} else if (child->type == MAIL_VIEW_ACCOUNT)
 			mail_account_view_activate ((MailAccountView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, FALSE);
 		else if (child->type == MAIL_VIEW_SETTINGS)
@@ -297,7 +320,8 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 		 mail_conv_view_activate ((MailConvView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
 	else if (child->type == MAIL_VIEW_FOLDER) {
 		 mail_folder_view_activate ((MailFolderView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, mv->slider, TRUE);
-		 mail_search_set_state (mv->priv->search, ((MailFolderView *)child)->search_str, ((MailFolderView *)child)->search_state);
+		 anjal_shell_view_restore_state ((EShellView *)mv->shell_view, child->uri);
+		 //mail_search_set_state (mv->priv->search, ((MailFolderView *)child)->search_str, ((MailFolderView *)child)->search_state);
 	} else if (child->type == MAIL_VIEW_ACCOUNT)
 		mail_account_view_activate ((MailAccountView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
 	else if (child->type == MAIL_VIEW_SETTINGS)
@@ -324,7 +348,8 @@ mv_message_new (MailFolderView *mfv, gpointer data, char *umid, MailView *mv)
 static void
 mv_search_set (MailFolderView *mfv, MailView *mv)
 {
-	 mail_search_set_state (mv->priv->search, mfv->search_str, mfv->search_state);
+	anjal_shell_view_restore_state (mv->shell_view, ((MailViewChild *)mfv)->uri);
+	 //mail_search_set_state (mv->priv->search, mfv->search_str, mfv->search_state);
 }
 
 static void
@@ -660,6 +685,7 @@ mail_view_set_folder_tree_widget (MailView *mv, GtkWidget *tree)
 	mv->folder_tree = tree;
 }
 
+#if 0
 static gboolean
 mv_tree_click_cb (GtkWidget *w, GdkEventButton *event, MailView *mv)
 {
@@ -681,13 +707,14 @@ mv_tree_click_cb (GtkWidget *w, GdkEventButton *event, MailView *mv)
 	 }
 	 return FALSE;
 }
+#endif
 
 void
 mail_view_set_folder_tree (MailView *mv, GtkWidget *tree)
 {
 	mv->tree = tree;
-	em_folder_tree_set_skip_double_click ((EMFolderTree *)tree, FALSE);
-	g_signal_connect ((GObject *)em_folder_tree_get_tree_view((EMFolderTree *)tree), "button-press-event", G_CALLBACK(mv_tree_click_cb), mv);
+	//em_folder_tree_set_skip_double_click ((EMFolderTree *)tree, FALSE);
+	//g_signal_connect ((GObject *)em_folder_tree_get_tree_view((EMFolderTree *)tree), "button-press-event", G_CALLBACK(mv_tree_click_cb), mv);
 }
 
 void
@@ -744,7 +771,7 @@ mail_view_check_mail(MailView *mv, gboolean deep)
 	
 	if (deep) {
 		em_utils_clear_get_password_canceled_accounts_flag ();
-		mail_send_receive_dialog (FALSE);
+		mail_send_receive (NULL);
 	}
 }
 
@@ -764,28 +791,31 @@ mail_view_save (MailView *mv)
 }
 
 void
-mail_view_set_search (MailView *mv, const char *search, char *state, char *search_str)
+mail_view_set_search (MailView *mv, const char *search)
 {
 	MailViewChild *child = (MailViewChild *)mv->priv->current_view;
 
 	if (child->type == MAIL_VIEW_FOLDER) {
 		MailFolderView *mfv = (MailFolderView *)child;
 
-		if (g_strcmp0 (mfv->search_state, state) == 0 &&
-				g_strcmp0 (mfv->search, search) == 0)
-			return;
-		if (mfv->search_state)
-			g_free (mfv->search_state);
-		if (mfv->search_str)
-			g_free (mfv->search_str);
-		mfv->search_state = state;
-		mfv->search_str = search_str;
-		mail_folder_view_set_search (mfv, search, search_str);
+		mail_folder_view_set_search (mfv, search, gtk_entry_get_text ((GtkEntry *)mv->priv->search_entry));
 	}
 }
 
 void
+mail_view_set_search_entry (MailView *mv, GtkWidget *entry)
+{
+	mv->priv->search_entry = entry;
+}
+
+void
 mail_view_init_search (MailView *mv, GtkWidget *search)
 {
 	mv->priv->search = (MailSearch *)search;
 }
+
+void
+mail_view_set_shell_view (MailView *mv, EShellView *shell)
+{
+	mv->shell_view = shell;
+}
diff --git a/src/mail-view.h b/src/mail-view.h
index 223dc13..78df55d 100644
--- a/src/mail-view.h
+++ b/src/mail-view.h
@@ -24,6 +24,8 @@
 #define _MAIL_VIEW_H_
 
 #include <gtk/gtk.h>
+#include <mail/anjal-mail-view.h>
+#include <shell/e-shell-view.h>
 
 #define MAIL_VIEW_TYPE        (mail_view_get_type ())
 #define MAIL_VIEW(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_VIEW_TYPE, MailView))
@@ -44,18 +46,19 @@ enum {
 typedef struct _MailViewPrivate MailViewPrivate;
 
 typedef struct _MailView {
-	GtkNotebook parent;
+	AnjalMailView parent;
 
-	 GtkWidget *tree; /* Actual tree */
+	GtkWidget *tree; /* Actual tree */
 	GtkWidget *folder_tree;
 	GtkWidget *slider;
 	GtkWidget *check_mail;
 	GtkWidget *sort_by; 
 	MailViewPrivate *priv;
+	EShellView *shell_view;
 } MailView;
 
 typedef struct _MailViewClass {
-	GtkNotebookClass parent_class;
+	AnjalMailViewClass parent_class;
 	void (* view_new) (MailView*);
 	
 } MailViewClass;
@@ -68,7 +71,7 @@ typedef struct _MailViewChild {
 	GtkVBox parent;
 	int type;
 	char *uri;
-	 MailViewFlags flags;
+	MailViewFlags flags;
 }MailViewChild;
 
 MailView * mail_view_new (void);
@@ -83,10 +86,12 @@ void mail_view_set_folder_tree_widget (MailView *mv, GtkWidget *tree);
 void mail_view_set_folder_tree (MailView *mv, GtkWidget *tree);
 void mail_view_save (MailView *mv);
 MailViewChild * mail_view_add_page (MailView *mv, guint16 type, gpointer data);
-void mail_view_set_search (MailView *view, const char *search, char *state, char *search_str);
+void mail_view_set_search (MailView *view, const char *search);
 void mail_view_set_slider (MailView *mv, GtkWidget *slider);
 void mail_view_init_search (MailView *mv, GtkWidget *search);
 void mail_view_switch_to_people (MailView* mv, MailViewChild *mpv);
 void mail_view_switch_to_settings (MailView* mv, MailViewChild *mpv);
+void mail_view_set_search_entry (MailView *mv, GtkWidget *entry);
+void mail_view_set_shell_view (MailView *mv, EShellView *shell);
 
 #endif
diff --git a/src/main.c b/src/main.c
index 32a4fe0..d7b4922 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,9 +38,10 @@
 #include <libedataserverui/e-passwords.h>
 #include <mail/mail-mt.h>
 #include "mail-shell.h"
-#include <libgnome/gnome-sound.h>
 #include <gconf/gconf-client.h>
 #include <e-util/e-icon-factory.h>
+#include <libedataserver/e-categories.h>
+#include <dbus/dbus-glib.h>
 
 #ifdef G_OS_WIN32
 #define WIN32_LEAN_AND_MEAN
@@ -59,12 +60,9 @@
 gboolean windowed = FALSE;
 gboolean anjal_icon_decoration = FALSE;
 gboolean default_app =  FALSE;
-GtkWidget *main_window;
+MailShell *main_window;
 static gchar **remaining_args;
-
-/* For testing propose use the local (not installed) glade file */
-/* #define GLADE_FILE PACKAGE_DATA_DIR"/anjal/glade/anjal.glade" */
-#define GLADE_FILE "anjal.glade"
+extern char *shell_moduledir;
 
 #define GCONF_KEY_MAILTO_ENABLED "/desktop/gnome/url-handlers/mailto/enabled"
 #define GCONF_KEY_MAILTO_COMMAND "/desktop/gnome/url-handlers/mailto/command"
@@ -107,7 +105,6 @@ mail_message_received_cb (UniqueApp         *app G_GNUC_UNUSED,
 
 	 return UNIQUE_RESPONSE_PASSTHROUGH;
 }
-
 #endif
 
 static void
@@ -115,7 +112,7 @@ check_and_set_default_mail (void)
 {
 	GConfClient *client = gconf_client_get_default ();
 	gchar *mailer;
-	printf("coming here\n");
+
 	mailer  = gconf_client_get_string(client, GCONF_KEY_MAILTO_COMMAND, NULL);
 	if (mailer && *mailer && (strcmp (mailer, ANJAL_MAILTO_COMMAND) == 0)) {
 		g_object_unref (client);
@@ -125,84 +122,146 @@ check_and_set_default_mail (void)
 	gconf_client_set_bool(client, GCONF_KEY_MAILTO_ENABLED, TRUE, NULL);
 	gconf_client_set_string(client, GCONF_KEY_MAILTO_COMMAND, ANJAL_MAILTO_COMMAND, NULL);
 	g_object_unref (client);
-	printf("Set %s\n", GCONF_KEY_MAILTO_COMMAND);
 }
 
 static gboolean
-idle_cb (MailShell *shell G_GNUC_UNUSED)
+idle_cb (MailShell *mshell G_GNUC_UNUSED)
 {
+	EShell *shell;
+
+	shell = e_shell_get_default ();
+	
 	if (default_app) {
 		check_and_set_default_mail ();
 	}
 
+#if HAVE_UNIQUE	
+	if (unique_app_is_running (UNIQUE_APP (shell))) {
+		   gboolean cmd_line =  (remaining_args && remaining_args[0] != NULL);
+		   
+		  if (!cmd_line)
+			unique_app_send_message (UNIQUE_APP(shell), UNIQUE_ACTIVATE, NULL);
+		  else {
+			  UniqueMessageData *data = unique_message_data_new ();
+			  unique_message_data_set_text (data, remaining_args[0], -1);
+			  unique_app_send_message (UNIQUE_APP(shell), UNIQUE_OPEN, data);
+			  unique_message_data_free (data);
+		  }
+
+		  gtk_main_quit ();
+		  return FALSE;
+	  }
+#endif
+
+	main_window = mail_shell_new (shell, TRUE);
+	gtk_widget_show ((GtkWidget *)main_window);
+	mail_shell_set_cmdline_args ((MailShell *)main_window, remaining_args);
+#if HAVE_UNIQUE	
+	g_signal_connect (UNIQUE_APP(shell), "message-received",
+                    G_CALLBACK (mail_message_received_cb),  main_window);
+#endif
 	return FALSE;
 }
 
-#ifdef G_OS_WIN32
+
 static void
-set_paths (void)
+categories_icon_theme_hack (void)
 {
-	wchar_t exe_filename[MAX_PATH];
-	wchar_t *p;
-	gchar *exe_folder_utf8;
-	gchar *components_folder_utf8;
-	gchar *top_folder_utf8;
-	gchar *path;
-
-	GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
-
-	p = wcsrchr (exe_filename, L'\\');
-	g_assert (p != NULL);
-
-	*p = L'\0';
-	exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
-
-	p = wcsrchr (exe_filename, L'\\');
-	g_assert (p != NULL);
-
-	*p = L'\0';
-	top_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
-	components_folder_utf8 =
-		g_strconcat (top_folder_utf8,
-#ifdef EVOLUTION_2_26
-			     "/lib/evolution/2.26/components",
-#else
-			     "/lib/evolution/2.28/components",
-#endif
-			     NULL);
-
-	path = g_build_path (";",
-			     exe_folder_utf8,
-			     components_folder_utf8,
-			     g_getenv ("PATH"),
-			     NULL);
-	if (!g_setenv ("PATH", path, TRUE))
-		g_warning ("Could not set PATH for Anjal and its child processes");
-
-	g_free (path);
-	g_free (exe_folder_utf8);
-	g_free (components_folder_utf8);
-
-	/* Set BONOBO_ACTIVATION_PATH */
-	if (g_getenv ("BONOBO_ACTIVATION_PATH" ) == NULL) {
-		path = g_build_filename (top_folder_utf8,
-					 "lib/bonobo/servers",
-					 NULL);
-		if (!g_setenv ("BONOBO_ACTIVATION_PATH", path, TRUE))
-			g_warning ("Could not set BONOBO_ACTIVATION_PATH");
-		g_free (path);
+	GtkIconTheme *icon_theme;
+	const gchar *category_name;
+	const gchar *filename;
+	gchar *dirname;
+
+	/* XXX Allow the category icons to be referenced as named
+	 *     icons, since GtkAction does not support GdkPixbufs. */
+
+	/* Get the icon file for some default category.  Doesn't matter
+	 * which, so long as it has an icon.  We're just interested in
+	 * the directory components. */
+	category_name = _("Birthday");
+	filename = e_categories_get_icon_file_for (category_name);
+	g_return_if_fail (filename != NULL && *filename != '\0');
+
+	/* Extract the directory components. */
+	dirname = g_path_get_dirname (filename);
+
+	/* Add it to the icon theme's search path.  This relies on
+	 * GtkIconTheme's legacy feature of using image files found
+	 * directly in the search path. */
+	icon_theme = gtk_icon_theme_get_default ();
+	gtk_icon_theme_append_search_path (icon_theme, dirname);
+
+	g_free (dirname);
+}
+
+static void
+shell_window_destroyed_cb (EShell *shell)
+{
+	if (e_shell_get_watched_windows (shell) == NULL)
+		gtk_main_quit ();
+}
+
+static void
+create_default_shell (void)
+{
+	EShell *shell;
+	GConfClient *client;
+	gboolean online = TRUE;
+	const gchar *key;
+	GError *error = NULL;
+
+	client = gconf_client_get_default ();
+	key = "/apps/evolution/shell/start_offline";
+
+	/* Requesting online or offline mode from the command-line
+	 * should be persistent, just like selecting it in the UI. */
+
+	/*if (start_online) {
+		online = TRUE;
+		gconf_client_set_bool (client, key, FALSE, &error);
+	} else if (start_offline) {
+		online = FALSE;
+		gconf_client_set_bool (client, key, TRUE, &error);
+	} else*/ {
+		gboolean value;
+
+		value = gconf_client_get_bool (client, key, &error);
+		if (error == NULL)
+			online = !value;
 	}
-	g_free (top_folder_utf8);
+
+	if (error != NULL) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	shell = g_object_new (
+		E_TYPE_SHELL,
+		"name", "org.gnome.Anjal",
+		"online", online,
+		NULL);
+
+	g_signal_connect (
+		shell, "window-destroyed",
+		G_CALLBACK (shell_window_destroyed_cb), NULL);
+
+	g_object_unref (client);
+
+	/* EShell keeps its own reference to the first instance for use
+	 * in e_shell_get_default(), so it's safe to unreference here. */
+	g_object_unref (shell);
+
+	g_idle_add ((GSourceFunc) idle_cb, remaining_args);
 }
-#endif
 
 int
 main (int argc, char *argv[])
 {
 	GError *error = NULL;
-#if HAVE_UNIQUE	
-	UniqueApp *app;
-#endif
+	EShell *default_shell;
+	GConfClient *client = gconf_client_get_default();
+
+	shell_moduledir = ANJAL_MODULEDIR;
 
 	if (!g_thread_supported ()) 
 		g_thread_init (NULL);
@@ -240,17 +299,20 @@ main (int argc, char *argv[])
 		g_error_free(error);
 	}
 #endif	
-	glade_init ();
-	e_cursors_init ();
+	g_type_init ();
+	if (!g_thread_get_initialized ())
+		g_thread_init (NULL);
+	dbus_g_thread_init ();
+
 	e_passwords_init();
 	e_icon_factory_init ();
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(), PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "anjal" G_DIR_SEPARATOR_S "icons");
-	if (!g_thread_supported ()) 
-		g_thread_init (NULL);
-	mail_msg_init ();
-	gnome_sound_init ("localhost");
+	categories_icon_theme_hack ();
 
-#if HAVE_UNIQUE	
+	gconf_client_set_bool (client, "/apps/evolution/mail/display/enable_vfolders", FALSE, NULL);
+	g_object_unref (client);
+	
+#if 0
 	app = unique_app_new ("org.gnome.Anjal", NULL);
 	  if (unique_app_is_running (app))  {
 		   gboolean cmd_line =  (remaining_args && remaining_args[0] != NULL);
@@ -266,24 +328,24 @@ main (int argc, char *argv[])
 
 		  return 0;
 	  }
-#endif
+#endif	  
+	/* Let Evo's libs load anjal as the default backend. */  
+	mail_mt_set_backend ("anjal");
+	create_default_shell ();
+
 	if (windowed)
 		anjal_icon_decoration = TRUE;
 
-	main_window = (GtkWidget *)mail_shell_new ();
-	gtk_widget_show (main_window);
-	mail_shell_set_cmdline_args ((MailShell *)main_window, remaining_args);
-#if HAVE_UNIQUE
-	g_signal_connect (app, "message-received",
-                    G_CALLBACK (mail_message_received_cb),  main_window);
-#endif
-	
-	g_idle_add ((GSourceFunc) idle_cb, main_window);
 
+	
 	gtk_main ();
+
+	default_shell = e_shell_get_default ();
+	g_object_unref (default_shell);
+	if (E_IS_SHELL (default_shell))
+		g_warning ("Shell not finalized on exit");
+	
 	e_icon_factory_shutdown ();
-	gnome_sound_shutdown ();
-	e_cursors_shutdown ();
 	
 #ifdef G_OS_WIN32
 	link_shutdown ();



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