[anjal] Anjal Settings in Control Center. Initial commit for that.



commit d947e42b8c34b78aa743257231f7aa35005ecce7
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Mon Jan 11 12:06:29 2010 +0530

    Anjal Settings in Control Center. Initial commit for that.

 Makefile.am               |    4 +-
 anjal-settings.desktop.in |   11 +
 po/POTFILES.in            |    3 +
 src/Makefile.am           |   36 ++++-
 src/anjal-settings-main.c |  315 +++++++++++++++++++++++++++++++
 src/mail-capplet-shell.c  |  449 +++++++++++++++++++++++++++++++++++++++++++++
 src/mail-capplet-shell.h  |   58 ++++++
 src/mail-message-view.c   |    2 +-
 src/mail-settings-view.c  |    2 +
 src/mail-view.c           |   44 ++++-
 10 files changed, 918 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9d695fd..f32672d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS = art src po
 desktopdir = $(datadir)/applications
-desktop_in_files = anjal.desktop.in
+desktop_in_files = anjal.desktop.in \
+		   anjal-settings.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
@@ -35,6 +36,7 @@ dist-hook:
 		echo A git clone is required to generate a ChangeLog >&2; \
 	fi
 EXTRA_DIST = anjal.desktop.in \
+	     anjal-settings.desktop.in \
 	     intltool-extract.in \
 	     intltool-merge.in \
 	     intltool-update.in
diff --git a/anjal-settings.desktop.in b/anjal-settings.desktop.in
new file mode 100644
index 0000000..8ee7b47
--- /dev/null
+++ b/anjal-settings.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+_Name=Email Settings
+_GenericName=Email Settings
+_Comment=Configure email accounts
+Exec=anjal-settings
+Icon=evolution
+Terminal=false
+Type=Application
+Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;
+OnlyShowIn=GNOME;
+StartupNotify=true
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4985da5..d26a99c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -5,6 +5,8 @@ src/custom-cell-renderer-toggle-pixbuf.c
 src/custom-cell-renderer-hbox.c
 src/custom-cell-renderer-vbox.c
 src/em-tree-store.c
+src/anjal-settings-main.c
+src/mail-capplet-shell.c
 src/mail-component.c
 src/mail-composer-view.c
 src/mail-conv-view.c
@@ -26,3 +28,4 @@ src/mail-people-view.c
 src/anjal.schemas.in
 src/anjal.xml.in
 anjal.desktop.in
+anjal-settings.desktop.in
diff --git a/src/Makefile.am b/src/Makefile.am
index 45ce449..335fa76 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,25 @@ AM_CFLAGS =\
 	 -Wall\
 	 -g -O0 
 
-bin_PROGRAMS = anjal
+bin_PROGRAMS = anjal \
+	       anjal-settings
+
+anjal_settings_SOURCES  = \
+	anjal-settings-main.c \
+	mail-settings-view.c \
+	mail-settings-view.h \
+	mail-account-view.c \
+	mail-account-view.h \
+	mail-view.c \
+	mail-view.h \
+	mail-capplet-shell.c \
+	mail-capplet-shell.h \
+	mail-decoration.c \
+	mail-decoration.h \
+	anjal-mail-view.h \
+	anjal-mail-view.c
+
+anjal_settings_CFLAGS = -DANJAL_SETTINGS
 
 anjal_SOURCES = \
 	main.c \
@@ -96,6 +114,22 @@ anjal_SOURCES += mail-people-view.c \
 		 mail-people-view.h
 endif
 
+
+anjal_settings_LDFLAGS = \
+	-Wl,--export-dynamic
+
+anjal_settings_LDADD = $(ANJAL_LIBS) \
+	$(MOZILLA_LIBS) \
+	$(WEBKIT_LIBS) \
+	$(UNIQUE_LIBS) \
+	$(ANERLEY_LIBS) \
+	$(CLUTTER_LIBS) \
+	$(MANUAL_NSPR_LIBS) \
+	$(MANUAL_NSS_LIBS) \
+	-lemiscwidgets \
+	-lfilter \
+	-L"$(evolutionprivdir)/anjal"
+
 anjal_LDFLAGS = \
 	-Wl,--export-dynamic
 
