diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-07-10 23:26:31 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-07-10 23:26:31 +0800 |
commit | 090af2cb0e680190161fa4fb204f32c2c432dc26 (patch) | |
tree | 98c5993e67e3bf3d0c6d7d2fb9da57621c6ed763 /shell | |
parent | a3a24835e896c685201c7dfc0aea405c92b953b3 (diff) | |
download | gsoc2013-evolution-090af2cb0e680190161fa4fb204f32c2c432dc26.tar.gz gsoc2013-evolution-090af2cb0e680190161fa4fb204f32c2c432dc26.tar.zst gsoc2013-evolution-090af2cb0e680190161fa4fb204f32c2c432dc26.zip |
Pass zero as the @sorting_priority to evolution_storage_new_folder().
* gui/component/addressbook-storage.c (load_source_data): Pass
zero as the @sorting_priority to evolution_storage_new_folder().
(addressbook_storage_add_source): Likewise.
* subscribe-dialog.c (recursive_add_folder): Pass zero as
@sorting_priority to evolution_storage_new_folder().
* mail-folder-cache.c (real_flush_updates): Pass zero as
@sorting_priority to evolution_storage_new_folder().
* evolution-test-component.c (setup_custom_storage): Pass
@sorting_priority to evolution_storage_new_folder() so we test it.
Also make /FirstFolder have an "inbox" custom icon.
* e-local-storage.c (new_folder): Pass zero as @sorting_priority
to evolution_storage_new_folder().
* evolution-storage.c (evolution_storage_new_folder): New arg
@sorting_priority; put it in the CORBA folder struct.
* evolution-shell-client.c
(impl_FolderSelectionListener_selected): Copy the sortingPriority
as well.
* e-folder.c (e_folder_to_corba): Set sortingPriority.
* e-corba-storage-registry.c
(impl_StorageRegistry_getFolderByUri): Set sortingPriority in the
new CORBA Folder struct.
* e-corba-storage.c (impl_StorageListener_notifyFolderCreated):
Set the custom_icon if folder->customIconName is not an empty
string. Likewise, set the sorting_priority
* Evolution-common.idl: New member sortingPriority in struct
Folder.
* e-storage-set-view.c (folder_sort_callback): Sort according to
the sorting_priorities.
* e-folder.c: New member sorting_priority in EFolderPrivate.
(init): Init to zero.
(e_folder_set_custom_icon): Emit "changed" if required.
(e_folder_set_sorting_priority): New.
svn path=/trunk/; revision=17404
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 37 | ||||
-rw-r--r-- | shell/Evolution-common.idl | 1 | ||||
-rw-r--r-- | shell/e-corba-storage-registry.c | 13 | ||||
-rw-r--r-- | shell/e-corba-storage.c | 12 | ||||
-rw-r--r-- | shell/e-folder.c | 80 | ||||
-rw-r--r-- | shell/e-folder.h | 2 | ||||
-rw-r--r-- | shell/e-local-storage.c | 3 | ||||
-rw-r--r-- | shell/e-storage-set-view.c | 59 | ||||
-rw-r--r-- | shell/evolution-shell-client.c | 1 | ||||
-rw-r--r-- | shell/evolution-storage.c | 14 | ||||
-rw-r--r-- | shell/evolution-storage.h | 3 | ||||
-rw-r--r-- | shell/evolution-test-component.c | 9 |
12 files changed, 182 insertions, 52 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index a368248f01..6f3800622a 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,40 @@ +2002-07-10 Ettore Perazzoli <ettore@ximian.com> + + * evolution-test-component.c (setup_custom_storage): Pass + @sorting_priority to evolution_storage_new_folder() so we test it. + Also make /FirstFolder have an "inbox" custom icon. + + * e-local-storage.c (new_folder): Pass zero as @sorting_priority + to evolution_storage_new_folder(). + + * evolution-storage.c (evolution_storage_new_folder): New arg + @sorting_priority; put it in the CORBA folder struct. + + * evolution-shell-client.c + (impl_FolderSelectionListener_selected): Copy the sortingPriority + as well. + + * e-folder.c (e_folder_to_corba): Set sortingPriority. + + * e-corba-storage-registry.c + (impl_StorageRegistry_getFolderByUri): Set sortingPriority in the + new CORBA Folder struct. + + * e-corba-storage.c (impl_StorageListener_notifyFolderCreated): + Set the custom_icon if folder->customIconName is not an empty + string. Likewise, set the sorting_priority + + * Evolution-common.idl: New member sortingPriority in struct + Folder. + + * e-storage-set-view.c (folder_sort_callback): Sort according to + the sorting_priorities. + + * e-folder.c: New member sorting_priority in EFolderPrivate. + (init): Init to zero. + (e_folder_set_custom_icon): Emit "changed" if required. + (e_folder_set_sorting_priority): New. + 2002-07-09 Ettore Perazzoli <ettore@ximian.com> * e-icon-factory.c (load_icon): Ooops. Swapped the large/small diff --git a/shell/Evolution-common.idl b/shell/Evolution-common.idl index 0f7da597d0..5cc1cf1b5f 100644 --- a/shell/Evolution-common.idl +++ b/shell/Evolution-common.idl @@ -19,6 +19,7 @@ module Evolution { string customIconName; long unreadCount; boolean canSyncOffline; + short sortingPriority; }; typedef sequence <Folder> FolderList; diff --git a/shell/e-corba-storage-registry.c b/shell/e-corba-storage-registry.c index 3a09e3793b..cfdfce65ae 100644 --- a/shell/e-corba-storage-registry.c +++ b/shell/e-corba-storage-registry.c @@ -398,12 +398,13 @@ impl_StorageRegistry_getFolderByUri (PortableServer_Servant servant, corba_folder->displayName = CORBA_string_dup (e_folder_get_name (folder)); - corba_folder->description = CORBA_string_dup (e_safe_corba_string (e_folder_get_description (folder))); - corba_folder->type = CORBA_string_dup (e_folder_get_type_string (folder)); - corba_folder->physicalUri = CORBA_string_dup (e_safe_corba_string (e_folder_get_physical_uri (folder))); - corba_folder->customIconName = CORBA_string_dup (e_safe_corba_string (e_folder_get_custom_icon_name (folder))); - corba_folder->evolutionUri = corba_evolution_uri; - corba_folder->unreadCount = e_folder_get_unread_count (folder); + corba_folder->description = CORBA_string_dup (e_safe_corba_string (e_folder_get_description (folder))); + corba_folder->type = CORBA_string_dup (e_folder_get_type_string (folder)); + corba_folder->physicalUri = CORBA_string_dup (e_safe_corba_string (e_folder_get_physical_uri (folder))); + corba_folder->customIconName = CORBA_string_dup (e_safe_corba_string (e_folder_get_custom_icon_name (folder))); + corba_folder->evolutionUri = corba_evolution_uri; + corba_folder->unreadCount = e_folder_get_unread_count (folder); + corba_folder->sortingPriority = e_folder_get_sorting_priority (folder); return corba_folder; } diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c index 0dd61461df..0fe5bdc3f4 100644 --- a/shell/e-corba-storage.c +++ b/shell/e-corba-storage.c @@ -102,13 +102,15 @@ impl_StorageListener_notifyFolderCreated (PortableServer_Servant servant, storage_listener_servant = (StorageListenerServant *) servant; storage = storage_listener_servant->storage; - e_folder = e_folder_new (folder->displayName, - folder->type, - folder->description); + e_folder = e_folder_new (folder->displayName, folder->type, folder->description); - e_folder_set_physical_uri (e_folder, folder->physicalUri); - e_folder_set_unread_count (e_folder, folder->unreadCount); + e_folder_set_physical_uri (e_folder, folder->physicalUri); + e_folder_set_unread_count (e_folder, folder->unreadCount); e_folder_set_can_sync_offline (e_folder, folder->canSyncOffline); + e_folder_set_sorting_priority (e_folder, folder->sortingPriority); + + if (folder->customIconName[0] != '\0') + e_folder_set_custom_icon (e_folder, folder->customIconName); if (! e_storage_new_folder (storage, path, e_folder)) { g_warning ("Cannot register folder -- %s %s\n", path, folder->displayName); diff --git a/shell/e-folder.c b/shell/e-folder.c index 6f36e5b487..64083a6d31 100644 --- a/shell/e-folder.c +++ b/shell/e-folder.c @@ -46,6 +46,13 @@ struct _EFolderPrivate { int child_highlight; int unread_count; + /* Folders have a default sorting priority of zero; when deciding the + sort order in the Evolution folder tree, folders with the same + priority value are compared by name, while folders with a higher + priority number always come after the folders with a lower priority + number. */ + int sorting_priority; + unsigned int self_highlight : 1; unsigned int is_stock : 1; unsigned int can_sync_offline : 1; @@ -161,6 +168,7 @@ init (EFolder *folder) priv->physical_uri = NULL; priv->child_highlight = 0; priv->unread_count = 0; + priv->sorting_priority = 0; priv->self_highlight = FALSE; priv->is_stock = FALSE; priv->can_sync_offline = FALSE; @@ -287,7 +295,7 @@ e_folder_get_can_sync_offline (EFolder *folder) * @folder: An EFolder * * Get the name of the custom icon for @folder, or NULL if no custom icon is - * associated with it + * associated with it. **/ const char * e_folder_get_custom_icon_name (EFolder *folder) @@ -297,6 +305,22 @@ e_folder_get_custom_icon_name (EFolder *folder) return folder->priv->custom_icon_name; } +/** + * e_folder_get_sorting_priority: + * @folder: An EFolder + * + * Get the sorting priority for @folder. + * + * Return value: Sorting priority value for @folder. + **/ +int +e_folder_get_sorting_priority (EFolder *folder) +{ + g_return_val_if_fail (E_IS_FOLDER (folder), 0); + + return folder->priv->sorting_priority; +} + void e_folder_set_name (EFolder *folder, @@ -425,16 +449,43 @@ e_folder_set_custom_icon (EFolder *folder, { g_return_if_fail (E_IS_FOLDER (folder)); - if (icon_name != folder->priv->custom_icon_name) { + if (icon_name == folder->priv->custom_icon_name) + return; + + if (folder->priv->custom_icon_name == NULL + || (icon_name != NULL && strcmp (icon_name, folder->priv->custom_icon_name) != 0)) { g_free (folder->priv->custom_icon_name); + folder->priv->custom_icon_name = g_strdup (icon_name); - if (icon_name == NULL) - folder->priv->custom_icon_name = NULL; - else - folder->priv->custom_icon_name = g_strdup (icon_name); + gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); } } +/** + * e_folder_set_sorting_priority: + * @folder: An EFolder + * @sorting_priority: A sorting priority number + * + * Set the sorting priority for @folder. Folders have a default sorting + * priority of zero; when deciding the sort order in the Evolution folder tree, + * folders with the same priority value are compared by name, while folders + * with a higher priority number always come after the folders with a lower + * priority number. + **/ +void +e_folder_set_sorting_priority (EFolder *folder, + int sorting_priority) +{ + g_return_if_fail (E_IS_FOLDER (folder)); + + if (folder->priv->sorting_priority == sorting_priority) + return; + + folder->priv->sorting_priority = sorting_priority; + + gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); +} + /* Gotta love CORBA. */ @@ -455,14 +506,15 @@ e_folder_to_corba (EFolder *folder, g_return_if_fail (E_IS_FOLDER (folder)); g_return_if_fail (folder_return != NULL); - folder_return->type = safe_corba_string_dup (e_folder_get_type_string (folder)); - folder_return->description = safe_corba_string_dup (e_folder_get_description (folder)); - folder_return->displayName = safe_corba_string_dup (e_folder_get_name (folder)); - folder_return->physicalUri = safe_corba_string_dup (e_folder_get_physical_uri (folder)); - folder_return->evolutionUri = safe_corba_string_dup (evolution_uri); - folder_return->customIconName = safe_corba_string_dup (e_folder_get_custom_icon_name (folder)); - folder_return->unreadCount = e_folder_get_unread_count (folder); - folder_return->canSyncOffline = e_folder_get_can_sync_offline (folder); + folder_return->type = safe_corba_string_dup (e_folder_get_type_string (folder)); + folder_return->description = safe_corba_string_dup (e_folder_get_description (folder)); + folder_return->displayName = safe_corba_string_dup (e_folder_get_name (folder)); + folder_return->physicalUri = safe_corba_string_dup (e_folder_get_physical_uri (folder)); + folder_return->evolutionUri = safe_corba_string_dup (evolution_uri); + folder_return->customIconName = safe_corba_string_dup (e_folder_get_custom_icon_name (folder)); + folder_return->unreadCount = e_folder_get_unread_count (folder); + folder_return->canSyncOffline = e_folder_get_can_sync_offline (folder); + folder_return->sortingPriority = e_folder_get_sorting_priority (folder); } diff --git a/shell/e-folder.h b/shell/e-folder.h index b808fb1755..3a7d5ea42f 100644 --- a/shell/e-folder.h +++ b/shell/e-folder.h @@ -81,6 +81,7 @@ gboolean e_folder_get_highlighted (EFolder *folder); gboolean e_folder_get_is_stock (EFolder *folder); gboolean e_folder_get_can_sync_offline (EFolder *folder); const char *e_folder_get_custom_icon_name (EFolder *folder); +int e_folder_get_sorting_priority (EFolder *folder); void e_folder_set_name (EFolder *folder, const char *name); void e_folder_set_type_string (EFolder *folder, const char *type); @@ -91,6 +92,7 @@ void e_folder_set_child_highlight (EFolder *folder, gboolean highlighted); void e_folder_set_is_stock (EFolder *folder, gboolean is_stock); void e_folder_set_can_sync_offline (EFolder *folder, gboolean can_sync_offline); void e_folder_set_custom_icon (EFolder *folder, const char *icon_name); +void e_folder_set_sorting_priority (EFolder *folder, int sorting_priority); void e_folder_to_corba (EFolder *folder, const char *evolution_uri, diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c index 0b2f0c7cdc..393c1aa4da 100644 --- a/shell/e-local-storage.c +++ b/shell/e-local-storage.c @@ -147,7 +147,8 @@ new_folder (ELocalStorage *local_storage, e_folder_get_description (folder), e_folder_get_custom_icon_name (folder), e_folder_get_unread_count (folder), - FALSE); + FALSE, + 0); } static gboolean diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index d6a0bf9cd7..6f2c520654 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -149,30 +149,30 @@ storage_sort_callback (ETreeMemory *etmm, ETreePath node2, void *closure) { - char *folder_path1; - char *folder_path2; - gboolean path1_local; - gboolean path2_local; + char *folder_path_1; + char *folder_path_2; + gboolean path_1_local; + gboolean path_2_local; - folder_path1 = e_tree_memory_node_get_data(etmm, node1); - folder_path2 = e_tree_memory_node_get_data(etmm, node2); + folder_path_1 = e_tree_memory_node_get_data(etmm, node1); + folder_path_2 = e_tree_memory_node_get_data(etmm, node2); /* FIXME bad hack to put the "my evolution" and "local" storages on top. */ - if (strcmp (folder_path1, G_DIR_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) + if (strcmp (folder_path_1, G_DIR_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) return -1; - if (strcmp (folder_path2, G_DIR_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) + if (strcmp (folder_path_2, G_DIR_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) return +1; - path1_local = ! strcmp (folder_path1, G_DIR_SEPARATOR_S E_LOCAL_STORAGE_NAME); - path2_local = ! strcmp (folder_path2, G_DIR_SEPARATOR_S E_LOCAL_STORAGE_NAME); + path_1_local = ! strcmp (folder_path_1, G_DIR_SEPARATOR_S E_LOCAL_STORAGE_NAME); + path_2_local = ! strcmp (folder_path_2, G_DIR_SEPARATOR_S E_LOCAL_STORAGE_NAME); - if (path1_local && path2_local) + if (path_1_local && path_2_local) return 0; - if (path1_local) + if (path_1_local) return -1; - if (path2_local) + if (path_2_local) return 1; return g_utf8_collate (e_tree_model_value_at (E_TREE_MODEL (etmm), node1, 0), @@ -180,10 +180,34 @@ storage_sort_callback (ETreeMemory *etmm, } static int -folder_sort_callback (ETreeMemory *etmm, ETreePath path1, ETreePath path2, gpointer closure) +folder_sort_callback (ETreeMemory *etmm, + ETreePath node1, + ETreePath node2, + void *closure) { - return g_utf8_collate (e_tree_model_value_at (E_TREE_MODEL (etmm), path1, 0), - e_tree_model_value_at (E_TREE_MODEL (etmm), path2, 0)); + EStorageSetViewPrivate *priv; + EFolder *folder_1, *folder_2; + const char *folder_path_1, *folder_path_2; + int priority_1, priority_2; + + priv = E_STORAGE_SET_VIEW (closure)->priv; + + folder_path_1 = e_tree_memory_node_get_data(etmm, node1); + folder_path_2 = e_tree_memory_node_get_data(etmm, node2); + + folder_1 = e_storage_set_get_folder (priv->storage_set, folder_path_1); + folder_2 = e_storage_set_get_folder (priv->storage_set, folder_path_2); + + priority_1 = e_folder_get_sorting_priority (folder_1); + priority_2 = e_folder_get_sorting_priority (folder_2); + + if (priority_1 == priority_2) + return g_utf8_collate (e_tree_model_value_at (E_TREE_MODEL (etmm), node1, 0), + e_tree_model_value_at (E_TREE_MODEL (etmm), node2, 0)); + else if (priority_1 < priority_2) + return -1; + else /* priority_1 > priority_2 */ + return +1; } @@ -1425,7 +1449,8 @@ new_storage_cb (EStorageSet *storage_set, path = g_strconcat (G_DIR_SEPARATOR_S, e_storage_get_name (storage), NULL); node = e_tree_memory_node_insert (E_TREE_MEMORY(priv->etree_model), priv->root_node, -1, path); - e_tree_memory_sort_node (E_TREE_MEMORY(priv->etree_model), priv->root_node, storage_sort_callback, storage_set_view); + e_tree_memory_sort_node (E_TREE_MEMORY(priv->etree_model), priv->root_node, + storage_sort_callback, storage_set_view); if (! add_node_to_hash (storage_set_view, path, node)) { e_tree_memory_node_remove (E_TREE_MEMORY(priv->etree_model), node); diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index 3100991384..f7fb368399 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -113,6 +113,7 @@ impl_FolderSelectionListener_selected (PortableServer_Servant servant, ret_folder->customIconName = CORBA_string_dup (folder->customIconName); ret_folder->evolutionUri = CORBA_string_dup (folder->evolutionUri); ret_folder->unreadCount = folder->unreadCount; + ret_folder->sortingPriority = folder->sortingPriority; * (listener_servant->folder_return) = ret_folder; } diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c index bb1d37cd9e..88ca1e72da 100644 --- a/shell/evolution-storage.c +++ b/shell/evolution-storage.c @@ -967,7 +967,8 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage, const char *description, const char *custom_icon_name, int unread_count, - gboolean can_sync_offline) + gboolean can_sync_offline, + int sorting_priority) { EvolutionStorageResult result; EvolutionStoragePrivate *priv; @@ -994,11 +995,12 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage, CORBA_exception_init (&ev); corba_folder = GNOME_Evolution_Folder__alloc (); - corba_folder->displayName = CORBA_string_dup (display_name); - corba_folder->description = CORBA_string_dup (description); - corba_folder->type = CORBA_string_dup (type); - corba_folder->physicalUri = CORBA_string_dup (physical_uri); - corba_folder->canSyncOffline = (CORBA_boolean) can_sync_offline; + corba_folder->displayName = CORBA_string_dup (display_name); + corba_folder->description = CORBA_string_dup (description); + corba_folder->type = CORBA_string_dup (type); + corba_folder->physicalUri = CORBA_string_dup (physical_uri); + corba_folder->canSyncOffline = (CORBA_boolean) can_sync_offline; + corba_folder->sortingPriority = sorting_priority; if (custom_icon_name != NULL) corba_folder->customIconName = CORBA_string_dup (custom_icon_name); diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h index be228c79e0..9cd5eabfbd 100644 --- a/shell/evolution-storage.h +++ b/shell/evolution-storage.h @@ -140,7 +140,8 @@ EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage const char *description, const char *custom_icon_name, int unread_count, - gboolean can_sync_offline); + gboolean can_sync_offline, + int sorting_priority); EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage, const char *path, int unread_count); diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c index daeea054b3..9464b44b92 100644 --- a/shell/evolution-test-component.c +++ b/shell/evolution-test-component.c @@ -326,10 +326,15 @@ setup_custom_storage (EvolutionShellClient *shell_client) return; } + /* Test the sorting_priority arg here: if it was just sorting in + alphabetical order, FirstFolder would come before SecondFolder, but + we are specifying -1 sorting priority for SecondFolder and zero for + FirstFolder so the order is reversed. */ + evolution_storage_new_folder (the_storage, "/FirstFolder", "FirstFolder", - "mail", "file:///tmp/blah", "", NULL, 0, TRUE); + "mail", "file:///tmp/blah", "", "inbox", 0, TRUE, 0); evolution_storage_new_folder (the_storage, "/SecondFolder", "SecondFolder", - "calendar", "file:///tmp/bleh", "", NULL, 0, FALSE); + "calendar", "file:///tmp/bleh", "", NULL, 0, FALSE, -1); } |