[anjal] Support Account in tabs.



commit aa1d27b54221c46efbbe7f98313518d68b9d0d4d
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Wed Apr 29 11:38:41 2009 +0530

    Support Account in tabs.
---
 src/mail-account-view.c |   79 +++++++++++++++++++++++++++++++++++++++++++++++
 src/mail-account-view.h |    2 +
 2 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/src/mail-account-view.c b/src/mail-account-view.c
index 785b074..515ef67 100644
--- a/src/mail-account-view.c
+++ b/src/mail-account-view.c
@@ -28,6 +28,8 @@
 #include "mail-account-view.h"
 #include <libedataserver/e-account-list.h>
 #include "mail-component.h"
+#include "mail-view.h"
+#include "e-util/e-icon-factory.h"
 
 struct _MailAccountViewPrivate {
 	GtkWidget *tab_str;
@@ -35,6 +37,13 @@ struct _MailAccountViewPrivate {
 
 G_DEFINE_TYPE (MailAccountView, mail_account_view, GTK_TYPE_VBOX)
 
+enum {
+	VIEW_CLOSE,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
 static void
 mail_account_view_init (MailAccountView  *shell)
 {
@@ -58,6 +67,16 @@ mail_account_view_class_init (MailAccountViewClass *klass)
 
 	mail_account_view_parent_class = g_type_class_peek_parent (klass);
 	object_class->finalize = mail_account_view_finalize;
+
+	signals[VIEW_CLOSE] =
+		g_signal_new ("view-close",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (MailAccountViewClass , view_close),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+	
 }
 
 void
@@ -69,8 +88,68 @@ MailAccountView *
 mail_account_view_new ()
 {
 	MailAccountView *view = g_object_new (MAIL_ACCOUNT_VIEW_TYPE, NULL);
+	view->type = MAIL_VIEW_ACCOUNT;
+	view->uri = "account://";
 	mail_account_view_construct (view);
 	
 	return view;
 }
 
+static gboolean
+mav_btn_expose (GtkWidget *w, GdkEventExpose *event, MailAccountView *mfv)
+{
+	GdkPixbuf *img = g_object_get_data (w, "pbuf");
+	cairo_t *cr = gdk_cairo_create (w->window);
+	int wid = w->allocation.width;
+	int heig = w->allocation.height;
+	cairo_save (cr);
+	gdk_cairo_set_source_pixbuf (cr, img, event->area.x-4, event->area.y-5);
+	cairo_paint(cr);
+	cairo_restore(cr);
+	cairo_destroy (cr);
+
+	return TRUE;
+}
+
+static void
+mav_close (GtkButton *w, MailAccountView *mfv)
+{
+	g_signal_emit (mfv, signals[VIEW_CLOSE], 0);			
+}
+
+
+
+GtkWidget *
+mail_account_view_get_tab_widget(MailAccountView *mcv)
+{
+	GdkPixbuf *pbuf = e_icon_factory_get_icon ("gtk-close", E_ICON_SIZE_MENU);
+	GtkWidget *tool, *box, *img;
+	int w=-1, h=-1;
+	GtkWidget *tab_label;
+
+	img = gtk_image_new_from_pixbuf (pbuf);
+	g_object_set_data (img, "pbuf", pbuf);
+	g_signal_connect (img, "expose-event", mav_btn_expose, mcv);
+	
+	tool = gtk_button_new ();
+	gtk_button_set_relief(tool, GTK_RELIEF_NONE);
+	gtk_button_set_focus_on_click (tool, FALSE);
+	gtk_widget_set_tooltip_text (tool, _("Close Tab"));
+	g_signal_connect (tool, "clicked", G_CALLBACK(mav_close), mcv);
+	
+	box = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (box, img, FALSE, FALSE, 0);
+	gtk_container_add (tool, box);
+	gtk_widget_show_all (tool);
+	gtk_icon_size_lookup_for_settings (gtk_widget_get_settings(tool) , GTK_ICON_SIZE_MENU, &w, &h);
+	gtk_widget_set_size_request (tool, w+2, h+2);
+
+	box = gtk_label_new (_("Account Wizard"));
+	tab_label = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (tab_label, box, FALSE, FALSE, 0);
+	gtk_box_pack_start (tab_label, tool, FALSE, FALSE, 0);
+	gtk_widget_show_all (tab_label);
+
+	return tab_label;
+	
+}
diff --git a/src/mail-account-view.h b/src/mail-account-view.h
index b8a25fa..c9b8d01 100644
--- a/src/mail-account-view.h
+++ b/src/mail-account-view.h
@@ -49,6 +49,8 @@ typedef struct _MailAccountView {
 typedef struct _MailAccountViewClass {
 	GtkVBoxClass parent_class;
 
+	void (* view_close) (MailAccountView *);	
+
 } MailAccountViewClass;
 
 MailAccountView *mail_account_view_new (void);



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