diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2000-09-11 19:12:16 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2000-09-11 19:12:16 +0800 |
commit | 0f618ac4cfae7d62fca7c0468458f55f3e4a3e9f (patch) | |
tree | 735c7930b24b243bf2cd72c6984c4d274c1ffb2e /shell | |
parent | 32496628e7268ad257e87a84d97add1239473dfa (diff) | |
download | gsoc2013-evolution-0f618ac4cfae7d62fca7c0468458f55f3e4a3e9f.tar.gz gsoc2013-evolution-0f618ac4cfae7d62fca7c0468458f55f3e4a3e9f.tar.zst gsoc2013-evolution-0f618ac4cfae7d62fca7c0468458f55f3e4a3e9f.zip |
Fully support setting the display name in the tree. It seems to work.
svn path=/trunk/; revision=5320
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 24 | ||||
-rw-r--r-- | shell/e-local-storage.c | 28 | ||||
-rw-r--r-- | shell/e-storage-set-view.c | 114 | ||||
-rw-r--r-- | shell/e-storage.c | 33 | ||||
-rw-r--r-- | shell/e-storage.h | 37 |
5 files changed, 155 insertions, 81 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 634c6ea9dd..0858065aec 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,27 @@ +2000-09-11 Ettore Perazzoli <ettore@helixcode.com> + + * e-storage.c (impl_list_folders): Removed. + (impl_get_subfolder_paths): New static function, implementation + for `::get_subfolder_paths'. + (class_init): Install it. + (e_storage_get_subfolder_paths): New. + + * e-storage.h: `list_folders' virtual method removed. New virtual + method `list_subfolder_paths'. + + * e-storage-set-view.c (etree_icon_at): If the folder is not + found, return NULL. + + * e-local-storage.c (bonobo_interface_set_display_name_cb): New + function, callback for the `set_display_name' signal on the + EvolutionLocalStorage. + (construct): Connect it. + + * e-storage-set-view.c (folder_changed_cb): New callback for the + "changed" signal emitted by the EFolders. It makes the model emit + the "changed" signal for the appropriate row. + (insert_folders): Connect it. + 2000-09-09 Ettore Perazzoli <ettore@helixcode.com> * e-storage-set-view.c (etree_value_at): Return the name of the diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c index 5e78f05b9a..7a8a1de8e2 100644 --- a/shell/e-local-storage.c +++ b/shell/e-local-storage.c @@ -507,6 +507,30 @@ impl_async_remove_folder (EStorage *storage, } +/* Callbacks for the `Evolution::LocalStorage' interface we are exposing to the outside world. */ + +static void +bonobo_interface_set_display_name_cb (EvolutionLocalStorage *bonobo_local_storage, + const char *path, + const char *display_name, + void *data) +{ + ELocalStorage *local_storage; + EFolder *folder; + + local_storage = E_LOCAL_STORAGE (data); + + g_print ("%s -- %s %s\n", __FUNCTION__, path, display_name); + + folder = e_storage_get_folder (E_STORAGE (local_storage), path); + if (folder == NULL) + return; + + e_folder_set_name (folder, display_name); + +} + + /* Initialization. */ static void @@ -569,6 +593,10 @@ construct (ELocalStorage *local_storage, g_assert (priv->bonobo_interface == NULL); priv->bonobo_interface = evolution_local_storage_new (E_LOCAL_STORAGE_NAME); + gtk_signal_connect (GTK_OBJECT (priv->bonobo_interface), "set_display_name", + GTK_SIGNAL_FUNC (bonobo_interface_set_display_name_cb), + local_storage); + return load_all_folders (local_storage); } diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index 670df6f920..9b11f57a94 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -29,6 +29,8 @@ #include <gnome.h> #include "e-util/e-util.h" +#include "e-util/e-gtk-utils.h" + #include "e-shell-constants.h" #include "e-storage-set-view.h" @@ -331,8 +333,6 @@ etable_drag_begin (EStorageSetView *storage_set_view, node = e_tree_model_node_at_row (priv->etree_model, row); priv->selected_row_path = e_tree_model_node_get_data (priv->etree_model, node); - - g_print ("dragging %s\n", priv->selected_row_path); } static void @@ -469,8 +469,9 @@ static GdkPixbuf* etree_icon_at (ETreeModel *etree, ETreePath *tree_path, void *model_data) { EStorageSetView *storage_set_view; - char *path; EStorageSet *storage_set; + EFolder *folder; + char *path; /* folders are from depth 2 on. depth 1 are storages and 0 is our (invisible) root node. */ @@ -482,8 +483,11 @@ etree_icon_at (ETreeModel *etree, ETreePath *tree_path, void *model_data) path = (char*)e_tree_model_node_get_data (etree, tree_path); - return get_pixbuf_for_folder (storage_set_view, - e_storage_set_get_folder (storage_set, path)); + folder = e_storage_set_get_folder (storage_set, path); + if (folder == NULL) + return NULL; + + return get_pixbuf_for_folder (storage_set_view, folder); } static void* @@ -608,6 +612,7 @@ new_folder_cb (EStorageSet *storage_set, ETreePath *new_node; const char *last_separator; char *parent_path; + char *copy_of_path; g_return_if_fail (g_path_is_absolute (path)); @@ -628,7 +633,8 @@ new_folder_cb (EStorageSet *storage_set, g_free (parent_path); - new_node = e_tree_model_node_insert (etree, parent_node, -1, (gpointer)g_strdup(path)); + copy_of_path = g_strdup (path); + new_node = e_tree_model_node_insert (etree, parent_node, -1, copy_of_path); if (! add_node_to_hash (storage_set_view, path, new_node)) { e_tree_model_node_remove (etree, new_node); @@ -694,32 +700,58 @@ init (EStorageSetView *storage_set_view) priv = g_new (EStorageSetViewPrivate, 1); - priv->storage_set = NULL; - priv->path_to_etree_node = g_hash_table_new (g_str_hash, g_str_equal); - priv->type_name_to_pixbuf = g_hash_table_new (g_str_hash, g_str_equal); - priv->selected_row_path = NULL; + priv->storage_set = NULL; + priv->path_to_etree_node = g_hash_table_new (g_str_hash, g_str_equal); + priv->type_name_to_pixbuf = g_hash_table_new (g_str_hash, g_str_equal); + priv->selected_row_path = NULL; storage_set_view->priv = priv; } -static int -folder_compare_cb (gconstpointer a, gconstpointer b) +/* Handling of the "changed" signal in EFolders displayed in the EStorageSetView. */ + +struct _FolderChangedCallbackData { + EStorageSetView *storage_set_view; + char *path; +}; +typedef struct _FolderChangedCallbackData FolderChangedCallbackData; + +static void +folder_changed_callback_data_destroy_notify (void *data) { - EFolder *folder_a; - EFolder *folder_b; - const char *name_a; - const char *name_b; + FolderChangedCallbackData *callback_data; - folder_a = E_FOLDER (a); - folder_b = E_FOLDER (b); + callback_data = (FolderChangedCallbackData *) data; - name_a = e_folder_get_name (folder_a); - name_b = e_folder_get_name (folder_b); + g_free (callback_data->path); + g_free (callback_data); +} - return strcmp (name_a, name_b); +static void +folder_changed_cb (EFolder *folder, + void *data) +{ + EStorageSetView *storage_set_view; + EStorageSetViewPrivate *priv; + FolderChangedCallbackData *callback_data; + ETreePath *node; + + callback_data = (FolderChangedCallbackData *) data; + + storage_set_view = callback_data->storage_set_view; + priv = callback_data->storage_set_view->priv; + + node = g_hash_table_lookup (priv->path_to_etree_node, callback_data->path); + if (node == NULL) { + g_warning ("EStorageSetView -- EFolder::changed emitted for a folder whose path I don't know."); + return; + } + + e_tree_model_node_changed (priv->etree_model, node); } + static void insert_folders (EStorageSetView *storage_set_view, ETreePath *parent, @@ -729,7 +761,7 @@ insert_folders (EStorageSetView *storage_set_view, EStorageSetViewPrivate *priv; ETreeModel *etree; ETreePath *node; - GList *folder_list; + GList *folder_path_list; GList *p; const char *storage_name; @@ -738,35 +770,41 @@ insert_folders (EStorageSetView *storage_set_view, storage_name = e_storage_get_name (storage); - folder_list = e_storage_list_folders (storage, path); - if (folder_list == NULL) + folder_path_list = e_storage_get_subfolder_paths (storage, path); + if (folder_path_list == NULL) return; - folder_list = g_list_sort (folder_list, folder_compare_cb); - - for (p = folder_list; p != NULL; p = p->next) { + for (p = folder_path_list; p != NULL; p = p->next) { + FolderChangedCallbackData *folder_changed_callback_data; EFolder *folder; const char *folder_name; - char *subpath; + const char *folder_path; char *full_path; - folder = E_FOLDER (p->data); + folder_path = (const char *) p->data; + folder = e_storage_get_folder (storage, folder_path); folder_name = e_folder_get_name (folder); - subpath = g_concat_dir_and_file (path, folder_name); - - full_path = g_strconcat("/", storage_name, subpath, NULL); - - node = e_tree_model_node_insert (etree, parent, -1, (gpointer)full_path); + full_path = g_strconcat ("/", storage_name, folder_path, NULL); + node = e_tree_model_node_insert (etree, parent, -1, (void *) full_path); + add_node_to_hash (storage_set_view, full_path, node); - insert_folders (storage_set_view, node, storage, subpath); + insert_folders (storage_set_view, node, storage, folder_path); - add_node_to_hash (storage_set_view, full_path, node); + folder_changed_callback_data = g_new (FolderChangedCallbackData, 1); + folder_changed_callback_data->storage_set_view = storage_set_view; + folder_changed_callback_data->path = g_strdup (folder_path); - g_free (subpath); + e_gtk_signal_connect_full_while_alive (GTK_OBJECT (folder), "changed", + GTK_SIGNAL_FUNC (folder_changed_cb), + NULL, + folder_changed_callback_data, + folder_changed_callback_data_destroy_notify, + FALSE, FALSE, + GTK_OBJECT (storage_set_view)); } - e_free_object_list (folder_list); + e_free_string_list (folder_path_list); } static void diff --git a/shell/e-storage.c b/shell/e-storage.c index ee09b5576c..df69f33fd9 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -97,33 +97,14 @@ destroy (GtkObject *object) /* EStorage methods. */ static GList * -impl_list_folders (EStorage *storage, - const char *path) +impl_get_subfolder_paths (EStorage *storage, + const char *path) { EStoragePrivate *priv; - GList *path_list; - GList *list; - GList *p; priv = storage->priv; - path_list = e_folder_tree_get_subfolders (priv->folder_tree, path); - - list = NULL; - for (p = path_list; p != NULL; p = p->next) { - EFolder *e_folder; - const char *sub_path; - - sub_path = (const char *) p->data; - e_folder = e_folder_tree_get_folder (priv->folder_tree, sub_path); - - gtk_object_ref (GTK_OBJECT (e_folder)); - list = g_list_prepend (list, e_folder); - } - - e_free_string_list (path_list); - - return list; + return e_folder_tree_get_subfolders (priv->folder_tree, path); } static EFolder * @@ -179,7 +160,7 @@ class_init (EStorageClass *class) object_class->destroy = destroy; - class->list_folders = impl_list_folders; + class->get_subfolder_paths = impl_get_subfolder_paths; class->get_folder = impl_get_folder; class->get_name = impl_get_name; class->async_create_folder = impl_async_create_folder; @@ -260,15 +241,15 @@ e_storage_path_is_relative (const char *path) GList * -e_storage_list_folders (EStorage *storage, - const char *path) +e_storage_get_subfolder_paths (EStorage *storage, + const char *path) { g_return_val_if_fail (storage != NULL, NULL); g_return_val_if_fail (E_IS_STORAGE (storage), NULL); g_return_val_if_fail (path != NULL, NULL); g_return_val_if_fail (g_path_is_absolute (path), NULL); - return (* ES_CLASS (storage)->list_folders) (storage, path); + return (* ES_CLASS (storage)->get_subfolder_paths) (storage, path); } EFolder * diff --git a/shell/e-storage.h b/shell/e-storage.h index 7b140bda22..0988e94250 100644 --- a/shell/e-storage.h +++ b/shell/e-storage.h @@ -81,28 +81,31 @@ struct _EStorageClass { /* Virtual methods. */ - GList * (* list_folders) (EStorage *storage, const char *path); - EFolder * (* get_folder) (EStorage *storage, const char *path); - const char * (* get_name) (EStorage *storage); - - void (* async_create_folder) (EStorage *storage, const char *path, - const char *type, const char *description, - EStorageResultCallback callback, void *data); - void (* async_remove_folder) (EStorage *storage, const char *path, - EStorageResultCallback callback, void *data); + GList * (* get_subfolder_paths) (EStorage *storage, const char *path); + EFolder * (* get_folder) (EStorage *storage, const char *path); + const char * (* get_name) (EStorage *storage); + + void (* async_create_folder) (EStorage *storage, const char *path, + const char *type, const char *description, + EStorageResultCallback callback, void *data); + void (* async_remove_folder) (EStorage *storage, const char *path, + EStorageResultCallback callback, void *data); }; -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); +GtkType e_storage_get_type (void); +void e_storage_construct (EStorage *storage); +EStorage *e_storage_new (void); -GList *e_storage_list_folders (EStorage *storage, const char *path); -EFolder *e_storage_get_folder (EStorage *storage, const char *path); +gboolean e_storage_path_is_relative (const char *path); +gboolean e_storage_path_is_absolute (const char *path); -const char *e_storage_get_name (EStorage *storage); +GList *e_storage_get_subfolder_paths (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. */ |