diff options
Diffstat (limited to 'shell/e-storage.c')
-rw-r--r-- | shell/e-storage.c | 146 |
1 files changed, 65 insertions, 81 deletions
diff --git a/shell/e-storage.c b/shell/e-storage.c index 1f54ee5afa..2f6ec935e5 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -32,22 +32,20 @@ #include "e-folder-tree.h" #include "e-shell-constants.h" -#include "e-shell-marshal.h" #include <gtk/gtkobject.h> #include <gtk/gtksignal.h> +#include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> -#include <string.h> - #define PARENT_TYPE GTK_TYPE_OBJECT static GtkObjectClass *parent_class = NULL; #define ES_CLASS(obj) \ - E_STORAGE_CLASS (GTK_OBJECT_GET_CLASS (obj)) + E_STORAGE_CLASS (GTK_OBJECT (obj)->klass) struct _EStoragePrivate { /* The set of folders we have in this storage. */ @@ -64,6 +62,7 @@ enum { NEW_FOLDER, UPDATED_FOLDER, REMOVED_FOLDER, + CLOSE_FOLDER, LAST_SIGNAL }; @@ -86,7 +85,7 @@ folder_destroy_notify (EFolderTree *tree, } e_folder = E_FOLDER (data); - g_object_unref (e_folder); + gtk_object_unref (GTK_OBJECT (e_folder)); } @@ -109,12 +108,13 @@ folder_changed_cb (EFolder *folder, path = e_folder_tree_get_path_for_data (priv->folder_tree, folder); g_assert (path != NULL); - g_signal_emit (storage, signals[UPDATED_FOLDER], 0, path); + gtk_signal_emit (GTK_OBJECT (storage), signals[UPDATED_FOLDER], path); - highlight = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (folder), "last_highlight")); + highlight = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (folder), "last_highlight")); if (highlight != e_folder_get_highlighted (folder)) { highlight = !highlight; - g_object_set_data (G_OBJECT (folder), "last_highlight", GINT_TO_POINTER (highlight)); + gtk_object_set_data (GTK_OBJECT (folder), "last_highlight", + GINT_TO_POINTER (highlight)); p = strrchr (path, '/'); if (p && p != path) { char *name; @@ -129,7 +129,7 @@ folder_changed_cb (EFolder *folder, } -/* GObject methods. */ +/* GtkObject methods. */ static void free_folder (gpointer path, gpointer folder, gpointer user_data) @@ -139,7 +139,7 @@ free_folder (gpointer path, gpointer folder, gpointer user_data) } static void -impl_finalize (GObject *object) +destroy (GtkObject *object) { EStorage *storage; EStoragePrivate *priv; @@ -156,9 +156,7 @@ impl_finalize (GObject *object) g_free (priv->name); - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -228,11 +226,9 @@ impl_async_xfer_folder (EStorage *storage, static void impl_async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data) + const char *path) { - (*callback) (storage, E_STORAGE_NOTIMPLEMENTED, path, data); + ; } static gboolean @@ -266,12 +262,12 @@ impl_async_remove_shared_folder (EStorage *storage, static void class_init (EStorageClass *class) { - GObjectClass *object_class; + GtkObjectClass *object_class; - object_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_ref(gtk_object_get_type ()); + object_class = GTK_OBJECT_CLASS (class); + parent_class = gtk_type_class (gtk_object_get_type ()); - object_class->finalize = impl_finalize; + object_class->destroy = destroy; class->get_subfolder_paths = impl_get_subfolder_paths; class->get_folder = impl_get_folder; @@ -286,32 +282,39 @@ class_init (EStorageClass *class) class->async_remove_shared_folder = impl_async_remove_shared_folder; signals[NEW_FOLDER] = - g_signal_new ("new_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, new_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); + gtk_signal_new ("new_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EStorageClass, new_folder), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); signals[UPDATED_FOLDER] = - g_signal_new ("updated_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, updated_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); + gtk_signal_new ("updated_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EStorageClass, updated_folder), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); signals[REMOVED_FOLDER] = - g_signal_new ("removed_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, removed_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); + gtk_signal_new ("removed_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EStorageClass, removed_folder), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); + signals[CLOSE_FOLDER] = + gtk_signal_new ("close_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EStorageClass, close_folder), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, + GTK_TYPE_STRING); + + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -356,7 +359,7 @@ e_storage_new (const char *name, { EStorage *new; - new = g_object_new (e_storage_get_type (), NULL); + new = gtk_type_new (e_storage_get_type ()); e_storage_construct (new, name, root_folder); @@ -490,21 +493,17 @@ e_storage_async_xfer_folder (EStorage *storage, void e_storage_async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data) + const char *path) { g_return_if_fail (storage != NULL); g_return_if_fail (E_IS_STORAGE (storage)); g_return_if_fail (path != NULL); g_return_if_fail (g_path_is_absolute (path)); - if (g_hash_table_lookup (storage->priv->pseudofolders, path) == NULL) { - (* callback) (storage, E_STORAGE_OK, path, data); + if (g_hash_table_lookup (storage->priv->pseudofolders, path) == NULL) return; - } - (* ES_CLASS (storage)->async_open_folder) (storage, path, callback, data); + (* ES_CLASS (storage)->async_open_folder) (storage, path); } @@ -711,30 +710,26 @@ e_storage_new_folder (EStorage *storage, } g_free (parent_path); - g_signal_connect_object (e_folder, "changed", G_CALLBACK (folder_changed_cb), storage, 0); + gtk_signal_connect_while_alive (GTK_OBJECT (e_folder), "changed", folder_changed_cb, + storage, GTK_OBJECT (storage)); - g_signal_emit (storage, signals[NEW_FOLDER], 0, path); + gtk_signal_emit (GTK_OBJECT (storage), signals[NEW_FOLDER], path); folder_changed_cb (e_folder, storage); return TRUE; } -/* This really should be called e_storage_set_has_subfolders, but then - * it would look like it was an EStorageSet function. (Fact o' the - * day: The word "set" has more distinct meanings than any other word - * in the English language.) Anyway, we now return you to your - * regularly scheduled source code, already in progress. - */ gboolean -e_storage_declare_has_subfolders (EStorage *storage, - const char *path, - const char *message) +e_storage_has_subfolders (EStorage *storage, + const char *path, + const char *message) { EStoragePrivate *priv; GList *subfolders, *f; EFolder *pseudofolder; char *pseudofolder_path; + gboolean retval; g_return_val_if_fail (storage != NULL, FALSE); g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); @@ -744,6 +739,8 @@ e_storage_declare_has_subfolders (EStorage *storage, priv = storage->priv; + gtk_signal_emit (GTK_OBJECT (storage), signals[CLOSE_FOLDER], path); + if (g_hash_table_lookup (priv->pseudofolders, path)) return TRUE; @@ -764,23 +761,10 @@ e_storage_declare_has_subfolders (EStorage *storage, g_hash_table_insert (priv->pseudofolders, g_strdup (path), pseudofolder); - return e_storage_new_folder (storage, pseudofolder_path, pseudofolder); -} - -gboolean -e_storage_get_has_subfolders (EStorage *storage, - const char *path) -{ - EStoragePrivate *priv; - - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - - priv = storage->priv; + retval = e_storage_new_folder (storage, pseudofolder_path, pseudofolder); + g_free (pseudofolder_path); - return g_hash_table_lookup (priv->pseudofolders, path) != NULL; + return retval; } gboolean @@ -816,7 +800,7 @@ e_storage_removed_folder (EStorage *storage, g_free (parent_path); } - g_signal_emit (storage, signals[REMOVED_FOLDER], 0, path); + gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVED_FOLDER], path); e_folder_tree_remove (priv->folder_tree, path); |