aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-shell.c')
-rw-r--r--shell/e-shell.c448
1 files changed, 152 insertions, 296 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 2713df3921..6c225cdf49 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -1,377 +1,233 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * E-shell.c: Shell object for Evolution
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-shell.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
*
- * Authors:
- * Miguel de Icaza (miguel@helixcode.com)
+ * 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
+ * General Public License for more details.
*
- * (C) 1999 Miguel de Icaza
- * (C) 2000 Helix Code, Inc.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/libgnome.h>
-#include "Evolution.h"
-#include "e-util/e-util.h"
-#include "e-shell.h"
+#endif
-#define PARENT_TYPE (bonobo_object_get_type ())
+#include <gtk/gtkobject.h>
+#include <gtk/gtktypeutils.h>
-static BonoboObjectClass *e_shell_parent_class;
-POA_Evolution_Shell__vepv eshell_vepv;
+#include "e-util/e-util.h"
-GtkType e_shell_get_type (void);
+#include "e-folder-type-repository.h"
+#include "e-local-storage.h"
+#include "e-shell-view.h"
+#include "e-shortcuts.h"
+#include "e-storage-set.h"
-void
-e_shell_new_appointment (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+#include "e-shell.h"
-void
-e_shell_new_meeting_request (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+
+#define PARENT_TYPE GTK_TYPE_OBJECT
+static GtkObjectClass *parent_class = NULL;
-void
-e_shell_new_task (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+struct _EShellPrivate {
+ char *local_directory;
-void
-e_shell_new_task_request (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+ EStorageSet *storage_set;
+ EShortcuts *shortcuts;
+ EFolderTypeRepository *folder_type_repository;
+};
-void
-e_shell_new_contact (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+#define SHORTCUTS_FILE_NAME "shortcuts.xml"
+#define LOCAL_STORAGE_DIRECTORY "local"
-void
-e_shell_new_mail_message (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+
+/* Initialization of the storages. */
-void
-e_shell_new_distribution_list (EShell *eshell)
+static gboolean
+setup_storages (EShell *shell)
{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+ EStorage *local_storage;
+ EShellPrivate *priv;
+ gchar *local_storage_path;
-void
-e_shell_new_journal_entry (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+ priv = shell->priv;
-void
-e_shell_new_note (EShell *eshell)
-{
- printf ("Unimplemented function invoked: %s\n", __FUNCTION__);
-}
+ local_storage_path = g_concat_dir_and_file (priv->local_directory,
+ LOCAL_STORAGE_DIRECTORY);
+ local_storage = e_local_storage_open (local_storage_path);
+ g_free (local_storage_path);
-static void
-EShell_cmd_new (PortableServer_Servant servant,
- const Evolution_Shell_NewType type,
- CORBA_Environment *ev)
-{
- EShell *eshell = E_SHELL (bonobo_object_from_servant (servant));
-
- switch (type){
- case Evolution_Shell_APPOINTMENT:
- e_shell_new_appointment (eshell);
- break;
-
- case Evolution_Shell_MEETING_REQUEST:
- e_shell_new_meeting_request (eshell);
- break;
-
- case Evolution_Shell_TASK:
- e_shell_new_task (eshell);
- break;
-
- case Evolution_Shell_TASK_REQUEST:
- e_shell_new_task_request (eshell);
- break;
-
- case Evolution_Shell_CONTACT:
- e_shell_new_contact (eshell);
- break;
-
- case Evolution_Shell_MAIL_MESSAGE:
- e_shell_new_mail_message (eshell);
- break;
-
- case Evolution_Shell_DISTRIBUTION_LIST:
- e_shell_new_distribution_list (eshell);
- break;
-
- case Evolution_Shell_JOURNAL_ENTRY:
- e_shell_new_journal_entry (eshell);
- break;
-
- case Evolution_Shell_NOTE:
- e_shell_new_note (eshell);
- break;
-
- default:
- }
-}
+ if (local_storage == NULL)
+ return FALSE;
-static void
-EShell_register_service (PortableServer_Servant servant,
- const Evolution_Shell_ServiceType type,
- const CORBA_char *uri,
- CORBA_Environment *ev)
-{
- char *service_type_desc = NULL;
-
- switch (type) {
-
- case Evolution_Shell_MAIL_STORE :
- service_type_desc = "store";
- break;
- case Evolution_Shell_MAIL_TRANSPORT :
- service_type_desc = "transport";
- break;
- default :
- service_type_desc = "service of unknown type";
- }
-
- printf ("A component has registered a %s with uri \"%s\"\n", service_type_desc, uri);
+ priv->storage_set = e_storage_set_new ();
+ e_storage_set_add_storage (priv->storage_set, local_storage);
+ return TRUE;
}
+
+/* GtkObject methods. */
-static POA_Evolution_Shell__epv *
-e_shell_get_epv (void)
+static void
+destroy (GtkObject *object)
{
- POA_Evolution_Shell__epv *epv;
-
- epv = g_new0 (POA_Evolution_Shell__epv, 1);
+ EShell *shell;
+ EShellPrivate *priv;
- epv->new = EShell_cmd_new;
- epv->register_service = EShell_register_service;
+ shell = E_SHELL (object);
+ priv = shell->priv;
- return epv;
-}
+ gtk_object_unref (GTK_OBJECT (priv->storage_set));
+ gtk_object_unref (GTK_OBJECT (priv->shortcuts));
+ gtk_object_unref (GTK_OBJECT (priv->folder_type_repository));
-static void
-init_e_shell_corba_class (void)
-{
- eshell_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- eshell_vepv.Evolution_Shell_epv = e_shell_get_epv ();
-}
+ g_free (priv);
-static void
-es_destroy_default_folders (EShell *eshell)
-{
- gtk_object_unref (GTK_OBJECT (eshell->default_folders.inbox));
- gtk_object_unref (GTK_OBJECT (eshell->default_folders.outbox));
- gtk_object_unref (GTK_OBJECT (eshell->default_folders.drafts));
- gtk_object_unref (GTK_OBJECT (eshell->default_folders.calendar));
- gtk_object_unref (GTK_OBJECT (eshell->default_folders.tasks));
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
+
static void
-e_shell_destroy (GtkObject *object)
+class_init (EShellClass *klass)
{
- EShell *eshell = E_SHELL (object);
+ GtkObjectClass *object_class;
- gtk_object_unref (GTK_OBJECT (eshell->shortcut_bar));
- es_destroy_default_folders (eshell);
-
- GTK_OBJECT_CLASS (e_shell_parent_class)->destroy (object);
-}
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = destroy;
-static void
-e_shell_class_init (GtkObjectClass *object_class)
-{
- e_shell_parent_class = gtk_type_class (PARENT_TYPE);
- init_e_shell_corba_class ();
+ parent_class = gtk_type_class (gtk_object_get_type ());
- object_class->destroy = e_shell_destroy;
}
static void
-e_shell_destroy_views (EShell *eshell)
+init (EShell *shell)
{
+ EShellPrivate *priv;
- /*
- * Notice that eshell->views is updated by the various views
- * during unregistration
- */
- while (eshell->views){
- EShellView *view = eshell->views->data;
+ priv = g_new (EShellPrivate, 1);
- gtk_object_destroy (GTK_OBJECT (view));
- }
-}
+ priv->local_directory = NULL;
+ priv->storage_set = NULL;
+ priv->shortcuts = NULL;
+ priv->folder_type_repository = NULL;
-void
-e_shell_quit (EShell *eshell)
-{
- g_return_if_fail (eshell != NULL);
- g_return_if_fail (E_IS_SHELL (eshell));
-
- e_shell_destroy_views (eshell);
-
- gtk_main_quit ();
+ shell->priv = priv;
}
-static CORBA_Object
-create_corba_eshell (BonoboObject *object)
+
+void
+e_shell_construct (EShell *shell,
+ const char *local_directory)
{
- POA_Evolution_Shell *servant;
- CORBA_Environment ev;
+ EShellPrivate *priv;
+ gchar *shortcut_path;
- servant = (POA_Evolution_Shell *)g_new0 (BonoboObjectServant, 1);
- servant->vepv = &eshell_vepv;
+ g_return_if_fail (shell != NULL);
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (local_directory != NULL);
+ g_return_if_fail (g_path_is_absolute (local_directory));
- CORBA_exception_init (&ev);
+ GTK_OBJECT_UNSET_FLAGS (shell, GTK_FLOATING);
- POA_Evolution_Shell__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION){
- CORBA_exception_free (&ev);
- g_free (servant);
- return CORBA_OBJECT_NIL;
- }
+ priv = shell->priv;
- CORBA_exception_free (&ev);
+ priv->local_directory = g_strdup (local_directory);
- return bonobo_object_activate_servant (object, servant);
-}
+ if (! setup_storages (shell))
+ return;
-static void
-e_shell_setup_default_folders (EShell *eshell)
-{
- eshell->default_folders.summary = e_folder_new (
- E_FOLDER_SUMMARY, "internal:summary", _("Today"), _("Executive Summary"),
- NULL, "internal:");
- eshell->default_folders.inbox = e_folder_new (
- E_FOLDER_MAIL, "internal:inbox", _("Inbox"), _("New mail messages"),
- NULL, "internal:mail_view");
- eshell->default_folders.outbox = e_folder_new (
- E_FOLDER_MAIL, "internal:outbox", _("Sent messages"), _("Sent mail messages"),
- NULL, "internal:mail_view");
- eshell->default_folders.drafts = e_folder_new (
- E_FOLDER_MAIL, "internal:drafts", _("Drafts"), _("Draft mail messages"),
- NULL, "internal:mail_view");
- eshell->default_folders.calendar = e_folder_new (
- E_FOLDER_CALENDAR, "internal:personal_calendar", _("Calendar"), _("Your calendar"),
- NULL, "internal:calendar_daily");
- eshell->default_folders.contacts = e_folder_new (
- E_FOLDER_CONTACTS, "internal:personal_contacts", _("Contacts"), _("Your contacts list"),
- NULL, "internal:contact_view");
- eshell->default_folders.tasks = e_folder_new (
- E_FOLDER_TASKS, "internal:personal_calendar", _("Tasks"), _("Tasks list"),
- NULL, "internal:tasks_view");
-}
+ priv->folder_type_repository = e_folder_type_repository_new ();
+ priv->shortcuts = e_shortcuts_new (priv->storage_set, priv->folder_type_repository);
-static EShortcutGroup *
-setup_main_shortcuts (EShell *eshell)
-{
- EShortcutGroup *m;
+ shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml");
- m = e_shortcut_group_new (_("Main Shortcuts"), FALSE);
- e_shortcut_group_append (m, e_shortcut_new (eshell->default_folders.summary));
- e_shortcut_group_append (m, e_shortcut_new (eshell->default_folders.inbox));
- e_shortcut_group_append (m, e_shortcut_new (eshell->default_folders.calendar));
- e_shortcut_group_append (m, e_shortcut_new (eshell->default_folders.contacts));
- e_shortcut_group_append (m, e_shortcut_new (eshell->default_folders.tasks));
+ if (! e_shortcuts_load (priv->shortcuts, shortcut_path)) {
+ gtk_object_unref (GTK_OBJECT (priv->shortcuts));
+ priv->shortcuts = NULL;
+ }
- return m;
+ g_free (shortcut_path);
}
-static EShortcutGroup *
-setup_secondary_shortcuts (EShell *eshell)
+EShell *
+e_shell_new (const char *local_directory)
{
- EShortcutGroup *sec;
+ EShell *new;
+ EShellPrivate *priv;
- sec = e_shortcut_group_new (_("Other Shortcuts"), TRUE);
-
- e_shortcut_group_append (sec, e_shortcut_new (eshell->default_folders.drafts));
- e_shortcut_group_append (sec, e_shortcut_new (eshell->default_folders.outbox));
+ new = gtk_type_new (e_shell_get_type ());
+ e_shell_construct (new, local_directory);
- return sec;
-}
+ priv = new->priv;
-static void
-e_shell_setup_default_shortcuts (EShell *eshell)
-{
- eshell->shortcut_bar = e_shortcut_bar_model_new ();
- e_shortcut_bar_model_append (
- eshell->shortcut_bar,
- setup_main_shortcuts (eshell));
- e_shortcut_bar_model_append (
- eshell->shortcut_bar,
- setup_secondary_shortcuts (eshell));
-}
+ if (priv->shortcuts == NULL || priv->storage_set == NULL) {
+ gtk_object_unref (GTK_OBJECT (new));
+ return NULL;
+ }
-static void
-e_shell_init (GtkObject *object)
-{
- EShell *eshell = E_SHELL (object);
-
- e_shell_setup_default_folders (eshell);
- e_shell_setup_default_shortcuts (eshell);
+ return new;
}
-static void
-e_shell_construct (EShell *eshell, Evolution_Shell corba_eshell)
+
+GtkWidget *
+e_shell_new_view (EShell *shell,
+ const char *uri)
{
- bonobo_object_construct (BONOBO_OBJECT (eshell), corba_eshell);
-}
+ GtkWidget *view_widget;
+ EShellView *shell_view;
-EShell *
-e_shell_new (void)
-{
- Evolution_Shell corba_eshell;
- EShell *eshell;
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- eshell = gtk_type_new (e_shell_get_type ());
+ view_widget = e_shell_view_new (shell, uri);
+ shell_view = E_SHELL_VIEW (view_widget);
- corba_eshell = create_corba_eshell (BONOBO_OBJECT (eshell));
- if (corba_eshell == CORBA_OBJECT_NIL){
- gtk_object_destroy (GTK_OBJECT (eshell));
- return NULL;
- }
-
- e_shell_construct (eshell, corba_eshell);
+ gtk_widget_show (view_widget);
- return eshell;
+ return view_widget;
}
-void
-e_shell_register_view (EShell *eshell, EShellView *eshell_view)
+
+EShortcuts *
+e_shell_get_shortcuts (EShell *shell)
{
- g_return_if_fail (eshell != NULL);
- g_return_if_fail (E_IS_SHELL (eshell));
- g_return_if_fail (eshell_view != NULL);
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- eshell->views = g_slist_prepend (eshell->views, eshell_view);
+ return shell->priv->shortcuts;
}
-void
-e_shell_unregister_view (EShell *eshell, EShellView *eshell_view)
+EStorageSet *
+e_shell_get_storage_set (EShell *shell)
{
- g_return_if_fail (eshell != NULL);
- g_return_if_fail (E_IS_SHELL (eshell));
- g_return_if_fail (eshell_view != NULL);
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- eshell->views = g_slist_remove (eshell->views, eshell_view);
+ return shell->priv->storage_set;
}
-E_MAKE_TYPE (e_shell, "EShell", EShell, e_shell_class_init, e_shell_init, PARENT_TYPE);
-
+EFolderTypeRepository *
+e_shell_get_folder_type_repository (EShell *shell)
+{
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ return shell->priv->folder_type_repository;
+}
-
+
+E_MAKE_TYPE (e_shell, "EShell", EShell, class_init, init, PARENT_TYPE)