aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-06-08 01:01:52 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-06-08 01:01:52 +0800
commite7971bb4f5f1d262a3f3af99f81c221a724131da (patch)
tree9a27ea0d6eeda598771c40bea1b896a58d0bbe0f /shell
parent6aac85ab5b50dc9e3cc454c37858755a564120c3 (diff)
downloadgsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.gz
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.bz2
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.lz
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.xz
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.zst
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.zip
Fixed a refcount leak and added interfaces to add/remove folders
from an EStorage (although they are not implemented yet). svn path=/trunk/; revision=3460
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog67
-rw-r--r--shell/e-corba-storage.c2
-rw-r--r--shell/e-local-storage.c66
-rw-r--r--shell/e-local-storage.h6
-rw-r--r--shell/e-shell-view.c6
-rw-r--r--shell/e-shell.c33
-rw-r--r--shell/e-storage-set-view.c32
-rw-r--r--shell/e-storage-set.c44
-rw-r--r--shell/e-storage-set.h34
-rw-r--r--shell/e-storage.c148
-rw-r--r--shell/e-storage.h64
11 files changed, 396 insertions, 106 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 410e4e8b0f..b52b02446e 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,70 @@
+2000-06-07 Ettore Perazzoli <ettore@helixcode.com>
+
+ * e-storage.c (folder_destroy): Don't destroy the subfolders.
+ (remove_folder): New helper function.
+ (free_private): Use it.
+ (e_storage_removed_folder): Use it here too.
+ (folder_destroy): Don't unref the EFolder if NULL.
+
+ * e-storage-set-view.c (e_storage_set_view_construct): Use
+ `gtk_signal_connect_while_alive()' instead of just
+ `gtk_signal_connect()' so that the signal handler is automatically
+ removed when we are destroyed.
+
+ * e-storage-set.c (e_storage_set_remove_all_storages): New
+ function.
+
+ * e-shell-view.c (e_shell_view_construct): Use `bonobo_object_ref'
+ on the shell instead of `gtk_object_ref'.
+ (destroy): Unref the shell.
+
+ * e-local-storage.h: #include "e-component-registry.h".
+
+ * e-shell.c (setup_local_storage): Renamed from `setup_storages'.
+ Only set up the local storage, not the CORBA one, and don't create
+ the storage set.
+ (e_shell_construct): Create the storage set here instead. Call
+ `setup_local_storage' after setting up the components.
+
+ * e-local-storage.c: New member `component_registry' in
+ `ELocalStoragePrivate'.
+ (init): Init to NULL.
+ (destroy): If not null, unref it.
+ (e_local_storage_open): New arg @component_registry.
+ (construct): New arg @component_registry. Init
+ `priv->component_registry' from it.
+
+ * e-local-storage.c (impl_get_name): Renamed from `get_name'.
+ (impl_create_folder): New function, implementing
+ `EStorage::create_folder'. Just a stub for now.
+ (impl_remove_folder): New function, implementing
+ `EStorage::remove_folder'. Just a stub for now.
+ (class_init): Install these stub implementations.
+
+ * e-storage.c (e_storage_remove_folder): New function.
+ (e_storage_create_folder): New function.
+ (impl_create_folder): New function, default implementation for
+ `::create_folder'.
+ (impl_remove_folder): New function, default implementation for
+ `::remove_folder'.
+ (class_init): Install the implementations.
+
+ * e-storage.c (impl_get_name): Renamed from `get_name'.
+ (impl_get_folder): Renamed from `get_folder'.
+ (impl_list_folders): Renamed from `list_folders'.
+
+ * e-storage.h: New virtual methods `remove_folder',
+ `create_folder'.
+
+ * e-storage.c (e_storage_removed_folder): Renamed from
+ `e_storage_remove_folder'.
+ * e-corba-storage.c (impl_StorageListener_removed_folder): Updated
+ accordingly.
+
+2000-06-02 Ettore Perazzoli <ettore@helixcode.com>
+
+ * e-shell-view.c (setup_bonobo_ui_handler): Create the default toolbar.
+
2000-06-02 Jeffrey Stedfast <fejj@helixcode.com>
* e-shell-view-menu.c: Changed "Using the Shell" to "Getting Started"
diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c
index 00f1c575b0..b4320a4c52 100644
--- a/shell/e-corba-storage.c
+++ b/shell/e-corba-storage.c
@@ -134,7 +134,7 @@ impl_StorageListener_removed_folder (PortableServer_Servant servant,
storage_listener_servant = (StorageListenerServant *) servant;
storage = storage_listener_servant->storage;
- if (! e_storage_remove_folder (storage, path))
+ if (! e_storage_removed_folder (storage, path))
CORBA_exception_set (ev,
CORBA_USER_EXCEPTION,
ex_Evolution_StorageListener_NotFound,
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index f559d30f34..b97b25b8ec 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -54,6 +54,7 @@ static EStorageClass *parent_class = NULL;
#define SUBFOLDER_DIR_NAME_LEN 10
struct _ELocalStoragePrivate {
+ EComponentRegistry *component_registry;
char *base_path;
};
@@ -233,7 +234,7 @@ load_all_folders (ELocalStorage *local_storage)
/* GtkObject methods. */
static void
-destroy (GtkObject *object)
+impl_destroy (GtkObject *object)
{
ELocalStorage *local_storage;
ELocalStoragePrivate *priv;
@@ -242,6 +243,10 @@ destroy (GtkObject *object)
priv = local_storage->priv;
g_free (priv->base_path);
+
+ if (priv->component_registry != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->component_registry));
+
g_free (priv);
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -251,12 +256,36 @@ destroy (GtkObject *object)
/* EStorage methods. */
static const char *
-get_name (EStorage *storage)
+impl_get_name (EStorage *storage)
{
/* FIXME this sucks. */
return "local";
}
+static void
+impl_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
+{
+ ELocalStorage *local_storage;
+
+ local_storage = E_LOCAL_STORAGE (storage);
+}
+
+static void
+impl_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data)
+{
+ ELocalStorage *local_storage;
+
+ local_storage = E_LOCAL_STORAGE (storage);
+}
+
/* Initialization. */
@@ -266,13 +295,15 @@ class_init (ELocalStorageClass *class)
EStorageClass *storage_class;
GtkObjectClass *object_class;
- parent_class = gtk_type_class (e_storage_get_type ());
+ parent_class = gtk_type_class (e_storage_get_type ());
+ object_class = GTK_OBJECT_CLASS (class);
+ storage_class = E_STORAGE_CLASS (class);
- object_class = GTK_OBJECT_CLASS (class);
- object_class->destroy = destroy;
+ object_class->destroy = impl_destroy;
- storage_class = E_STORAGE_CLASS (class);
- storage_class->get_name = get_name;
+ storage_class->get_name = impl_get_name;
+ storage_class->create_folder = impl_create_folder;
+ storage_class->remove_folder = impl_remove_folder;
}
static void
@@ -282,7 +313,8 @@ init (ELocalStorage *local_storage)
priv = g_new (ELocalStoragePrivate, 1);
- priv->base_path = NULL;
+ priv->base_path = NULL;
+ priv->component_registry = NULL;
local_storage->priv = priv;
}
@@ -290,33 +322,45 @@ init (ELocalStorage *local_storage)
static gboolean
construct (ELocalStorage *local_storage,
+ EComponentRegistry *component_registry,
const char *base_path)
{
+ ELocalStoragePrivate *priv;
int base_path_len;
e_storage_construct (E_STORAGE (local_storage));
+ priv = local_storage->priv;
+
base_path_len = strlen (base_path);
while (base_path_len > 0 && base_path[base_path_len - 1] == G_DIR_SEPARATOR)
base_path_len--;
g_return_val_if_fail (base_path_len != 0, FALSE);
- local_storage->priv->base_path = g_strndup (base_path, base_path_len);
+ g_assert (priv->component_registry == NULL);
+ gtk_object_ref (GTK_OBJECT (component_registry));
+ priv->component_registry = component_registry;
+
+ g_assert (priv->base_path == NULL);
+ priv->base_path = g_strndup (base_path, base_path_len);
return load_all_folders (local_storage);
}
EStorage *
-e_local_storage_open (const char *base_path)
+e_local_storage_open (EComponentRegistry *component_registry,
+ const char *base_path)
{
EStorage *new;
+ 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 (base_path != NULL, NULL);
new = gtk_type_new (e_local_storage_get_type ());
- if (! construct (E_LOCAL_STORAGE (new), base_path)) {
+ if (! construct (E_LOCAL_STORAGE (new), component_registry, base_path)) {
gtk_object_unref (GTK_OBJECT (new));
return NULL;
}
diff --git a/shell/e-local-storage.h b/shell/e-local-storage.h
index 569216941e..feecda75a7 100644
--- a/shell/e-local-storage.h
+++ b/shell/e-local-storage.h
@@ -28,6 +28,7 @@
#include <config.h>
#endif
+#include "e-component-registry.h"
#include "e-storage.h"
#ifdef __cplusplus
@@ -57,8 +58,9 @@ struct _ELocalStorageClass {
GtkType e_local_storage_get_type (void);
-EStorage *e_local_storage_open (const char *base_path);
-const char *e_local_storage_get_base_path (ELocalStorage *storage);
+EStorage *e_local_storage_open (EComponentRegistry *component_registry,
+ const char *base_path);
+const char *e_local_storage_get_base_path (ELocalStorage *storage);
#ifdef __cplusplus
}
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 4b419937d0..ec5ac167b6 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -311,6 +311,7 @@ setup_bonobo_ui_handler (EShellView *shell_view)
bonobo_ui_handler_set_app (uih, GNOME_APP (shell_view));
bonobo_ui_handler_create_menubar (uih);
+ bonobo_ui_handler_create_toolbar (uih, "Toolbar");
bonobo_ui_handler_set_statusbar (uih, priv->appbar);
priv->uih = uih;
@@ -343,6 +344,9 @@ destroy (GtkObject *object)
g_hash_table_foreach (priv->uri_to_control, hash_forall_destroy_control, NULL);
g_hash_table_destroy (priv->uri_to_control);
+
+ if (priv->shell != NULL)
+ bonobo_object_unref (BONOBO_OBJECT (priv->shell));
g_free (priv->uri);
@@ -432,7 +436,7 @@ e_shell_view_construct (EShellView *shell_view,
gnome_app_construct (GNOME_APP (shell_view), "evolution", "Evolution");
- gtk_object_ref (GTK_OBJECT (shell));
+ bonobo_object_ref (BONOBO_OBJECT (shell));
priv->shell = shell;
setup_widgets (shell_view);
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 909ed0afd2..4fbb20dca1 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -161,7 +161,7 @@ setup_corba_storages (EShell *shell)
}
static gboolean
-setup_storages (EShell *shell)
+setup_local_storage (EShell *shell)
{
EStorage *local_storage;
EShellPrivate *priv;
@@ -171,7 +171,8 @@ setup_storages (EShell *shell)
local_storage_path = g_concat_dir_and_file (priv->local_directory,
LOCAL_STORAGE_DIRECTORY);
- local_storage = e_local_storage_open (local_storage_path);
+ local_storage = e_local_storage_open (shell->priv->component_registry,
+ local_storage_path);
if (local_storage == NULL) {
g_warning (_("Cannot set up local storage -- %s"), local_storage_path);
g_free (local_storage_path);
@@ -181,12 +182,11 @@ setup_storages (EShell *shell)
g_assert (shell->priv->folder_type_registry);
- priv->storage_set = e_storage_set_new (shell->priv->folder_type_registry);
e_storage_set_add_storage (priv->storage_set, local_storage);
gtk_object_unref (GTK_OBJECT (local_storage));
- return setup_corba_storages (shell);
+ return TRUE;
}
@@ -362,16 +362,20 @@ e_shell_construct (EShell *shell,
priv = shell->priv;
- priv->local_directory = g_strdup (local_directory);
+ priv->local_directory = g_strdup (local_directory);
priv->folder_type_registry = e_folder_type_registry_new ();
+ priv->storage_set = e_storage_set_new (shell->priv->folder_type_registry);
- /* Storages must be set up before the components, because otherwise components
+ /* CORBA storages must be set up before the components, because otherwise components
cannot register their own storages. */
- if (! setup_storages (shell))
+ if (! setup_corba_storages (shell))
return;
setup_components (shell);
+ /* The local storage depends on the component registry. */
+ setup_local_storage (shell);
+
shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml");
priv->shortcuts = e_shortcuts_new (priv->storage_set,
priv->folder_type_registry,
@@ -492,18 +496,23 @@ e_shell_quit (EShell *shell)
g_list_free (priv->views);
priv->views = NULL;
+ bonobo_object_unref (BONOBO_OBJECT (priv->corba_storage_registry));
+
+ priv->corba_storage_registry = NULL;
+
+ e_storage_set_remove_all_storages (priv->storage_set);
gtk_object_unref (GTK_OBJECT (priv->storage_set));
+
gtk_object_unref (GTK_OBJECT (priv->shortcuts));
gtk_object_unref (GTK_OBJECT (priv->folder_type_registry));
gtk_object_unref (GTK_OBJECT (priv->component_registry));
- priv->storage_set = NULL;
- priv->shortcuts = NULL;
+ priv->storage_set = NULL;
+ priv->shortcuts = NULL;
priv->folder_type_registry = NULL;
- priv->component_registry = NULL;
+ priv->component_registry = NULL;
- /* FIXME Unref does not work here. Probably somewhere we are leaking a _ref(). */
- bonobo_object_destroy (BONOBO_OBJECT (shell));
+ bonobo_object_unref (BONOBO_OBJECT (shell));
}
diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c
index 62b1cd20c6..989f6c5f62 100644
--- a/shell/e-storage-set-view.c
+++ b/shell/e-storage-set-view.c
@@ -759,29 +759,33 @@ e_storage_set_view_construct (EStorageSetView *storage_set_view,
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
ctree = GTK_CTREE (storage_set_view);
+ priv = storage_set_view->priv;
/* Set up GtkCTree/GtkCList parameters. */
- gtk_ctree_construct (ctree, 1, 0, NULL);
- gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
+ gtk_ctree_construct (ctree, 1, 0, NULL);
+ gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
gtk_ctree_set_expander_style (ctree, GTK_CTREE_EXPANDER_SQUARE);
- gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_BROWSE);
- gtk_clist_set_row_height (GTK_CLIST (ctree), E_SHELL_MINI_ICON_SIZE);
+
+ gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_BROWSE);
+ gtk_clist_set_row_height (GTK_CLIST (ctree), E_SHELL_MINI_ICON_SIZE);
gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE);
- priv = storage_set_view->priv;
-
gtk_object_ref (GTK_OBJECT (storage_set));
priv->storage_set = storage_set;
- gtk_signal_connect (GTK_OBJECT (storage_set), "new_storage",
- GTK_SIGNAL_FUNC (new_storage_cb), storage_set_view);
- gtk_signal_connect (GTK_OBJECT (storage_set), "removed_storage",
- GTK_SIGNAL_FUNC (removed_storage_cb), storage_set_view);
- gtk_signal_connect (GTK_OBJECT (storage_set), "new_folder",
- GTK_SIGNAL_FUNC (new_folder_cb), storage_set_view);
- gtk_signal_connect (GTK_OBJECT (storage_set), "removed_folder",
- GTK_SIGNAL_FUNC (removed_folder_cb), storage_set_view);
+ gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "new_storage",
+ GTK_SIGNAL_FUNC (new_storage_cb), storage_set_view,
+ GTK_OBJECT (storage_set_view));
+ gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "removed_storage",
+ GTK_SIGNAL_FUNC (removed_storage_cb), storage_set_view,
+ GTK_OBJECT (storage_set_view));
+ gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "new_folder",
+ GTK_SIGNAL_FUNC (new_folder_cb), storage_set_view,
+ GTK_OBJECT (storage_set_view));
+ gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "removed_folder",
+ GTK_SIGNAL_FUNC (removed_folder_cb), storage_set_view,
+ GTK_OBJECT (storage_set_view));
storage_list = e_storage_set_get_storage_list (storage_set);
diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c
index 7a71f518fe..33dc366afe 100644
--- a/shell/e-storage-set.c
+++ b/shell/e-storage-set.c
@@ -49,7 +49,7 @@ struct _NamedStorage {
typedef struct _NamedStorage NamedStorage;
struct _EStorageSetPrivate {
- GList *storages;
+ GList *storages; /* EStorage */
GHashTable *name_to_named_storage;
EFolderTypeRegistry *folder_type_registry;
@@ -85,6 +85,19 @@ named_storage_destroy (NamedStorage *named_storage)
g_free (named_storage);
}
+static gboolean
+name_to_named_storage_foreach_destroy (void *key,
+ void *value,
+ void *user_data)
+{
+ NamedStorage *named_storage;
+
+ named_storage = (NamedStorage *) value;
+ named_storage_destroy (named_storage);
+
+ return TRUE;
+}
+
/* Handling for signals coming from the EStorages. */
@@ -345,6 +358,35 @@ e_storage_set_remove_storage (EStorageSet *storage_set,
return TRUE;
}
+void
+e_storage_set_remove_all_storages (EStorageSet *storage_set)
+{
+ EStorageSetPrivate *priv;
+ GList *p;
+
+ g_return_if_fail (storage_set != NULL);
+ g_return_if_fail (E_IS_STORAGE_SET (storage_set));
+
+ priv = storage_set->priv;
+
+ for (p = priv->storages; p != NULL; p = p->next) {
+ EStorage *storage;
+
+ storage = E_STORAGE (p->data);
+
+ gtk_signal_emit (GTK_OBJECT (storage_set), signals[REMOVED_STORAGE], storage);
+ gtk_object_unref (GTK_OBJECT (storage));
+ }
+
+ g_hash_table_foreach_remove (priv->name_to_named_storage,
+ name_to_named_storage_foreach_destroy,
+ NULL);
+
+ g_list_free (priv->storages);
+ priv->storages = NULL;
+}
+
+
EStorage *
e_storage_set_get_storage (EStorageSet *storage_set,
const char *name)
diff --git a/shell/e-storage-set.h b/shell/e-storage-set.h
index e41471764d..9f9b38ac64 100644
--- a/shell/e-storage-set.h
+++ b/shell/e-storage-set.h
@@ -68,22 +68,24 @@ struct _EStorageSetClass {
};
-GtkType e_storage_set_get_type (void);
-void e_storage_set_construct (EStorageSet *storage_set,
- EFolderTypeRegistry *folder_type_registry);
-EStorageSet *e_storage_set_new (EFolderTypeRegistry *folder_type_registry);
-
-gboolean e_storage_set_add_storage (EStorageSet *storage_set,
- EStorage *storage);
-gboolean e_storage_set_remove_storage (EStorageSet *storage_set,
- EStorage *storage);
-
-GList *e_storage_set_get_storage_list (EStorageSet *storage_set);
-EStorage *e_storage_set_get_storage (EStorageSet *storage_set,
- const char *storage_name);
-EFolder *e_storage_set_get_folder (EStorageSet *storage_set,
- const char *path);
-GtkWidget *e_storage_set_new_view (EStorageSet *storage_set);
+GtkType e_storage_set_get_type (void);
+void e_storage_set_construct (EStorageSet *storage_set,
+ EFolderTypeRegistry *folder_type_registry);
+EStorageSet *e_storage_set_new (EFolderTypeRegistry *folder_type_registry);
+
+gboolean e_storage_set_add_storage (EStorageSet *storage_set,
+ EStorage *storage);
+gboolean e_storage_set_remove_storage (EStorageSet *storage_set,
+ EStorage *storage);
+void e_storage_set_remove_all_storages (EStorageSet *storage_set);
+
+GList *e_storage_set_get_storage_list (EStorageSet *storage_set);
+EStorage *e_storage_set_get_storage (EStorageSet *storage_set,
+ const char *storage_name);
+EFolder *e_storage_set_get_folder (EStorageSet *storage_set,
+ const char *path);
+
+GtkWidget *e_storage_set_new_view (EStorageSet *storage_set);
EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set);
diff --git a/shell/e-storage.c b/shell/e-storage.c
index 98ce48da70..b50a080fc4 100644
--- a/shell/e-storage.c
+++ b/shell/e-storage.c
@@ -64,6 +64,8 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+/* Folder handling. */
+
static Folder *
folder_new (EFolder *e_folder,
const char *path)
@@ -71,9 +73,9 @@ folder_new (EFolder *e_folder,
Folder *folder;
folder = g_new (Folder, 1);
- folder->path = g_strdup (path);
- folder->parent = NULL;
- folder->e_folder = e_folder;
+ folder->path = g_strdup (path);
+ folder->parent = NULL;
+ folder->e_folder = e_folder;
folder->subfolders = NULL;
return folder;
@@ -95,29 +97,56 @@ folder_add_subfolder (Folder *folder, Folder *subfolder)
static void
folder_destroy (Folder *folder)
{
- GList *p;
+ g_assert (folder->subfolders == NULL);
if (folder->parent != NULL)
folder_remove_subfolder (folder->parent, folder);
g_free (folder->path);
- gtk_object_unref (GTK_OBJECT (folder->e_folder));
-
- for (p = folder->subfolders; p != NULL; p = p->next)
- folder_destroy (p->data);
+ if (folder->e_folder != NULL)
+ gtk_object_unref (GTK_OBJECT (folder->e_folder));
g_free (folder);
}
static void
+remove_folder (EStorage *storage,
+ Folder *folder)
+{
+ EStoragePrivate *priv;
+
+ priv = storage->priv;
+
+ if (folder->subfolders != NULL) {
+ GList *p;
+
+ for (p = folder->subfolders; p != NULL; p = p->next) {
+ Folder *subfolder;
+
+ subfolder = (Folder *) p->data;
+ remove_folder (storage, subfolder);
+ }
+
+ g_list_free (folder->subfolders);
+ folder->subfolders = NULL;
+ }
+
+ g_hash_table_remove (priv->path_to_folder, folder->path);
+
+ folder_destroy (folder);
+}
+
+static void
free_private (EStorage *storage)
{
EStoragePrivate *priv;
+ Folder *root_folder;
priv = storage->priv;
- g_hash_table_foreach (priv->path_to_folder, (GHFunc) folder_destroy, NULL);
+ root_folder = g_hash_table_lookup (priv->path_to_folder, G_DIR_SEPARATOR_S);
+ remove_folder (storage, root_folder);
g_hash_table_destroy (priv->path_to_folder);
@@ -125,11 +154,26 @@ free_private (EStorage *storage)
}
+/* GtkObject methods. */
+
+static void
+destroy (GtkObject *object)
+{
+ EStorage *storage;
+
+ storage = E_STORAGE (object);
+
+ free_private (storage);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
/* EStorage methods. */
static GList *
-list_folders (EStorage *storage,
- const char *path)
+impl_list_folders (EStorage *storage,
+ const char *path)
{
Folder *folder;
Folder *subfolder;
@@ -152,8 +196,8 @@ list_folders (EStorage *storage,
}
static EFolder *
-get_folder (EStorage *storage,
- const char *path)
+impl_get_folder (EStorage *storage,
+ const char *path)
{
EStoragePrivate *priv;
Folder *folder;
@@ -168,24 +212,29 @@ get_folder (EStorage *storage,
}
static const char *
-get_name (EStorage *storage)
+impl_get_name (EStorage *storage)
{
- return "(No name)";
+ return _("(No name)");
}
-
-/* GtkObject methods. */
-
static void
-destroy (GtkObject *object)
+impl_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
{
- EStorage *storage;
-
- storage = E_STORAGE (object);
-
- free_private (storage);
+ (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
+}
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+static void
+impl_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data)
+{
+ (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
@@ -201,9 +250,11 @@ class_init (EStorageClass *class)
object_class->destroy = destroy;
- class->list_folders = list_folders;
- class->get_folder = get_folder;
- class->get_name = get_name;
+ class->list_folders = impl_list_folders;
+ class->get_folder = impl_get_folder;
+ class->get_name = impl_get_name;
+ class->create_folder = impl_create_folder;
+ class->remove_folder = impl_remove_folder;
signals[NEW_FOLDER] =
gtk_signal_new ("new_folder",
@@ -317,6 +368,40 @@ e_storage_get_name (EStorage *storage)
}
+/* Folder operations. */
+
+void
+e_storage_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
+{
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (E_IS_STORAGE (storage));
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (type != NULL);
+ g_return_if_fail (callback != NULL);
+
+ (* ES_CLASS (storage)->create_folder) (storage, path, type, description, callback, data);
+}
+
+void
+e_storage_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data)
+{
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (E_IS_STORAGE (storage));
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (callback != NULL);
+
+ (* ES_CLASS (storage)->remove_folder) (storage, path, callback, data);
+}
+
+
/* These functions are used by subclasses to add and remove folders from the
state stored in the storage object. */
@@ -374,8 +459,8 @@ e_storage_new_folder (EStorage *storage,
}
gboolean
-e_storage_remove_folder (EStorage *storage,
- const char *path)
+e_storage_removed_folder (EStorage *storage,
+ const char *path)
{
EStoragePrivate *priv;
Folder *folder;
@@ -395,8 +480,7 @@ e_storage_remove_folder (EStorage *storage,
gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVED_FOLDER], path);
- g_hash_table_remove (priv->path_to_folder, path);
- folder_destroy (folder);
+ remove_folder (storage, folder);
return TRUE;
}
diff --git a/shell/e-storage.h b/shell/e-storage.h
index 478feef5a6..b144d0af5a 100644
--- a/shell/e-storage.h
+++ b/shell/e-storage.h
@@ -46,6 +46,18 @@ typedef struct _EStorage EStorage;
typedef struct _EStoragePrivate EStoragePrivate;
typedef struct _EStorageClass EStorageClass;
+enum _EStorageResult {
+ E_STORAGE_OK,
+ E_STORAGE_NOTIMPLEMENTED,
+ E_STORAGE_NOTFOUND,
+ E_STORAGE_EXISTS,
+ E_STORAGE_IO,
+ E_STORAGE_UNSUPPORTEDTYPE
+};
+typedef enum _EStorageResult EStorageResult;
+
+typedef void (* EStorageResultCallback) (EStorage *storage, EStorageResult result, void *data);
+
#include "e-folder.h"
struct _EStorage {
@@ -58,31 +70,51 @@ struct _EStorageClass {
GtkObjectClass parent_class;
/* Signals. */
+
void * (* new_folder) (EStorage *storage, const char *path);
void * (* removed_folder) (EStorage *storage, const char *path);
/* Virtual methods. */
- GList * (* list_folders) (EStorage *storage, const char *path);
- EFolder * (* get_folder) (EStorage *storage, const char *path);
- const char * (* get_name) (EStorage *storage);
-};
-
-GtkType e_storage_get_type (void);
-void e_storage_construct (EStorage *storage);
-EStorage *e_storage_new (void);
-
-gboolean e_storage_path_is_relative (const char *path);
-gboolean e_storage_path_is_absolute (const char *path);
+ GList * (* list_folders) (EStorage *storage, const char *path);
+ EFolder * (* get_folder) (EStorage *storage, const char *path);
+ const char * (* get_name) (EStorage *storage);
-GList *e_storage_list_folders (EStorage *storage, const char *path);
-EFolder *e_storage_get_folder (EStorage *storage, const char *path);
+ void (* create_folder) (EStorage *storage, const char *path,
+ const char *type, const char *description,
+ EStorageResultCallback callback, void *data);
+ void (* remove_folder) (EStorage *storage, const char *path,
+ EStorageResultCallback callback, void *data);
+};
-const char *e_storage_get_name (EStorage *storage);
+
+GtkType e_storage_get_type (void);
+void e_storage_construct (EStorage *storage);
+EStorage *e_storage_new (void);
+gboolean e_storage_path_is_relative (const char *path);
+gboolean e_storage_path_is_absolute (const char *path);
+
+GList *e_storage_list_folders (EStorage *storage, const char *path);
+EFolder *e_storage_get_folder (EStorage *storage, const char *path);
+
+const char *e_storage_get_name (EStorage *storage);
+
+/* Folder operations. */
+
+void e_storage_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data);
+void e_storage_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data);
/* Protected. C++ anyone? */
-gboolean e_storage_new_folder (EStorage *storage, const char *path, EFolder *folder);
-gboolean e_storage_remove_folder (EStorage *storage, const char *path);
+gboolean e_storage_new_folder (EStorage *storage, const char *path, EFolder *folder);
+gboolean e_storage_removed_folder (EStorage *storage, const char *path);
#ifdef __cplusplus
}