diff --git a/src/anjal-settings-main.c b/src/anjal-settings-main.c
new file mode 100644
index 0000000..0999f7e
--- /dev/null
+++ b/src/anjal-settings-main.c
@@ -0,0 +1,315 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan novell com>
+ *
+ * Copyright (C) 2009 Intel Corporation (www.intel.com)
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <glib/gi18n.h>
+#include <libedataserverui/e-passwords.h>
+#include <mail/mail-mt.h>
+#include "mail-shell.h"
+#include <gconf/gconf-client.h>
+#include <libedataserver/e-categories.h>
+#include <dbus/dbus-glib.h>
+
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
+#if HAVE_UNIQUE
+#include <unique/unique.h>
+#endif
+
+gboolean windowed = FALSE;
+gboolean anjal_icon_decoration = FALSE;
+gboolean default_app =  FALSE;
+MailShell *main_window;
+static gchar **remaining_args;
+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"
+#define ANJAL_MAILTO_COMMAND "anjal %s"
+
+#if HAVE_UNIQUE
+static UniqueResponse
+mail_message_received_cb (UniqueApp         *app G_GNUC_UNUSED,
+                         gint               command,
+                         UniqueMessageData *message_data,
+                         guint              time_ G_GNUC_UNUSED,
+                         gpointer           user_data)
+{
+	 gchar *url;
+	 GtkWindow *window = (GtkWindow *) user_data;
+	 char *args[2];
+	 
+	 switch (command) {
+	 case UNIQUE_ACTIVATE :
+		  gtk_window_deiconify (window);
+		  gtk_window_present (window);
+		  return UNIQUE_RESPONSE_OK;
+
+	 case UNIQUE_NEW :
+		  return UNIQUE_RESPONSE_OK;
+
+	 case UNIQUE_OPEN :
+		  url = unique_message_data_get_text (message_data);
+		  args[0] = url;
+		  args[1] = NULL;
+		  //mail_shell_set_cmdline_args ((MailShell *)window, args);
+		  //mail_shell_handle_cmdline ((MailShell *)window);
+		  g_free (url);
+		  gdk_window_raise (((GtkWidget *)window)->window);
+		  gtk_window_deiconify (window);
+		  gtk_window_present (window);
+
+		  return UNIQUE_RESPONSE_OK;
+	 }
+
+	 return UNIQUE_RESPONSE_PASSTHROUGH;
+}
+#endif
+
+static void
+categories_icon_theme_hack (void)
+{
+	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
+check_and_set_default_mail (void)
+{
+	GConfClient *client = gconf_client_get_default ();
+	gchar *mailer;
+
+	mailer  = gconf_client_get_string(client, GCONF_KEY_MAILTO_COMMAND, NULL);
+	if (mailer && *mailer && (strcmp (mailer, ANJAL_MAILTO_COMMAND) == 0)) {
+		g_object_unref (client);
+		return; /* Anjal is the default mailer */
+	}
+	
+	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);
+}
+
+static gboolean
+idle_cb (MailShell *mshell G_GNUC_UNUSED)
+{
+	
+	if (default_app) {
+		check_and_set_default_mail ();
+	}
+
+
+
+	return FALSE;
+}
+
+static void
+create_default_shell (void)
+{
+	main_window = mail_capplet_shell_new();
+	gtk_widget_show (main_window);
+	g_idle_add ((GSourceFunc) idle_cb, remaining_args);
+}
+
+int
+main (int argc, char *argv[])
+{
+	GError *error = NULL;
+	EShell *default_shell;
+	GConfClient *client = gconf_client_get_default();
+#if HAVE_UNIQUE	
+	UniqueApp *app;
+#endif
+
+#ifdef G_OS_WIN32
+	extern void link_shutdown (void);
+	set_paths ();
+#endif
+
+	static GOptionEntry entries[] = {
+		{ "windowed", 'w', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &windowed,N_("Run Anjal in a window"), NULL },
+		{ "default-mailer", 'd', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &default_app,N_("Make Anjal the default email client"), NULL },
+		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, NULL },
+		{ NULL, 0, 0, 0, NULL, NULL, NULL }
+	};
+
+#ifdef ENABLE_NLS
+	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+#endif
+
+	
+	gtk_set_locale ();
+
+	if (!gtk_init_with_args (&argc, &argv, _("Anjal email client"), entries, NULL, &error)) {
+		g_error ("Unable to start Anjal: %s\n", error->message);
+		g_error_free(error);
+	}
+
+	if (!g_thread_get_initialized ())
+		g_thread_init (NULL);
+	dbus_g_thread_init ();
+
+	e_passwords_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");
+	categories_icon_theme_hack ();
+
+	gconf_client_set_bool (client, "/apps/evolution/mail/display/enable_vfolders", FALSE, NULL);
+	g_object_unref (client);
+	
+	app = unique_app_new ("org.gnome.AnjalSettings", NULL);
+	  if (unique_app_is_running (app))  {
+		   gboolean cmd_line =  (remaining_args && remaining_args[0] != NULL);
+		   
+		  if (!cmd_line)
+			unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+		  else {
+			  UniqueMessageData *data = unique_message_data_new ();
+			  unique_message_data_set_text (data, remaining_args[0], -1);
+			  unique_app_send_message (app, UNIQUE_OPEN, data);
+			  unique_message_data_free (data);
+		  }
+
+		  return 0;
+	  }
+
+	create_default_shell ();
+
+#if HAVE_UNIQUE	
+	g_signal_connect (UNIQUE_APP(app), "message-received",
+                    G_CALLBACK (mail_message_received_cb),  main_window);
+#endif
+
+	if (windowed)
+		anjal_icon_decoration = TRUE;
+	
+	gtk_main ();
+
+	
+#ifdef G_OS_WIN32
+	link_shutdown ();
+#endif
+	return 0;
+}
+
+#ifndef HACK
+gpointer em_format_html_print_new(gpointer p1 G_GNUC_UNUSED,
+				  int i G_GNUC_UNUSED)
+{
+	return NULL;
+}
+
+void em_format_html_print_raw_message (gpointer p1 G_GNUC_UNUSED,
+				       gpointer p2 G_GNUC_UNUSED)
+{
+	return ;
+}
+
+void 
+eab_merging_book_commit_contact ()
+{
+}
+
+void 
+e_searching_tokenizer_set_primary_case_sensitivity ()
+{
+}
+
+void 
+eab_prompt_save_dialog ()
+{
+}
+
+void
+eab_merging_book_add_contact ()
+{
+}
+
+void
+e_searching_tokenizer_match_count ()
+{
+}
+
+void
+addressbook_load_cancel()
+{
+}
+
+void
+e_searching_tokenizer_new ()
+{
+}
+
+void
+e_searching_tokenizer_set_primary_search_string()
+{
+}
+
+void
+addressbook_load()
+{
+}
+
+void
+eab_load_error_dialog()
+{
+}
+
+#endif
diff --git a/src/mail-capplet-shell.c b/src/mail-capplet-shell.c
new file mode 100644
index 0000000..6541593
--- /dev/null
+++ b/src/mail-capplet-shell.c
@@ -0,0 +1,449 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan gnome org>
+ *		Srinivasa Ragavan <srini linux intel com>
+ *
+ * Copyright (C) 2010 Intel Corporation. (www.intel.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gconf/gconf-client.h>
+#include "mail-capplet-shell.h"	
+#include "mail-view.h"
+#include <gdk/gdkkeysyms.h>
+#include "mail-decoration.h"
+#include <mail/em-utils.h>
+#include <mail/em-composer-utils.h>
+enum {
+	CTRL_W_PRESSED,
+	CTRL_Q_PRESSED,
+	LAST_SIGNAL
+};
+
+/* Re usable colors */
+
+GdkColor *pcolor_sel;
+char *scolor_sel;
+GdkColor *pcolor_fg_sel;
+char *scolor_fg_sel;
+GdkColor *pcolor_bg_norm;
+char *scolor_bg_norm;
+GdkColor *pcolor_norm;
+char *scolor_norm;
+GdkColor *pcolor_fg_norm;
+char *scolor_fg_norm;
+
+static guint mail_capplet_shell_signals[LAST_SIGNAL];
+
+extern gboolean windowed;
+
+struct  _MailCappletShellPrivate {
+
+	GtkWidget *box;
+	
+	GtkWidget * top_bar;
+	GtkWidget *message_pane;
+	GtkWidget *bottom_bar;
+
+	/* Top Bar */
+	GtkWidget *action_bar;
+	GtkWidget *quit;	
+	
+	MailViewChild *settings_view;
+};
+
+static void mail_capplet_shell_quit (MailCappletShell *shell);
+
+G_DEFINE_TYPE (MailCappletShell, mail_capplet_shell, GTK_TYPE_WINDOW)
+
+static void setup_abooks (void);
+
+static void
+mail_capplet_shell_init (MailCappletShell  *shell)
+{
+	shell->priv = g_new0(MailCappletShellPrivate, 1);
+	shell->priv->settings_view = NULL;
+}
+
+static void
+mail_capplet_shell_finalize (GObject *object)
+{
+	G_OBJECT_CLASS (mail_capplet_shell_parent_class)->finalize (object);
+}
+
+static void
+ms_ctrl_w_pressed (MailCappletShell *shell)
+{
+	MailCappletShellPrivate *priv = shell->priv;
+
+	mail_view_close_view ((MailView *)shell->view);
+}
+
+static void
+ms_ctrl_q_pressed (MailCappletShell *shell)
+{
+	mail_capplet_shell_quit (shell);
+}	
+
+static void
+mail_capplet_shell_class_init (MailCappletShellClass *klass)
+{
+	GObjectClass * object_class = G_OBJECT_CLASS (klass);
+	GtkBindingSet *binding_set;
+
+	mail_capplet_shell_parent_class = g_type_class_peek_parent (klass);
+	object_class->finalize = mail_capplet_shell_finalize;
+	klass->ctrl_w_pressed = ms_ctrl_w_pressed;
+	klass->ctrl_q_pressed = ms_ctrl_q_pressed;
+
+	mail_capplet_shell_signals [CTRL_W_PRESSED] =
+		g_signal_new ("ctrl_w_pressed",
+				G_TYPE_FROM_CLASS (object_class),
+					  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+				G_STRUCT_OFFSET (MailCappletShellClass, ctrl_w_pressed),
+				NULL, NULL,
+				g_cclosure_marshal_VOID__VOID,
+				G_TYPE_NONE, 0);
+	
+	mail_capplet_shell_signals [CTRL_Q_PRESSED] =
+		g_signal_new ("ctrl_q_pressed",
+				G_TYPE_FROM_CLASS (object_class),
+					  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+				G_STRUCT_OFFSET (MailCappletShellClass, ctrl_q_pressed),
+				NULL, NULL,
+				g_cclosure_marshal_VOID__VOID,
+				G_TYPE_NONE, 0);
+
+	binding_set = gtk_binding_set_by_class (klass);
+	gtk_binding_entry_add_signal (binding_set, GDK_W, GDK_CONTROL_MASK, "ctrl_w_pressed", 0);
+	gtk_binding_entry_add_signal (binding_set, GDK_w, GDK_CONTROL_MASK, "ctrl_w_pressed", 0);
+	gtk_binding_entry_add_signal (binding_set, GDK_Q, GDK_CONTROL_MASK, "ctrl_q_pressed", 0);
+	gtk_binding_entry_add_signal (binding_set, GDK_Q, GDK_CONTROL_MASK, "ctrl_q_pressed", 0);
+
+};
+
+static int
+color_expose (GtkWidget *w,
+	      GdkEventExpose *event G_GNUC_UNUSED,
+	      gpointer data)
+{
+	GtkWindow *win = (GtkWindow *)data;
+	cairo_t *cr = gdk_cairo_create (w->window);
+	int wid = w->allocation.width;
+	int heig = w->allocation.height;
+	int wwid, wheig;
+	GdkColor paint;
+
+	gtk_window_get_size (win, &wwid, &wheig);
+	gdk_color_parse ("#000000", &paint);
+	gdk_cairo_set_source_color (cr,  &(paint));
+	cairo_rectangle (cr, 0, 0, wwid, wheig);
+	cairo_stroke (cr);
+
+	gdk_color_parse ("#000000", &paint);
+	gdk_cairo_set_source_color (cr,  &(paint));
+	cairo_rectangle (cr, 1, 1, wid, heig);
+	cairo_fill (cr);
+
+	cairo_destroy (cr);
+
+	return FALSE;
+}
+
+
+
+static void
+ms_init_style (GtkStyle *style)
+{
+	 pcolor_sel = &style->base[GTK_STATE_SELECTED];
+	 scolor_sel =  gdk_color_to_string (pcolor_sel);
+
+	 pcolor_norm = &style->bg[GTK_STATE_NORMAL];
+	 scolor_norm =  gdk_color_to_string (pcolor_norm);
+
+	 pcolor_bg_norm = &style->base[GTK_STATE_NORMAL];
+	 scolor_bg_norm = gdk_color_to_string (pcolor_bg_norm);
+
+	 pcolor_fg_sel =&style->fg[GTK_STATE_SELECTED];
+	 scolor_fg_sel = gdk_color_to_string (pcolor_fg_sel);
+
+	 pcolor_fg_norm =&style->fg[GTK_STATE_NORMAL];
+	 scolor_fg_norm = gdk_color_to_string (pcolor_fg_norm);
+}
+
+static void
+mail_capplet_shell_quit (MailCappletShell *shell)
+{
+	gtk_main_quit();
+}
+
+static void
+mail_capplet_shell_quit_cb (GtkWidget *w G_GNUC_UNUSED,
+		    MailCappletShell *shell)
+{
+	mail_capplet_shell_quit (shell);
+}
+
+static void
+ms_delete_event (MailCappletShell *shell,
+		 GdkEvent *event G_GNUC_UNUSED,
+		 gpointer data G_GNUC_UNUSED)
+{
+	mail_capplet_shell_quit (shell);
+}
+
+static gboolean 
+ms_check_new ()
+{
+	GConfClient *client;
+	GSList *accounts;
+
+	client = gconf_client_get_default ();
+	accounts = gconf_client_get_list (client, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL);
+	g_object_unref (client);
+
+	if (accounts != NULL) {
+		g_slist_foreach (accounts, (GFunc) g_free, NULL);
+		g_slist_free (accounts);
+
+		return FALSE;
+	}
+	
+	return TRUE;
+}
+
+
+static void
+ms_show_post_druid (MailViewChild *mfv G_GNUC_UNUSED,
+		    MailCappletShell *shell)
+{
+	if (shell->priv->settings_view)
+		mail_view_switch_to_settings ((MailView *)shell->view, (MailViewChild *)shell->priv->settings_view);
+	else {
+		shell->priv->settings_view = mail_view_add_page ((MailView *)shell->view, MAIL_VIEW_SETTINGS, NULL);
+	}
+
+}
+
+#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, MailCappletShell *shell)
+{
+	g_signal_handlers_block_by_func (mv, handle_cmdline, shell);
+	mail_capplet_shell_handle_cmdline (shell);
+}
+
+void
+mail_capplet_shell_construct (MailCappletShell *shell)
+{
+	MailCappletShellPrivate *priv = shell->priv;
+	GtkWidget *tmp, *img, *box, *ar1, *ar2, *lbl;
+	GtkStyle *style = gtk_widget_get_default_style ();
+	int window_width = 1024;
+	char *custom_dir;
+
+	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);
+	}
+
+
+	priv->box = (GtkWidget *) gtk_vbox_new (FALSE, 0);
+	gtk_widget_show ((GtkWidget *)priv->box);
+	
+	/* Toolbar */
+	priv->top_bar = gtk_toolbar_new ();
+	gtk_box_pack_start ((GtkBox *)priv->box, priv->top_bar, FALSE, FALSE, 0);
+	gtk_widget_show (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);	*/
+	}
+
+	/* Label */
+	tmp = gtk_tool_item_new ();
+	gtk_tool_item_set_expand(tmp, FALSE);
+	lbl = gtk_label_new (_("Email Settings"));
+	gtk_container_add (tmp, lbl);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 0);
+	gtk_widget_show_all (tmp);
+
+	tmp = gtk_tool_item_new ();
+	gtk_tool_item_set_expand(tmp, TRUE);
+	lbl = gtk_label_new (NULL);
+	gtk_container_add (tmp, lbl);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, tmp, 1);
+	gtk_widget_show_all (tmp);	
+
+	/* Close button */
+	PACK_IN_TOOL(priv->quit, "gtk-close");
+	gtk_widget_set_tooltip_text(priv->quit, _("Quit"));
+	gtk_tool_item_set_expand (priv->quit, FALSE);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->quit, -1);
+	gtk_widget_show_all (priv->quit);
+	g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_capplet_shell_quit_cb), shell);
+	
+	gtk_container_add ((GtkContainer *)shell, priv->box);
+	
+	shell->view = mail_view_new ();
+	gtk_widget_show (shell->view);
+	tmp = gtk_vbox_new (FALSE, 0);
+	gtk_box_pack_end ((GtkBox *)priv->box, shell->view, TRUE, TRUE, 2);
+
+	/* This also initializes Camel, so it needs to happen early. */
+	mail_session_init ();
+	mail_config_init ();
+	mail_msg_init ();
+	custom_dir = g_build_filename (e_get_user_data_dir (), "mail", NULL);
+	e_mail_store_init (custom_dir);
+	g_free (custom_dir);
+	
+	if (ms_check_new()) {
+		MailViewChild *mc;
+		char *pdir = g_build_filename (g_get_home_dir(), ".gnome2_private", NULL);
+
+		mc = mail_view_add_page ((MailView *)shell->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);
+	} else 
+		shell->priv->settings_view = mail_view_add_page ((MailView *)shell->view, MAIL_VIEW_SETTINGS, NULL);
+
+
+}
+
+int
+mail_capplet_shell_toolbar_height (MailCappletShell *shell)
+{
+	return shell->priv->top_bar->allocation.height;
+}
+
+MailCappletShell *
+mail_capplet_shell_new ()
+{
+	MailCappletShell *shell = g_object_new (MAIL_CAPPLET_SHELL_TYPE, NULL);
+	mail_capplet_shell_construct (shell);
+
+	return shell;
+}
+
+#define PERSONAL_RELATIVE_URI "system"
+
+static void
+setup_abooks()
+{
+	char *base_dir, *uri;
+	GSList *groups;
+	ESourceGroup *group;
+	ESourceList *list = NULL;
+	ESourceGroup *on_this_computer = NULL;
+	ESource *personal_source = NULL;
+
+	base_dir = g_build_filename (e_get_user_data_dir (), "addressbook", "local", NULL);
+	uri = g_filename_to_uri (base_dir, NULL, NULL);
+	
+	if (!e_book_get_addressbooks(&list, NULL)) {
+		g_warning ("Unable to get books\n");
+		return;
+	}
+
+	groups = e_source_list_peek_groups (list);
+	if (groups) {
+		/* groups are already there, we need to search for things... */
+		GSList *g;
+
+		for (g = groups; g; g = g->next) {
+
+			group = E_SOURCE_GROUP (g->data);
+
+			if (!on_this_computer && !strcmp (uri, e_source_group_peek_base_uri (group))) {
+				on_this_computer = g_object_ref (group);
+				break;
+			}
+		}
+	}
+	
+	if (on_this_computer) {
+		/* make sure "Personal" shows up as a source under
+		   this group */
+		GSList *sources = e_source_group_peek_sources (on_this_computer);
+		GSList *s;
+		for (s = sources; s; s = s->next) {
+			ESource *source = E_SOURCE (s->data);
+			const gchar *relative_uri;
+
+			relative_uri = e_source_peek_relative_uri (source);
+			if (relative_uri == NULL)
+				continue;
+			if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
+				personal_source = g_object_ref (source);
+				break;
+			}
+		}
+	}
+	else {
+		/* create the local source group */
+		group = e_source_group_new (_("On This Computer"), uri);
+		e_source_list_add_group (list, group, -1);
+
+		on_this_computer = group;
+	}
+
+	if (!personal_source) {
+		/* Create the default Person addressbook */
+		ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
+		e_source_group_add_source (on_this_computer, source, -1);
+
+		e_source_set_property (source, "completion", "true");
+
+		personal_source = source;
+	}
+
+	if (on_this_computer)
+		g_object_unref (on_this_computer);
+	if (personal_source)
+		g_object_unref (personal_source);
+	
+	e_source_list_sync (list, NULL);
+	g_object_unref (list);
+	g_free (uri);
+	g_free (base_dir);
+}
+
diff --git a/src/mail-capplet-shell.h b/src/mail-capplet-shell.h
new file mode 100644
index 0000000..a8750e0
--- /dev/null
+++ b/src/mail-capplet-shell.h
@@ -0,0 +1,58 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan gnome org>
+ *		Srinivasa Ragavan <srini linux intel com>
+ *
+ * Copyright (C) 2010 Intel Corporation. (www.intel.com)
+ *
+ */
+
+#ifndef _MAIL_CAPPLET_SHELL_H_
+#define _MAIL_CAPPLET_SHELL_H_
+
+#include <gtk/gtk.h>
+#include "mail-view.h"
+
+#define MAIL_CAPPLET_SHELL_TYPE        (mail_capplet_shell_get_type ())
+#define MAIL_CAPPLET_SHELL(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_CAPPLET_SHELL_TYPE, MailCappletShell))
+#define MAIL_CAPPLET_SHELL_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), MAIL_CAPPLET_SHELL_TYPE, MailCappletShellClass))
+#define IS_MAIL_CAPPLET_SHELL(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), MAIL_CAPPLET_SHELL_TYPE))
+#define IS_MAIL_CAPPLET_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MAIL_CAPPLET_SHELL_TYPE))
+#define MAIL_CAPPLET_SHELL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MAIL_CAPPLET_SHELL_TYPE, MailCappletShellClass))
+
+typedef struct _MailCappletShellPrivate MailCappletShellPrivate;
+
+typedef struct _MailCappletShell {
+	GtkWindow parent;
+	MailView *view;
+
+	MailCappletShellPrivate *priv;
+} MailCappletShell;
+
+typedef struct _MailCappletShellClass {
+	GtkWindowClass parent_class;
+
+	void (* ctrl_w_pressed)    (MailCappletShell *class);
+	void (* ctrl_q_pressed)    (MailCappletShell *class);	
+} MailCappletShellClass;
+
+MailCappletShell * mail_capplet_shell_new (void);
+int mail_capplet_shell_toolbar_height (MailCappletShell *shell);
+
+#endif
+
+
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index f3f97af..3d3ccdf 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -1506,7 +1506,7 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	gtk_widget_hide (vbox);
 	mmview->priv->spinner = vbox;
 #if !HAVE_CLUTTER	
