From a5d79e9f915dc49ef0259ce7681c1f552c335a4c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 21 May 2010 16:30:40 +0200 Subject: Bug #546551 - Dialog for mark-all-read always mentions subfolders --- mail/mail-folder-cache.c | 33 +++++++++++++++++++++++++++++++++ mail/mail-folder-cache.h | 5 +++++ mail/mail.error.xml | 7 +++++++ 3 files changed, 45 insertions(+) (limited to 'mail') diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 5d52a1431d..a9726ea0db 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -97,6 +97,7 @@ struct _folder_info { gchar *uri; /* uri of folder */ guint32 flags; + gboolean has_children; gpointer folder; /* if known (weak pointer) */ }; @@ -429,6 +430,7 @@ setup_folder(MailFolderCache *self, CamelFolderInfo *fi, struct _store_info *si) mfi->uri = g_strdup(fi->uri); mfi->store_info = si; mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -577,6 +579,7 @@ rename_folders(MailFolderCache *self, struct _store_info *si, const gchar *oldba mfi->full_name = g_strdup(fi->full_name); mfi->uri = g_strdup(fi->uri); mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -588,6 +591,7 @@ rename_folders(MailFolderCache *self, struct _store_info *si, const gchar *oldba mfi->uri = g_strdup(fi->uri); mfi->store_info = si; mfi->flags = fi->flags; + mfi->has_children = fi->child != NULL; g_hash_table_insert(si->folders, mfi->full_name, mfi); g_hash_table_insert(si->folders_uri, mfi->uri, mfi); @@ -1301,3 +1305,32 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self, return fi.fi != NULL; } +/* Returns whether folder 'folder' has children based on folder_info->child property. + If not found returns FALSE and sets 'found' to FALSE, if not NULL. */ +gboolean +mail_folder_cache_get_folder_has_children (MailFolderCache *self, CamelFolder *folder, gboolean *found) +{ + gchar *uri = mail_tools_folder_to_url (folder); + struct _find_info fi = { uri, NULL, NULL }; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (folder != NULL, FALSE); + + if (self->priv->stores == NULL) + return FALSE; + + fi.url = camel_url_new (uri, NULL); + + g_mutex_lock (self->priv->stores_mutex); + g_hash_table_foreach ( + self->priv->stores, (GHFunc) + storeinfo_find_folder_info, &fi); + if (found) + *found = fi.fi != NULL; + g_mutex_unlock (self->priv->stores_mutex); + + camel_url_free (fi.url); + g_free (uri); + + return fi.fi != NULL && fi.fi->has_children; +} diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h index 1a3cf2ad5a..d2c09d834a 100644 --- a/mail/mail-folder-cache.h +++ b/mail/mail-folder-cache.h @@ -98,6 +98,11 @@ gboolean mail_folder_cache_get_folder_info_flags CamelFolder *folder, gint *flags); +gboolean mail_folder_cache_get_folder_has_children + (MailFolderCache *self, + CamelFolder *folder, + gboolean *found); + G_END_DECLS #endif /* MAIL_FOLDER_CACHE_H */ diff --git a/mail/mail.error.xml b/mail/mail.error.xml index ed6fa3a364..e2ffd243aa 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -391,6 +391,13 @@ You can choose to ignore this folder, overwrite or append its contents, or quit. + <_primary>Do you want to mark all messages as read? + <_secondary xml:space="preserve">This will mark all messages as read in the selected folder. +