diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 19 | ||||
-rw-r--r-- | shell/Evolution-Shell.idl | 10 | ||||
-rw-r--r-- | shell/Evolution-StorageSetView.idl | 28 | ||||
-rw-r--r-- | shell/Evolution.idl | 1 | ||||
-rw-r--r-- | shell/Makefile.am | 9 | ||||
-rw-r--r-- | shell/e-shell.c | 23 | ||||
-rw-r--r-- | shell/evolution-storage-set-view-factory.c | 59 | ||||
-rw-r--r-- | shell/evolution-storage-set-view-factory.h | 31 | ||||
-rw-r--r-- | shell/evolution-storage-set-view.c | 338 | ||||
-rw-r--r-- | shell/evolution-storage-set-view.h | 70 |
10 files changed, 583 insertions, 5 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 6a5bda5196..1aa66a3e8d 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,5 +1,24 @@ 2000-10-02 Ettore Perazzoli <ettore@helixcode.com> + * e-shell.c (impl_Shell_create_storage_set_view): New, + implementation for `::create_storage_set_view'. + (corba_class_init): Install. + + * evolution-storage-set-view-factory.c: New. + * evolution-storage-set-view-factory.h: New. + + * evolution-storage-set-view.c: New. + * evolution-storage-set-view.h: New. + + * Evolution-Shell.idl: New method + `Shell::create_storage_set_view'. + + * Evolution.idl: #include <Evolution-StorageSetView.idl>. + + * Evolution-StorageSetView.idl: New. + +2000-10-02 Ettore Perazzoli <ettore@helixcode.com> + * evolution-storage.c (find_listener_in_list): New helper function. (impl_Storage_remove_listener): New, implementation for diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl index d224cb0b27..0102ba09ec 100644 --- a/shell/Evolution-Shell.idl +++ b/shell/Evolution-Shell.idl @@ -63,6 +63,16 @@ module Evolution { * Return value: the `Evolution::LocalStorage' interface for * the local storage. */ LocalStorage get_local_storage (); + + /** + * create_storage_set_view: + * + * Create a control for the storage set view. This control + * will also implement the `Evolution::StorageSetView' interface. + * + * Return value: the newly created control. + */ + Bonobo::Control create_storage_set_view (); }; interface FolderSelectionListener { diff --git a/shell/Evolution-StorageSetView.idl b/shell/Evolution-StorageSetView.idl new file mode 100644 index 0000000000..0649b3b4a2 --- /dev/null +++ b/shell/Evolution-StorageSetView.idl @@ -0,0 +1,28 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Interface for the Evolution's StorageSetView control. + * + * Authors: + * Ettore Perazzoli <ettore@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + */ + +#include <Bonoob.idl> + +module Evolution { + interface StorageSetViewListener { + void folder_selected (in string uri); + }; + + /* FIXME: Maybe we should have a generic Bonobo::Listener interface. */ + interface StorageSetView : Bonobo::Unknown { + exception AlreadyListening {}; + exception NotFound {}; + + void add_listener (in StorageSetViewListener listener) + raises (AlreadyListening); + void remove_listener (in StorageSetViewListener listener) + raises (NotFound); + }; +}; diff --git a/shell/Evolution.idl b/shell/Evolution.idl index a81430848b..71ae040684 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -14,5 +14,6 @@ #include <Evolution-ShellComponent.idl> #include <Evolution-ShellView.idl> #include <Evolution-Storage.idl> +#include <Evolution-StorageSetView.idl> #include <Evolution-LocalStorage.idl> #include <Evolution-Shell.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index f68b15bc75..9da449867b 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -20,13 +20,14 @@ CLEANFILES = $(IDL_GENERATED) # CORBA stuff IDLS = \ - Evolution.idl \ Evolution-LocalStorage.idl \ Evolution-Session.idl \ Evolution-Shell.idl \ Evolution-ShellComponent.idl \ Evolution-ShellView.idl \ - Evolution-Storage.idl + Evolution-Storage.idl \ + Evolution-StorageSetView.idl \ + Evolution.idl IDL_GENERATED = \ Evolution.h \ @@ -114,6 +115,10 @@ evolution_SOURCES = \ e-storage-set.h \ e-storage.c \ e-storage.h \ + evolution-storage-set-view.c \ + evolution-storage-set-view.h \ + evolution-storage-set-view-factory.c \ + evolution-storage-set-view-factory.h \ main.c evolution_LDADD = \ diff --git a/shell/e-shell.c b/shell/e-shell.c index d1125e0dc2..a7c1a2d2c0 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -269,6 +269,22 @@ impl_Shell_get_local_storage (PortableServer_Servant servant, return copy_of_local_storage_interface; } +static Bonobo_Control +impl_Shell_create_storage_set_view (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EShell *shell; + BonoboControl *control; + + bonobo_object = bonobo_object_from_servant (servant); + shell = E_SHELL (bonobo_object); + + control = evolution_storage_set_view_factory_new_view (shell); + + return bonobo_object_corba_objref (BONOBO_OBJECT (control)); +} + /* Initialization of the storages. */ @@ -484,9 +500,10 @@ corba_class_init (void) base_epv->default_POA = NULL; epv = g_new0 (POA_Evolution_Shell__epv, 1); - epv->get_component_for_type = impl_Shell_get_component_for_type; - epv->user_select_folder = impl_Shell_user_select_folder; - epv->get_local_storage = impl_Shell_get_local_storage; + epv->get_component_for_type = impl_Shell_get_component_for_type; + epv->user_select_folder = impl_Shell_user_select_folder; + epv->get_local_storage = impl_Shell_get_local_storage; + epv->create_storage_set_view = impl_Shell_create_storage_set_view; vepv = &shell_vepv; vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); diff --git a/shell/evolution-storage-set-view-factory.c b/shell/evolution-storage-set-view-factory.c new file mode 100644 index 0000000000..79145d6492 --- /dev/null +++ b/shell/evolution-storage-set-view-factory.c @@ -0,0 +1,59 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-storage-set-view-factory.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. + * + * 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. + * + * 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> +#endif + +#include "e-storage-set-view.h" +#include "e-shell.h" +#include "evolution-storage-set-view.h" + +#include "evolution-storage-set-view-factory.h" + + +BonoboControl * +evolution_storage_set_view_factory_new_view (EShell *shell) +{ + EStorageSet *storage_set; + GtkWidget *storage_set_view; + BonoboControl *control; + EvolutionStorageSetView *storage_set_view_interface; + + g_return_val_if_fail (shell != NULL, NULL); + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + + storage_set = e_shell_get_storage_set (shell); + storage_set_view = e_storage_set_view_new (storage_set); + + storage_set_view_interface = evolution_storage_set_view_new (storage_set_view); + if (storage_set_view_interface == NULL) { + gtk_widget_destroy (storage_set_view); + return NULL; + } + + control = bonobo_control_new (storage_set_view); + bonobo_object_add_interface (BONOBO_OBJECT (control), BONOBO_OBJECT (storage_set_view)); + + return control; +} diff --git a/shell/evolution-storage-set-view-factory.h b/shell/evolution-storage-set-view-factory.h new file mode 100644 index 0000000000..85710e6cd1 --- /dev/null +++ b/shell/evolution-storage-set-view-factory.h @@ -0,0 +1,31 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-storage-set-view-factory.h + * + * 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. + * + * 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. + * + * 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 + */ + +#ifndef _EVOLUTION_STORAGE_SET_VIEW_FACTORY_H +#define _EVOLUTION_STORAGE_SET_VIEW_FACTORY_H + +#include "e-shell.h" + +BonoboControl *evolution_storage_set_view_factory_new_view (EShell *shell); + +#endif /* _EVOLUTION_STORAGE_SET_VIEW_FACTORY_H */ diff --git a/shell/evolution-storage-set-view.c b/shell/evolution-storage-set-view.c new file mode 100644 index 0000000000..e0401c5efc --- /dev/null +++ b/shell/evolution-storage-set-view.c @@ -0,0 +1,338 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-storage-set-view.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. + * + * 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. + * + * 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> +#endif + +#include <gnome.h> +#include "evolution-storage-set-view.h" + + +#define PARENT_TYPE bonobo_object_get_type () +static BonoboObjectClass *parent_class = NULL; + +struct _EvolutionStorageSetViewPrivate { + GtkWidget *storage_set_view_widget; + GList *listeners; +}; + + +/* EStorageSet widget callbacks. */ + +static void +storage_set_view_widget_folder_selected_cb (EStorageSetView *storage_set_view_widget, + const char *uri, + void *data) +{ + EvolutionStorageSetView *storage_set_view; + EvolutionStorageSetViewPrivate *priv; + GList *p; + + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (data); + priv = storage_set_view->priv; + + for (p = priv->listeners; p != NULL; p = p->next) { + CORBA_Environment ev; + Evolution_StorageSetViewListener listener; + + CORBA_exception_init (&ev); + + listener = (Evolution_StorageSetViewListener) p->data; + Evolution_StorageSetViewListener_folder_selected (listener, uri, &ev); + + /* FIXME: What if we fail? */ + + CORBA_exception_free (&ev); + } +} + + +/* Listener handling. */ + +static GList * +find_listener_in_list (Evolution_StorageSetViewListener listener, + GList *list) +{ + CORBA_Environment ev; + GList *p; + + CORBA_exception_init (&ev); + + for (p = list; p != NULL; p = p->next) { + Evolution_StorageSetViewListener listener_item; + + listener_item = (Evolution_StorageSetViewListener) p->data; + if (CORBA_Object_is_equivalent (listener, listener_item, &ev)) + break; + } + + CORBA_exception_free (&ev); + + return p; +} + +static gboolean +add_listener (EvolutionStorageSetView *storage_set_view, + Evolution_StorageSetViewListener listener) +{ + EvolutionStorageSetViewPrivate *priv; + CORBA_Environment ev; + const char *current_uri; + Evolution_StorageSetViewListener copy_of_listener; + + priv = storage_set_view->priv; + + if (find_listener_in_list (listener, priv->listeners) != NULL) + return FALSE; + + CORBA_exception_init (&ev); + + copy_of_listener = CORBA_Object_duplicate (listener, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + CORBA_exception_free (&ev); + return FALSE; + } + + priv->listeners = g_list_prepend (priv->listeners, copy_of_listener); + + current_uri = e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view_widget)); + if (current_uri != NULL) + Evolution_StorageSetViewListener_folder_selected (listener, current_uri, &ev); + + CORBA_exception_free (&ev); + + return TRUE; +} + +static gboolean +remove_listener (EvolutionStorageSetView *storage_set_view, + Evolution_StorageSetViewListener listener) +{ + EvolutionStorageSetViewPrivate *priv; + GList *listener_node; + CORBA_Environment ev; + + priv = storage_set_view->priv; + + listener_node = find_listener_in_list (listener, priv->listeners); + if (listener_node == NULL) + return FALSE; + + CORBA_exception_init (&ev); + CORBA_Object_release ((CORBA_Object) listener_node->data, &ev); + CORBA_exception_free (&ev); + + priv->listeners = g_list_remove_link (priv->listeners, listener_node); + + return TRUE; +} + + +/* CORBA interface implementation. */ + +static POA_Evolution_StorageSetView__vepv StorageSetView_vepv; + +static POA_Evolution_StorageSetView * +create_servant (void) +{ + POA_Evolution_StorageSetView *servant; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + servant = (POA_Evolution_StorageSetView *) g_new0 (BonoboObjectServant, 1); + servant->vepv = &StorageSetView_vepv; + + POA_Evolution_StorageSetView__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_free (servant); + servant = NULL; + } + + CORBA_exception_free (&ev); + + return servant; +} + +static void +impl_StorageSetView_add_listener (PortableServer_Servant servant, + const Evolution_StorageSetViewListener listener, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStorageSetView *storage_set_view; + + bonobo_object = bonobo_object_from_servant (servant); + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (servant); + + if (! add_listener (storage_set_view, listener)) + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_StorageSetView_AlreadyListening, NULL); +} + +static void +impl_StorageSetView_remove_listener (PortableServer_Servant servant, + const Evolution_StorageSetViewListener listener, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStorageSetView *storage_set_view; + + bonobo_object = bonobo_object_from_servant (servant); + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (servant); + + if (! remove_listener (storage_set_view, listener)) + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_StorageSetView_NotFound, NULL); +} + + +/* GtkObject methods. */ + +static void +impl_destroy (GtkObject *object) +{ + EvolutionStorageSetView *storage_set_view; + EvolutionStorageSetViewPrivate *priv; + CORBA_Environment ev; + GList *p; + + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (object); + priv = storage_set_view->priv; + + CORBA_exception_init (&ev); + + for (p = priv->listeners; p != NULL; p = p->next) { + Evolution_StorageSetViewListener listener; + + listener = (Evolution_StorageSetViewListener) p->data; + CORBA_Object_release (listener, &ev); + } + + CORBA_exception_free (&ev); + + g_free (priv); + + if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + +static void +corba_class_init (void) +{ + POA_Evolution_StorageSetView__vepv *vepv; + POA_Evolution_StorageSetView__epv *epv; + PortableServer_ServantBase__epv *base_epv; + + base_epv = g_new0 (PortableServer_ServantBase__epv, 1); + base_epv->_private = NULL; + base_epv->finalize = NULL; + base_epv->default_POA = NULL; + + epv = g_new0 (POA_Evolution_StorageSetView__epv, 1); + epv->add_listener = impl_StorageSetView_add_listener; + epv->remove_listener = impl_StorageSetView_remove_listener; + + vepv = &StorageSetView_vepv; + vepv->_base_epv = base_epv; + vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); + vepv->Evolution_StorageSetView_epv = epv; +} + +static void +class_init (EvolutionStorageSetViewClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + object_class->destroy = impl_destroy; + + parent_class = gtk_type_class (bonobo_object_get_type ()); + + corba_class_init (); +} + +static void +init (EvolutionStorageSetView *storage_set_view) +{ + EvolutionStorageSetViewPrivate *priv; + + priv = g_new (EvolutionStorageSetViewPrivate, 1); + priv->storage_set_view_widget = NULL; + priv->listeners = NULL; + + storage_set_view->priv = priv; +} + + +void +evolution_storage_set_view_construct (EvolutionStorageSetView *storage_set_view, + Evolution_StorageSetView corba_object, + EStorageSetView *storage_set_view_widget) +{ + EvolutionStorageSetViewPrivate *priv; + + g_return_if_fail (storage_set_view != NULL); + g_return_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW (storage_set_view)); + g_return_if_fail (corba_object != CORBA_OBJECT_NIL); + g_return_if_fail (storage_set_view_widget != NULL); + g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view_widget)); + + priv = storage_set_view->priv; + + bonobo_object_construct (BONOBO_OBJECT (storage_set_view), corba_object); + + g_assert (priv->storage_set_view_widget == NULL); + priv->storage_set_view_widget = GTK_WIDGET (storage_set_view_widget); + + gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_widget), "folder_selected", + GTK_SIGNAL_FUNC (storage_set_view_widget_folder_selected_cb), storage_set_view); +} + +EvolutionStorageSetView * +evolution_storage_set_view_new (EStorageSetView *storage_set_view_widget) +{ + POA_Evolution_StorageSetView *servant; + Evolution_StorageSetView corba_object; + EvolutionStorageSetView *new; + + g_return_val_if_fail (storage_set_view_widget != NULL, NULL); + g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view_widget), NULL); + + servant = create_servant (); + if (servant == NULL) + return NULL; + + new = gtk_type_new (evolution_storage_set_view_get_type ()); + + corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant); + + evolution_storage_set_view_construct (new, corba_object, storage_set_view_widget); + + return new; +} + + +E_MAKE_TYPE (evolution_storage_set_view, "EvolutionStorageSetView", EvolutionStorageSetView, class_init, init, PARENT_TYPE) diff --git a/shell/evolution-storage-set-view.h b/shell/evolution-storage-set-view.h new file mode 100644 index 0000000000..1f3a9f84bf --- /dev/null +++ b/shell/evolution-storage-set-view.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-storage-set-view.h + * + * 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. + * + * 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. + * + * 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 + */ + +#ifndef _EVOLUTION_STORAGE_SET_VIEW_H_ +#define _EVOLUTION_STORAGE_SET_VIEW_H_ + +#include <bonobo/bonobo-object.h> + +#include "e-storage-set-view.h" + +#include "Evolution.h" + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define EVOLUTION_TYPE_STORAGE_SET_VIEW (evolution_storage_set_view_get_type ()) +#define EVOLUTION_STORAGE_SET_VIEW(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW, EvolutionStorageSetView)) +#define EVOLUTION_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_SET_VIEW, EvolutionStorageSetViewClass)) +#define EVOLUTION_IS_STORAGE_SET_VIEW(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW)) +#define EVOLUTION_IS_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW)) + + +typedef struct _EvolutionStorageSetView EvolutionStorageSetView; +typedef struct _EvolutionStorageSetViewPrivate EvolutionStorageSetViewPrivate; +typedef struct _EvolutionStorageSetViewClass EvolutionStorageSetViewClass; + +struct _EvolutionStorageSetView { + BonoboObject parent; + + EvolutionStorageSetViewPrivate *priv; +}; + +struct _EvolutionStorageSetViewClass { + BonoboObjectClass parent_class; +}; + + +GtkType evolution_storage_set_view_get_type (void); +void evolution_storage_set_view_construct (EvolutionStorageSetView *storage_set_view, + Evolution_StorageSetView corba_object, + EStorageSetView *storage_set_view_widget); +EvolutionStorageSetView *evolution_storage_set_view_new (EStorageSetView *storage_set_view_widget); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _EVOLUTION_STORAGE_SET_VIEW_H_ */ |