aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-28 04:18:01 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-28 04:18:01 +0800
commit9b4c2438652f02d045c58ec2f41b0592a6d26219 (patch)
tree0561364fe46b1798bc956e36b9839852093899a5 /modules
parentd8b3127abda28009b5c9e97b0e5df9699316f968 (diff)
downloadgsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar.gz
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar.bz2
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar.lz
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar.xz
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.tar.zst
gsoc2013-evolution-9b4c2438652f02d045c58ec2f41b0592a6d26219.zip
Bug #550049 - Disable Mark messages as read actions when unusable
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/e-mail-shell-view-actions.h4
-rw-r--r--modules/mail/e-mail-shell-view.c68
2 files changed, 70 insertions, 2 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.h b/modules/mail/e-mail-shell-view-actions.h
index 99819f000e..6ae2e24a95 100644
--- a/modules/mail/e-mail-shell-view-actions.h
+++ b/modules/mail/e-mail-shell-view-actions.h
@@ -71,8 +71,8 @@
E_SHELL_WINDOW_ACTION ((window), "mail-folder-delete")
#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_EXPUNGE(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-folder-expunge")
-#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_MARK_ALL_READ(window) \
- E_SHELL_WINDOW_ACTION ((window), "mail-folder-mark-all-read")
+#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_MARK_ALL_AS_READ(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-folder-mark-all-as-read")
#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_MOVE(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-folder-move")
#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_NEW(window) \
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 3c82e516bc..d331c080ed 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -348,6 +348,54 @@ filter:
}
static void
+has_unread_mail (GtkTreeModel *model, GtkTreeIter *parent, gboolean is_root, gboolean *has_unread)
+{
+ guint unread = 0;
+ GtkTreeIter iter, child;
+
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (parent != NULL);
+ g_return_if_fail (has_unread != NULL);
+
+ if (is_root) {
+ gboolean is_store = FALSE, is_draft = FALSE;
+
+ gtk_tree_model_get (model, parent,
+ COL_UINT_UNREAD, &unread,
+ COL_BOOL_IS_STORE, &is_store,
+ COL_BOOL_IS_DRAFT, &is_draft,
+ -1);
+
+ if (is_draft || is_store) {
+ *has_unread = FALSE;
+ return;
+ }
+
+ *has_unread = *has_unread || (unread > 0 && unread != ~((guint)0));
+
+ if (*has_unread)
+ return;
+
+ if (!gtk_tree_model_iter_children (model, &iter, parent))
+ return;
+ } else {
+ iter = *parent;
+ }
+
+ do {
+ gtk_tree_model_get (model, &iter, COL_UINT_UNREAD, &unread, -1);
+
+ *has_unread = *has_unread || (unread > 0 && unread != ~((guint)0));
+ if (*has_unread)
+ break;
+
+ if (gtk_tree_model_iter_children (model, &child, &iter))
+ has_unread_mail (model, &child, FALSE, has_unread);
+
+ } while (gtk_tree_model_iter_next (model, &iter) && !*has_unread);
+}
+
+static void
mail_shell_view_update_actions (EShellView *shell_view)
{
EMailShellView *mail_shell_view;
@@ -371,6 +419,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
gboolean folder_is_outbox;
gboolean folder_is_store;
gboolean folder_is_trash;
+ gboolean folder_has_unread_rec = FALSE;
mail_shell_view = E_MAIL_SHELL_VIEW (shell_view);
@@ -400,6 +449,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
uri = em_folder_tree_get_selected_uri (folder_tree);
if (uri != NULL) {
+ EMFolderTreeModel *model;
+
account = mail_config_get_account_by_source_url (uri);
/* FIXME This belongs in a GroupWise plugin. */
@@ -407,6 +458,19 @@ mail_shell_view_update_actions (EShellView *shell_view)
(g_strrstr (uri, "groupwise://") != NULL) &&
account != NULL && account->parent_uid != NULL;
+ model = em_folder_tree_model_get_default ();
+ if (model) {
+ GtkTreeRowReference *reference = em_folder_tree_model_lookup_uri (model, uri);
+ if (reference != NULL) {
+ GtkTreePath *path = gtk_tree_row_reference_get_path (reference);
+ GtkTreeIter iter;
+
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ has_unread_mail (GTK_TREE_MODEL (model), &iter, TRUE, &folder_has_unread_rec);
+ gtk_tree_path_free (path);
+ }
+ }
+
g_free (uri);
}
@@ -459,6 +523,10 @@ mail_shell_view_update_actions (EShellView *shell_view)
sensitive = !folder_is_store && folder_can_be_deleted;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (MAIL_FOLDER_MARK_ALL_AS_READ);
+ sensitive = folder_has_unread_rec && !folder_is_store;
+ gtk_action_set_sensitive (action, sensitive);
+
e_mail_shell_view_update_popup_labels (mail_shell_view);
}