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
This commit is contained in:
Ettore Perazzoli
2002-07-10 15:26:31 +00:00
parent a3a24835e8
commit 090af2cb0e
17 changed files with 201 additions and 57 deletions

View File

@ -1,3 +1,9 @@
2002-07-10 Ettore Perazzoli <ettore@ximian.com>
* gui/component/addressbook-storage.c (load_source_data): Pass
zero as the @sorting_priority to evolution_storage_new_folder().
(addressbook_storage_add_source): Likewise.
2002-07-10 Chris Toshok <toshok@ximian.com>
* backend/idl/addressbook.idl: add Book.getCompletionView.

View File

@ -460,7 +460,7 @@ load_source_data (const char *file_path)
path = g_strdup_printf ("/%s", source->name);
evolution_storage_new_folder (storage, path, source->name,
"ldap-contacts", source->uri,
source->description, NULL, 0, FALSE);
source->description, NULL, 0, FALSE, 0);
sources = g_list_append (sources, source);
@ -579,7 +579,7 @@ addressbook_storage_add_source (AddressbookSource *source)
addressbook_get_other_contact_storage();
path = g_strdup_printf ("/%s", source->name);
evolution_storage_new_folder (storage, path, source->name, "ldap-contacts",
source->uri, source->description, NULL, 0, FALSE);
source->uri, source->description, NULL, 0, FALSE, 0);
g_free (path);
}

View File

@ -1,3 +1,11 @@
2002-07-10 Ettore Perazzoli <ettore@ximian.com>
* 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().
2002-07-09 Ettore Perazzoli <ettore@ximian.com>
* subscribe-dialog.c (recursive_add_folder): Pass NULL for

View File

@ -193,7 +193,7 @@ real_flush_updates(void *o, void *event_data, void *data)
evolution_storage_new_folder(storage,
up->path, up->name, type, up->uri, up->name, NULL,
up->unread,
TRUE);
TRUE, 0);
}
if (!up->olduri && up->add)

View File

@ -185,7 +185,7 @@ recursive_add_folder (EvolutionStorage *storage, const char *path, const char *n
g_free (parent);
}
evolution_storage_new_folder (storage, path, name, "mail", url, name, NULL, FALSE, TRUE);
evolution_storage_new_folder (storage, path, name, "mail", url, name, NULL, FALSE, TRUE, 0);
}
/* ** Get one level of folderinfo ****************************************** */

View File

@ -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

View File

@ -19,6 +19,7 @@ module Evolution {
string customIconName;
long unreadCount;
boolean canSyncOffline;
short sortingPriority;
};
typedef sequence <Folder> FolderList;

View File

@ -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;
}

View File

@ -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);

View File

@ -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) {
g_free (folder->priv->custom_icon_name);
if (icon_name == folder->priv->custom_icon_name)
return;
if (icon_name == NULL)
folder->priv->custom_icon_name = NULL;
else
folder->priv->custom_icon_name = g_strdup (icon_name);
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);
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);
}

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}