-	gtk_box_pack_start ((GtkBox *)mmview->body, mmview->priv->spinner, FALSE, FALSE, 0);
+	//gtk_box_pack_start ((GtkBox *)mmview->body, mmview->priv->spinner, FALSE, FALSE, 0);
 #endif
 	gtk_box_pack_start ((GtkBox *)mmview->priv->total_box, mmview->body, FALSE, FALSE, 2);
 
diff --git a/src/mail-settings-view.c b/src/mail-settings-view.c
index 1fe6707..ec80f2c 100644
--- a/src/mail-settings-view.c
+++ b/src/mail-settings-view.c
@@ -278,7 +278,9 @@ mail_settings_view_get_tab_widget(MailSettingsView *mcv)
 	box = gtk_label_new (_("Settings"));
 	tab_label = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start ((GtkBox *)tab_label, box, FALSE, FALSE, 0);
+#ifndef ANJAL_SETTINGS	
 	gtk_box_pack_start ((GtkBox *)tab_label, tool, FALSE, FALSE, 0);
+#endif	
 	gtk_widget_show_all (tab_label);
 
 	return tab_label;
diff --git a/src/mail-view.c b/src/mail-view.c
index 6a92043..39f360f 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -28,10 +28,14 @@
 #include "mail/mail-send-recv.h"
 #include "mail/mail-ops.h"
 #include "mail-view.h"
