diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2000-07-20 21:37:56 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2000-07-20 21:37:56 +0800 |
commit | b40242c395b0eec33a622ddfe90634fd6d63e4c6 (patch) | |
tree | aecb84b01ffb6c3536c5db0c26165df4f51d860a | |
parent | 8aec5bf2be2fbfdfb4cecd6c48a77d197db41d39 (diff) | |
download | gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar.gz gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar.bz2 gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar.lz gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar.xz gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.tar.zst gsoc2013-evolution-b40242c395b0eec33a622ddfe90634fd6d63e4c6.zip |
Add support for saving the current configuration of all the
components.
svn path=/trunk/; revision=4237
-rw-r--r-- | shell/ChangeLog | 27 | ||||
-rw-r--r-- | shell/Evolution-Session.idl | 39 | ||||
-rw-r--r-- | shell/Evolution.idl | 3 | ||||
-rw-r--r-- | shell/Makefile.am | 15 | ||||
-rw-r--r-- | shell/e-component-registry.c | 71 | ||||
-rw-r--r-- | shell/e-component-registry.h | 17 | ||||
-rw-r--r-- | shell/e-shell.c | 112 | ||||
-rw-r--r-- | shell/evolution-session.c | 211 | ||||
-rw-r--r-- | shell/evolution-session.h | 72 |
9 files changed, 539 insertions, 28 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index d857de8519..565762994e 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,5 +1,32 @@ 2000-07-20 Ettore Perazzoli <ettore@helixcode.com> + * e-shell.c (save_settings_for_views): New. Code moved out of + `e_shell_save_settings'. + (e_shell_save_settings): Use it. + (save_settings_for_component): New. + (save_settings_for_components): New. + (e_shell_save_settings): Use it, so that we make all the + components save settings too. + + * e-component-registry.c + (e_component_registry_get_id_list): New. + (e_component_registry_get_component_by_id): New. + + * Makefile.am (libeshell_a_SOURCES): Add + `evolution-shell-component-client' and `evolution-session'. + + * evolution-session.c: New. + * evolution-session.h: New. + + * Makefile.am (evolution_SOURCES): Removed files that were already + in `libeshell.a'. + + * Evolution.idl: #include <Evolution-Session.idl>. + + * Evolution-Session.idl: New. + +2000-07-20 Ettore Perazzoli <ettore@helixcode.com> + * main.c (no_views_left_cb): Call `e_shell_quit()' on the shell before getting out of the GTK+ main loop. (view_delete_event_cb): Removed. diff --git a/shell/Evolution-Session.idl b/shell/Evolution-Session.idl new file mode 100644 index 0000000000..855f1c03ea --- /dev/null +++ b/shell/Evolution-Session.idl @@ -0,0 +1,39 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Interface for saving configuration information. + * + * Authors: + * Ettore Perazzoli <ettore@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + */ + +#include <Bonobo.h> + +module Evolution { + + interface Session : Bonobo::Unknown { + exception Failed {}; + + /** + * save_configuration: + * @prefix: A configuration path prefix. + * + * Save the current configuration at the specified @prefix. + * The component can use any path starting by @prefix for its + * keys. + */ + void save_configuration (in string prefix) + raises (Failed); + + /** + * load_configuration: + * @prefix: A configuration path prefix. + * + * Load the saved configuration at the specified @prefix. + */ + void load_configuration (in string prefix) + raises (Failed); + }; + +}; diff --git a/shell/Evolution.idl b/shell/Evolution.idl index 80a45eedc1..a0eb944008 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -10,6 +10,7 @@ #include <Bonobo.idl> -#include <Evolution-Storage.idl> +#include <Evolution-Session.idl> #include <Evolution-Shell.idl> #include <Evolution-ShellComponent.idl> +#include <Evolution-Storage.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index dbcc08cac6..782e849d3a 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -21,6 +21,7 @@ CLEANFILES = $(IDL_GENERATED) IDLS = \ Evolution.idl \ + Evolution-Session.idl \ Evolution-Shell.idl \ Evolution-ShellComponent.idl \ Evolution-Storage.idl @@ -37,6 +38,12 @@ $(IDL_GENERATED): $(IDLS) $(ORBIT_IDL) -I$(datadir)/idl -I`$(GNOME_CONFIG) --datadir`/idl \ -I$(srcdir) $(srcdir)/Evolution.idl +# bonobo-idl stuff. +# (Automatically generated GTK+ object wrappers for CORBA interface implementations). + +evolution-session.c: evolution-session.bcd + bonobo-idl evolution-session.bcd + # Shell library noinst_LIBRARIES = \ @@ -44,10 +51,14 @@ noinst_LIBRARIES = \ libeshell_a_SOURCES = \ $(IDL_GENERATED) \ + evolution-session.c \ + evolution-session.h \ evolution-shell-client.c \ evolution-shell-client.h \ evolution-shell-component.c \ evolution-shell-component.h \ + evolution-shell-component-client.c \ + evolution-shell-component-client.h \ evolution-storage.c \ evolution-storage.h @@ -97,10 +108,6 @@ evolution_SOURCES = \ e-storage-set.h \ e-storage.c \ e-storage.h \ - evolution-shell-client.c \ - evolution-shell-client.h \ - evolution-shell-component-client.c \ - evolution-shell-component-client.h \ main.c evolution_LDADD = \ diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c index 944b5c150b..a331a1a551 100644 --- a/shell/e-component-registry.c +++ b/shell/e-component-registry.c @@ -297,5 +297,76 @@ e_component_registry_register_component (EComponentRegistry *component_registry, } +static void +compose_id_list_foreach (void *key, + void *value, + void *data) +{ + GList **listp; + const char *id; + + listp = (GList **) data; + id = (const char *) key; + + *listp = g_list_prepend (*listp, g_strdup (id)); +} + +/** + * e_component_registry_get_id_list: + * @component_registry: + * + * Get the list of components registered. + * + * Return value: A GList of strings containining the IDs for all the registered + * components. The list must be freed by the caller when not used anymore. + **/ +GList * +e_component_registry_get_id_list (EComponentRegistry *component_registry) +{ + EComponentRegistryPrivate *priv; + GList *list; + + g_return_val_if_fail (component_registry != NULL, NULL); + g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), NULL); + + priv = component_registry->priv; + list = NULL; + + g_hash_table_foreach (priv->component_id_to_component, compose_id_list_foreach, &list); + + return list; +} + +/** + * e_component_registry_get_component_by_id: + * @component_registry: + * @id: The component's OAF ID + * + * Get the registered component client for the specified ID. If that component + * is not registered, return NULL. + * + * Return value: A pointer to the ShellComponentClient for that component. + **/ +EvolutionShellComponentClient * +e_component_registry_get_component_by_id (EComponentRegistry *component_registry, + const char *id) +{ + EComponentRegistryPrivate *priv; + const Component *component; + + g_return_val_if_fail (component_registry != NULL, NULL); + g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), NULL); + g_return_val_if_fail (id != NULL, NULL); + + priv = component_registry->priv; + + component = g_hash_table_lookup (priv->component_id_to_component, id); + if (component == NULL) + return NULL; + + return component->client; +} + + E_MAKE_TYPE (e_component_registry, "EComponentRegistry", EComponentRegistry, class_init, init, PARENT_TYPE) diff --git a/shell/e-component-registry.h b/shell/e-component-registry.h index 298b756391..0a34413844 100644 --- a/shell/e-component-registry.h +++ b/shell/e-component-registry.h @@ -59,13 +59,18 @@ struct _EComponentRegistryClass { }; -GtkType e_component_registry_get_type (void); -void e_component_registry_construct (EComponentRegistry *component_registry, - EShell *shell); -EComponentRegistry *e_component_registry_new (EShell *shell); +GtkType e_component_registry_get_type (void); +void e_component_registry_construct (EComponentRegistry *component_registry, + EShell *shell); +EComponentRegistry *e_component_registry_new (EShell *shell); -gboolean e_component_registry_register_component (EComponentRegistry *component_registry, - const char *id); +gboolean e_component_registry_register_component (EComponentRegistry *component_registry, + const char *id); + +GList *e_component_registry_get_id_list (EComponentRegistry *component_registry); + +EvolutionShellComponentClient *e_component_registry_get_component_by_id (EComponentRegistry *component_registry, + const char *id); #ifdef __cplusplus } diff --git a/shell/e-shell.c b/shell/e-shell.c index 63c4b08f92..a7c0ca8c03 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -610,30 +610,16 @@ e_shell_get_folder_type_registry (EShell *shell) } -/** - * e_shell_save_settings: - * @shell: - * - * Save the settings for this shell. - * - * Return value: %TRUE if it worked, %FALSE otherwise. Even if %FALSE is - * returned, it is possible that at least part of the settings for the views - * have been saved. - **/ -gboolean -e_shell_save_settings (EShell *shell) +static gboolean +save_settings_for_views (EShell *shell) { EShellPrivate *priv; + GConfError *err = NULL; GList *p; gboolean retval; - GConfError *err = NULL; int i; - g_return_val_if_fail (shell != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL (shell), FALSE); - priv = shell->priv; - retval = TRUE; for (p = priv->views, i = 0; p != NULL; p = p->next, i++) { @@ -656,9 +642,101 @@ e_shell_save_settings (EShell *shell) g_list_length (priv->views), &err); gconf_client_suggest_sync (priv->gconf_client, NULL); + return TRUE; +} + +static gboolean +save_settings_for_component (EShell *shell, + const char *id, + EvolutionShellComponentClient *client) +{ + Bonobo_Unknown unknown_interface; + Evolution_Session session_interface; + CORBA_Environment ev; + char *prefix; + gboolean retval; + + unknown_interface = bonobo_object_corba_objref (BONOBO_OBJECT (client)); + g_assert (unknown_interface != CORBA_OBJECT_NIL); + + CORBA_exception_init (&ev); + + session_interface = Bonobo_Unknown_query_interface (unknown_interface, "IDL:Evolution/Session:1.0", &ev); + if (ev._major != CORBA_NO_EXCEPTION || CORBA_Object_is_nil (session_interface, &ev)) { + CORBA_exception_free (&ev); + return TRUE; + } + + prefix = g_strconcat ("/apps/Evolution/Shell/Components/", id, NULL); + Evolution_Session_save_configuration (session_interface, prefix, &ev); + + if (ev._major == CORBA_NO_EXCEPTION) + retval = TRUE; + else + retval = FALSE; + + g_free (prefix); + + CORBA_exception_free (&ev); + return retval; } +static gboolean +save_settings_for_components (EShell *shell) +{ + EShellPrivate *priv; + GList *component_ids; + GList *p; + gboolean retval; + + priv = shell->priv; + + g_assert (priv->component_registry); + component_ids = e_component_registry_get_id_list (priv->component_registry); + + retval = TRUE; + for (p = component_ids; p != NULL; p = p->next) { + EvolutionShellComponentClient *client; + const char *id; + + id = p->data; + client = e_component_registry_get_component_by_id (priv->component_registry, id); + + if (! save_settings_for_component (shell, id, client)) + retval = FALSE; + } + + e_free_string_list (component_ids); + + return retval; +} + +/** + * e_shell_save_settings: + * @shell: + * + * Save the settings for this shell. + * + * Return value: %TRUE if it worked, %FALSE otherwise. Even if %FALSE is + * returned, it is possible that at least part of the settings for the views + * have been saved. + **/ +gboolean +e_shell_save_settings (EShell *shell) +{ + gboolean views_saved; + gboolean components_saved; + + g_return_val_if_fail (shell != NULL, FALSE); + g_return_val_if_fail (E_IS_SHELL (shell), FALSE); + + views_saved = save_settings_for_views (shell); + components_saved = save_settings_for_components (shell); + + return views_saved && components_saved; +} + /** * e_shell_restore_from_settings: * @shell: An EShell object. diff --git a/shell/evolution-session.c b/shell/evolution-session.c new file mode 100644 index 0000000000..0bc09f1ebe --- /dev/null +++ b/shell/evolution-session.c @@ -0,0 +1,211 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-session.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.h" + +#include "e-util/e-util.h" + +#include "evolution-session.h" + + +#define PARENT_TYPE bonobo_object_get_type () +static BonoboObjectClass *parent_class = NULL; + +struct _EvolutionSessionPrivate { + int dummy; +}; + +enum { + LOAD_CONFIGURATION, + SAVE_CONFIGURATION, + LAST_SIGNAL +}; + +static int signals[LAST_SIGNAL]; + + +/* GtkObject methods. */ + +static void +impl_destroy (GtkObject *object) +{ + EvolutionSession *session; + EvolutionSessionPrivate *priv; + + session = EVOLUTION_SESSION (object); + priv = session->priv; + + g_free (priv); + + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + +/* CORBA interface implementation. */ + +static void +impl_Evolution_Session_save_configuration (PortableServer_Servant servant, + const CORBA_char *prefix, + CORBA_Environment *ev) +{ + BonoboObject *self; + + self = bonobo_object_from_servant (servant); + gtk_signal_emit (GTK_OBJECT (self), signals[SAVE_CONFIGURATION], prefix); +} + +static void +impl_Evolution_Session_load_configuration (PortableServer_Servant servant, + const CORBA_char *prefix, + CORBA_Environment *ev) +{ + BonoboObject *self; + + self = bonobo_object_from_servant (servant); + gtk_signal_emit (GTK_OBJECT (self), signals[LOAD_CONFIGURATION], prefix); +} + + +/* Initialization. */ + +static POA_Evolution_Session__vepv Evolution_Session_vepv; + +static void +corba_class_init (void) +{ + POA_Evolution_Session__vepv *vepv; + POA_Evolution_Session__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_Session__epv, 1); + epv->save_configuration = impl_Evolution_Session_save_configuration; + epv->load_configuration = impl_Evolution_Session_load_configuration; + + vepv = &Evolution_Session_vepv; + vepv->_base_epv = base_epv; + vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); + vepv->Evolution_Session_epv = epv; +} + +static void +class_init (EvolutionSessionClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + parent_class = gtk_type_class (bonobo_object_get_type ()); + + object_class->destroy = impl_destroy; + + signals[LOAD_CONFIGURATION] + = gtk_signal_new ("load_configuration", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionSessionClass, load_configuration), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); + signals[SAVE_CONFIGURATION] + = gtk_signal_new ("save_configuration", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionSessionClass, save_configuration), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); +} + +static void +init (EvolutionSession *session) +{ + EvolutionSessionPrivate *priv; + + priv = g_new (EvolutionSessionPrivate, 1); + + session->priv = priv; +} + + +static Evolution_Session +create_corba_session (BonoboObject *object) +{ + POA_Evolution_Session *servant; + CORBA_Environment ev; + + servant = (POA_Evolution_Session *) g_new0 (BonoboObjectServant, 1); + servant->vepv = &Evolution_Session_vepv; + + CORBA_exception_init (&ev); + + POA_Evolution_Session__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION){ + g_free (servant); + CORBA_exception_free (&ev); + return CORBA_OBJECT_NIL; + } + + CORBA_exception_free (&ev); + return (Evolution_Session) bonobo_object_activate_servant (object, servant); +} + +void +evolution_session_construct (EvolutionSession *session, + CORBA_Object corba_session) +{ + g_return_if_fail (session != NULL); + g_return_if_fail (corba_session != CORBA_OBJECT_NIL); + + bonobo_object_construct (BONOBO_OBJECT (session), corba_session); +} + +EvolutionSession * +evolution_session_new (void) +{ + EvolutionSession *session; + Evolution_Session corba_session; + + session = gtk_type_new (evolution_session_get_type ()); + + corba_session = create_corba_session (BONOBO_OBJECT (session)); + if (corba_session == CORBA_OBJECT_NIL) { + bonobo_object_unref (BONOBO_OBJECT (session)); + return NULL; + } + + evolution_session_construct (session, corba_session); + return session; +} + + +E_MAKE_TYPE (evolution_session, "EvolutionSession", EvolutionSession, class_init, init, PARENT_TYPE) diff --git a/shell/evolution-session.h b/shell/evolution-session.h new file mode 100644 index 0000000000..93c0ebed2a --- /dev/null +++ b/shell/evolution-session.h @@ -0,0 +1,72 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-session.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_SESSION_H__ +#define __EVOLUTION_SESSION_H__ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define EVOLUTION_TYPE_SESSION (evolution_session_get_type ()) +#define EVOLUTION_SESSION(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_SESSION, EvolutionSession)) +#define EVOLUTION_SESSION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_SESSION, EvolutionSessionClass)) +#define EVOLUTION_IS_SESSION(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_SESSION)) +#define EVOLUTION_IS_SESSION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_SESSION)) + + +typedef struct _EvolutionSession EvolutionSession; +typedef struct _EvolutionSessionPrivate EvolutionSessionPrivate; +typedef struct _EvolutionSessionClass EvolutionSessionClass; + +struct _EvolutionSession { + BonoboObject parent; + + EvolutionSessionPrivate *priv; +}; + +struct _EvolutionSessionClass { + BonoboObjectClass parent_class; + + void (* save_configuration) (EvolutionSession *session, const char *prefix); + void (* load_configuration) (EvolutionSession *session, const char *prefix); +}; + + +GtkType evolution_session_get_type (void); +void evolution_session_construct (EvolutionSession *session, + CORBA_Object corba_session); +EvolutionSession *evolution_session_new (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EVOLUTION_SESSION_H__ */ |