[anjal] Added All four pages to mail account view.



commit 71280efde20ada4e7532ec768208a152d2735ba7
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Wed Apr 29 18:08:05 2009 +0530

    Added All four pages to mail account view.
---
 src/mail-account-view.c |  143 ++++++++++++++++++++++++++++++++++++++++++++++-
 src/mail-account-view.h |   76 ++++++++++++++++++++++++-
 2 files changed, 216 insertions(+), 3 deletions(-)

diff --git a/src/mail-account-view.c b/src/mail-account-view.c
index 515ef67..8df19b8 100644
--- a/src/mail-account-view.c
+++ b/src/mail-account-view.c
@@ -79,9 +79,150 @@ mail_account_view_class_init (MailAccountViewClass *klass)
 	
 }
 
+static gint
+provider_compare (const CamelProvider *p1, const CamelProvider *p2)
+{
+	/* sort providers based on "location" (ie. local or remote) */
+	if (p1->flags & CAMEL_PROVIDER_IS_REMOTE) {
+		if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
+			return 0;
+		return -1;
+	} else {
+		if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
+			return 1;
+		return 0;
+	}
+}
+
+struct _page_text {
+	char *head;
+	char *next;
+	char *prev;
+} mail_account_pages[] = {
+	{ N_("Identity"), N_("Next - Receiving mail"), NULL },
+	{ N_("Receiving mail"), N_("Next - Sending mail"), N_("Back - Identity")},
+	{ N_("Sending mail"), N_("Next - Review account"), N_("Back - Receiving mail")},
+	{ N_("Review account"), N_("Finish"), N_("Back - Sending")},
+};
+
+static void
+mav_next_pressed (GtkButton *button, MailAccountView *mav)
+{
+	if (mav->current_page == MAV_LAST - 1)
+		return;
+
+	gtk_widget_hide (mav->pages[mav->current_page]->box);
+	mav->current_page++;
+	gtk_widget_show (mav->pages[mav->current_page]->box);
+}
+
+static void
+mav_prev_pressed (GtkButton *button, MailAccountView *mav)
+{
+	if (mav->current_page == 0)
+		return;
+
+	gtk_widget_hide (mav->pages[mav->current_page]->box);
+	mav->current_page--;
+	gtk_widget_show (mav->pages[mav->current_page]->box);
+
+}
+
+
+static GtkWidget *
+mav_construct_page(MailAccountView *view, MAVPageType type)
+{
+	MAVPage *page = g_new0(MAVPage, 1);
+	GtkWidget *box, *tmp;
+	char *str;
+
+	page->type = type;
+
+	page->box = gtk_vbox_new (FALSE, 2);
+	
+	tmp = gtk_label_new (NULL);
+	str = g_strdup_printf("<span  size=\"x-large\">%s</span>", mail_account_pages[type].head);
+	gtk_label_set_markup (tmp, str);
+	g_free(str);
+	gtk_widget_show (tmp);
+	gtk_box_pack_start(page->box, tmp, FALSE, FALSE, 3);
+
+	if (mail_account_pages[type].prev) {
+		box = gtk_hbox_new(FALSE, 0);
+		tmp = gtk_image_new_from_pixbuf (e_icon_factory_get_icon("go-previous", E_ICON_SIZE_BUTTON));
+		gtk_box_pack_start(box, tmp, FALSE, FALSE, 0);
+		tmp = gtk_label_new (mail_account_pages[type].prev);
+		gtk_box_pack_start(box, tmp, FALSE, FALSE, 3);
+		page->prev = gtk_button_new ();
+		gtk_container_add (page->prev, box);
+		gtk_widget_show_all(page->prev);
+		g_signal_connect(page->prev, "clicked", G_CALLBACK(mav_prev_pressed), view);
+	}
+
+	if (mail_account_pages[type].next) {
+		box = gtk_hbox_new(FALSE, 0);
+		tmp = gtk_label_new (mail_account_pages[type].next);
+		gtk_box_pack_start(box, tmp, FALSE, FALSE, 3);
+		tmp = gtk_image_new_from_pixbuf (e_icon_factory_get_icon("go-next", E_ICON_SIZE_BUTTON));
+		gtk_box_pack_start(box, tmp, FALSE, FALSE, 0);
+		page->next = gtk_button_new ();
+		gtk_container_add (page->next, box);
+		gtk_widget_show_all(page->next);
+		g_signal_connect(page->next, "clicked", G_CALLBACK(mav_next_pressed), view);
+	}
+
+	box = gtk_hbox_new (FALSE, 0);
+	if (page->prev)
+		gtk_box_pack_start (box, page->prev, FALSE, FALSE, 12);
+	if (page->next)
+		gtk_box_pack_end (box, page->next, FALSE, FALSE, 12);
+	gtk_widget_show (box);
+	gtk_box_pack_end (page->box, box, FALSE, FALSE, 6);
+	gtk_widget_show(page->box);
+
+	return page;
+}
+
 void