+#ifndef ANJAL_SETTINGS
 #include "mail-folder-view.h"
 #include "mail-composer-view.h"
 #include "mail-conv-view.h"
+#endif
+
 #include "mail-settings-view.h"
+
 #if HAVE_ANERLEY
 #  include "mail-people-view.h"
 #endif
@@ -61,7 +65,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
 #undef MV_NEW_TAB
 
 G_DEFINE_TYPE (MailView, mail_view, ANJAL_MAIL_VIEW_TYPE)
+#ifndef ANJAL_SETTINGS
 static MailConvView * mv_switch_message_view (MailView *mv, const char *uri);
+#endif
+
 void anjal_shell_view_restore_state (EShellView *view, const char *uri);
 
 static void
@@ -90,7 +97,9 @@ mail_view_finalize (GObject *object)
 static void
 mv_set_folder_uri (AnjalMailView *mv, const char *uri)
 {
+#ifndef ANJAL_SETTINGS	
 	mail_view_set_folder_uri ((MailView *)mv, uri);
+#endif
 }
 
 static void set_folder_tree (AnjalMailView *mv, EMFolderTree *tree)
@@ -101,7 +110,9 @@ static void set_folder_tree (AnjalMailView *mv, EMFolderTree *tree)
 static void
 set_search (AnjalMailView *mv, const char *search)
 {
+#ifndef ANJAL_SETTINGS	
 	mail_view_set_search ((MailView *)mv, search);
+#endif	
 }
 
 static void
