aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/mail-folder-cache.c33
-rw-r--r--mail/mail-folder-cache.h5
-rw-r--r--mail/mail.error.xml7
-rw-r--r--modules/mail/e-mail-shell-view-actions.c6
-rw-r--r--plugins/mark-all-read/mark-all-read.c10
5 files changed, 58 insertions, 3 deletions
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
@@ -392,6 +392,13 @@ You can choose to ignore this folder, overwrite or append its contents, or quit.
<error id="ask-mark-all-read" type="question" default="GTK_RESPONSE_NO">
<_primary>Do you want to mark all messages as read?</_primary>
+ <_secondary xml:space="preserve">This will mark all messages as read in the selected folder.</_secondary>
+ <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+ <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+ </error>
+
+ <error id="ask-mark-all-read-sub" type="question" default="GTK_RESPONSE_NO">
+ <_primary>Do you want to mark all messages as read?</_primary>
<_secondary xml:space="preserve">This will mark all messages as read in the selected folder and its subfolders.</_secondary>
<button stock="gtk-no" response="GTK_RESPONSE_NO"/>
<button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 15694111ab..9bac5dfb4a 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -19,6 +19,7 @@
*
*/
+#include "mail/mail-folder-cache.h"
#include "e-mail-shell-view-private.h"
static void
@@ -232,7 +233,10 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action,
g_return_if_fail (folder != NULL);
key = "/apps/evolution/mail/prompts/mark_all_read";
- prompt = "mail:ask-mark-all-read";
+ if (mail_folder_cache_get_folder_has_children (mail_folder_cache_get_default (), folder, NULL))
+ prompt = "mail:ask-mark-all-read-sub";
+ else
+ prompt = "mail:ask-mark-all-read";
if (!em_utils_prompt_user (parent, key, prompt, NULL))
return;
diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c
index 6f968ba0c6..f22b2276f0 100644
--- a/plugins/mark-all-read/mark-all-read.c
+++ b/plugins/mark-all-read/mark-all-read.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <e-util/e-plugin-ui.h>
#include <mail/em-folder-tree.h>
+#include <mail/em-utils.h>
#include <mail/mail-ops.h>
#include <mail/mail-mt.h>
@@ -77,7 +78,7 @@ box_mapped_cb (GtkWidget *box,
}
static gint
-prompt_user (void)
+prompt_user (gboolean has_subfolders)
{
GtkWidget *container;
GtkWidget *dialog;
@@ -89,6 +90,11 @@ prompt_user (void)
gchar *markup;
gint response;
+ if (!has_subfolders) {
+ return em_utils_prompt_user (e_shell_get_active_window (e_shell_get_default ()), NULL, "mail:ask-mark-all-read", NULL) ?
+ GTK_RESPONSE_NO : GTK_RESPONSE_CANCEL;
+ }
+
dialog = gtk_dialog_new ();
widget = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
gtk_widget_hide (widget);
@@ -371,7 +377,7 @@ mar_got_folder (gchar *folder_uri,
goto exit;
if (scan_folder_tree_for_unread (folder_uri) > 1)
- response = prompt_user ();
+ response = prompt_user (folder_info->child != NULL);
else
response = GTK_RESPONSE_NO;