-mail_account_view_construct (MailAccountView *acview)
+mail_account_view_construct (MailAccountView *view)
 {
+	int i;
+	
+	view->scroll = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_policy (view->scroll, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (view->scroll, GTK_SHADOW_NONE);
+	view->page_widget = gtk_vbox_new (FALSE, 3);
+	gtk_scrolled_window_add_with_viewport (view->scroll, view->page_widget);
+	gtk_widget_show_all (view->scroll);
+	
+	if (view->original) {
+		char *xml;
+
+		g_object_ref(view->original);
+		xml = e_account_to_xml(view->original);
+		view->account = e_account_new_from_xml(xml);
+		g_free(xml);
+
+		//view->do_signature = TRUE;		
+	} else {
+		/* TODO: have a get_default_account thing?? */
+		view->account = e_account_new();
+		view->account->enabled = TRUE;
+		e_account_set_string(view->account, E_ACCOUNT_DRAFTS_FOLDER_URI,
+				     mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS));
+		e_account_set_string(view->account, E_ACCOUNT_SENT_FOLDER_URI,
+				     mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT));		
+	}
+	view->providers = g_list_sort(camel_provider_list(TRUE), (GCompareFunc)provider_compare);
+	
+	for (i=0; i<MAV_LAST; i++) {
+		view->pages[i] = mav_construct_page (view, i);
+		gtk_box_pack_start (view->page_widget, view->pages[i]->box, TRUE, TRUE, 0);
+		gtk_widget_hide (view->pages[i]->box);
+	}
+	gtk_widget_show (view->pages[0]->box);
+	view->current_page = 0;
+	gtk_box_pack_start (view, view->scroll, TRUE, TRUE, 0);
 }
 
 MailAccountView *
diff --git a/src/mail-account-view.h b/src/mail-account-view.h
index c9b8d01..6dad80a 100644
--- a/src/mail-account-view.h
+++ b/src/mail-account-view.h
@@ -25,6 +25,8 @@
 
 #include <gtk/gtk.h>
 #include <webkit/webkit.h>
+#include <libedataserver/e-account-list.h>
+#include <camel/camel-provider.h>
 
 #define MAIL_ACCOUNT_VIEW_TYPE        (mail_account_view_get_type ())
 #define MAIL_ACCOUNT_VIEW(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_ACCOUNT_VIEW_TYPE, MailFolderView))
@@ -33,9 +35,25 @@
 #define IS_MAIL_ACCOUNT_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MAIL_ACCOUNT_VIEW_TYPE))
 #define MAIL_ACCOUNT_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MAIL_ACCOUNT_VIEW_TYPE, MailFolderViewClass))
 
-struct _EAccount;
-
 typedef struct _MailAccountViewPrivate MailAccountViewPrivate;
+typedef struct _MailAccountService MailAccountService;
+
+typedef enum {
+	MAV_IDENTITY_PAGE=0,
+	MAV_RECV_PAGE,
+	MAV_SEND_PAGE,
+	MAV_REVIEW_PAGE,
+	MAV_LAST,
+} MAVPageType;
+
+typedef struct _MAVPage {
+	GtkWidget *box;
+	MAVPageType type;
+	GtkWidget *next;
+	GtkWidget *prev;
+}MAVPage;
+
+
 
 typedef struct _MailAccountView {
 	GtkVBox parent;
@@ -43,6 +61,19 @@ typedef struct _MailAccountView {
 	char *uri;
 	/* Base class of MailChildView ends */
 
+	GtkWidget *scroll;
+	GtkWidget *page_widget;
+	EAccount *original;
+	EAccount *account;
+
+	GList *providers;
+
+	MAVPage *pages[4];
+	int current_page;
+
+	MailAccountService *source;
+	MailAccountService *transport;
+
 	MailAccountViewPrivate *priv;
 } MailAccountView;
 
@@ -53,6 +84,47 @@ typedef struct _MailAccountViewClass {
 
 } MailAccountViewClass;
 
+struct _MailAccountService {
+	MailAccountView *mav;
+
+	/* NOTE: keep all widgets together, first frame last check_dialog */
+	struct _GtkWidget *frame;
+	struct _GtkWidget *container;
+
+	struct _GtkComboBox *providers;
+
+	struct _GtkLabel *description;
+	struct _GtkLabel *hostlabel;
+	struct _GtkEntry *hostname;
+	struct _GtkLabel *userlabel;
+	struct _GtkEntry *username;
+	struct _GtkEntry *path;
+	struct _GtkLabel *pathlabel;
+	struct _GtkWidget *pathentry;
+
+	struct _GtkWidget *ssl_frame;
+	struct _GtkComboBox *use_ssl;
+	struct _GtkWidget *ssl_hbox;
+	struct _GtkWidget *no_ssl;
+
+	struct _GtkWidget *auth_frame;
+	struct _GtkComboBox *authtype;
+
+	struct _GtkWidget *authitem;
+	struct _GtkToggleButton *remember;
+	struct _GtkButton *check_supported;
+	struct _GtkToggleButton *needs_auth;
+
+	struct _GtkWidget *check_dialog;
+	int check_id;
+
+	GList *authtypes;	/* if "Check supported" */
+	CamelProvider *provider;
+	CamelProviderType type;
+
+	int auth_changed_id;
+};
+
 MailAccountView *mail_account_view_new (void);
 
 #endif



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