@@ -159,6 +170,7 @@ mv_switch (GtkNotebook     *notebook,GtkNotebookPage *page, guint page_num, gpoi
 		else
 			 priv->current_view = node->data;
 		child = (MailViewChild *)priv->current_view;
+#ifndef ANJAL_SETTINGS		
 		if (child->type == MAIL_VIEW_COMPOSER)
 			 mail_composer_view_activate ((MailComposerView *)child, shell->folder_tree, shell->check_mail, shell->sort_by, TRUE);
 		else if (child->type == MAIL_VIEW_MESSAGE)
@@ -170,6 +182,12 @@ mv_switch (GtkNotebook     *notebook,GtkNotebookPage *page, guint page_num, gpoi
 			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)
 			mail_settings_view_activate ((MailSettingsView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, shell->slider, FALSE);
+#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)
+			mail_settings_view_activate ((MailSettingsView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, shell->slider, FALSE);
+#endif
 #if HAVE_ANERLEY
 		else if (child->type == MAIL_VIEW_PEOPLE)
 			mail_people_view_activate ((MailPeopleView *)child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, shell->slider, FALSE);
@@ -284,6 +302,7 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 	if (g_list_length(mv->priv->children) == 1)
 		return;
 
+#ifndef ANJAL_SETTINGS	
 	/* Make sure atleast one folder view is open. */
 	if (mfv->type == MAIL_VIEW_FOLDER) {
 		GList *tmp = mv->priv->children;
@@ -305,6 +324,7 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 		if (!mail_composer_view_can_quit((MailComposerView *)mfv))
 			return;
 	}
+#endif	
 	g_signal_handlers_block_by_func(mv, mv_switch, mv);
 	gtk_notebook_remove_page ((GtkNotebook *)mv, n);
 	g_signal_handlers_unblock_by_func(mv, mv_switch, mv);
@@ -314,6 +334,7 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 	pos = gtk_notebook_get_current_page ((GtkNotebook *)mv);
 	child = g_list_nth_data(mv->priv->children, pos);
 	mv->priv->current_view = child;
+#ifndef ANJAL_SETTINGS	
 	if (child->type == MAIL_VIEW_COMPOSER)
 		 mail_composer_view_activate ((MailComposerView *)child, mv->folder_tree, mv->check_mail, mv->sort_by, TRUE);
 	else if (child->type == MAIL_VIEW_MESSAGE)
@@ -326,6 +347,13 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 		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)
 		mail_settings_view_activate ((MailSettingsView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, mv->slider, FALSE);
+#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)
+		mail_settings_view_activate ((MailSettingsView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, mv->slider, FALSE);
+	
+#endif	
 #if HAVE_ANERLEY
 	else if (child->type == MAIL_VIEW_PEOPLE)
 		mail_people_view_activate ((MailPeopleView *)child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, mv->slider, FALSE);
@@ -333,6 +361,7 @@ mv_close_mcv (MailViewChild *mfv, MailView *mv)
 
 }
 
+#ifndef ANJAL_SETTINGS
 static void
 mv_message_new (MailFolderView *mfv, gpointer data, char *umid, MailView *mv)
 {
@@ -441,8 +470,10 @@ mail_view_add_message (MailView *mv, gpointer data, gboolean block)
 	return (MailViewChild *)mcv;
 }
 
+#endif
+
 static void
-mv_show_acc_mcv (MailFolderView *mfv, EAccount *account, MailView *mv)
+mv_show_acc_mcv (MailViewChild *mfv, EAccount *account, MailView *mv)
 {
 	mail_view_add_page(mv, MAIL_VIEW_ACCOUNT, account);
 }
@@ -552,6 +583,7 @@ mail_view_add_page (MailView *mv, guint16 type, gpointer data)
 	
 	g_signal_handlers_block_by_func(mv, mv_switch, mv);
 	switch (type){
+#ifndef ANJAL_SETTINGS		
 	case MAIL_VIEW_FOLDER:
 		 child = mail_view_add_folder (mv, data, block);
 		break;
@@ -562,6 +594,7 @@ mail_view_add_page (MailView *mv, guint16 type, gpointer data)
 	case MAIL_VIEW_MESSAGE:
 		 child = mail_view_add_message (mv, data, block);
 		break;
+#endif		
 	case MAIL_VIEW_SETTINGS:
 		 child = mail_view_add_settings (mv, data, block);
 		break;
@@ -587,6 +620,7 @@ mail_view_add_page (MailView *mv, guint16 type, gpointer data)
 	return child;
 }
 
+#ifndef ANJAL_SETTINGS
 static void
 mv_switch_folder_view (MailView *mv, const char *uri)
 {
@@ -628,6 +662,7 @@ mv_switch_message_view (MailView *mv, const char *uri)
 void
 mail_view_set_folder_uri (MailView *mv, const char *uri)
 {
+	
 	 mv_switch_folder_view (mv, uri);
 	//mail_folder_view_set_folder_uri (mv->priv->current_view, uri);
 }
@@ -650,7 +685,7 @@ mail_view_show_list (MailView *mv)
 
 		  
 }
-
+#endif
 void
 mail_view_close_view (MailView *mv)
 {
@@ -659,6 +694,7 @@ mail_view_close_view (MailView *mv)
 	 mv_close_mcv (child, mv);
 }
 
+#ifndef ANJAL_SETTINGS
 static void
 mv_slider_clicked (GtkButton *slider, MailView *mv)
 {
@@ -678,6 +714,7 @@ mail_view_set_slider (MailView *mv, GtkWidget *slider)
 	mv->slider = slider;
 	g_signal_connect (slider, "clicked", G_CALLBACK(mv_slider_clicked), mv);
 }
+#endif
 
 void
 mail_view_set_folder_tree_widget (MailView *mv, GtkWidget *tree)
@@ -753,7 +790,7 @@ mv_spinner_done (CamelFolder *f, gpointer data)
 	MailView *mv = (MailView *)data;
 	 mv_spinner_show (mv, FALSE);
 }
-
+#ifndef ANJAL_SETTINGS
 void
 mail_view_check_mail(MailView *mv, gboolean deep)
 {
@@ -801,6 +838,7 @@ mail_view_set_search (MailView *mv, const char *search)
 		mail_folder_view_set_search (mfv, search, e_shell_searchbar_get_search_text ((EShellSearchbar *)mv->priv->search_entry));
 	}
 }
+#endif
 
 void
 mail_view_set_search_entry (MailView *mv, GtkWidget *entry)



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