diff options
Diffstat (limited to 'mail/e-mail-shell-content.c')
-rw-r--r-- | mail/e-mail-shell-content.c | 118 |
1 files changed, 116 insertions, 2 deletions
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c index 025b49c18a..f6b07ea728 100644 --- a/mail/e-mail-shell-content.c +++ b/mail/e-mail-shell-content.c @@ -22,6 +22,7 @@ #include "e-mail-shell-content.h" #include <glib/gi18n.h> +#include <camel/camel-store.h> #include <libedataserver/e-data-server-util.h> #include "e-util/gconf-bridge.h" @@ -197,6 +198,7 @@ mail_shell_content_constructed (GObject *object) /* XXX Kill EMFolderView? */ priv->folder_view = em_folder_view_new (); + g_object_ref_sink (priv->folder_view); widget = GTK_WIDGET (((EMFolderView *) priv->folder_view)->list); gtk_paned_add1 (GTK_PANED (container), widget); gtk_widget_show (widget); @@ -236,11 +238,123 @@ static guint32 mail_shell_content_check_state (EShellContent *shell_content) { EMailShellContent *mail_shell_content; + EMFolderView *folder_view; + GPtrArray *uids; + CamelFolder *folder; + CamelStore *store; + const gchar *folder_uri; + const gchar *tag; + gboolean can_clear_flags = FALSE; + gboolean can_flag_completed = FALSE; + gboolean can_flag_for_followup = FALSE; + gboolean has_deleted = FALSE; + gboolean has_important = FALSE; + gboolean has_junk = FALSE; + gboolean has_not_junk = FALSE; + gboolean has_read = FALSE; + gboolean has_undeleted = FALSE; + gboolean has_unimportant = FALSE; + gboolean has_unread = FALSE; + gboolean draft_or_outbox; guint32 state = 0; - - /* FIXME */ + guint ii; mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content); + folder_view = e_mail_shell_content_get_folder_view (mail_shell_content); + uids = message_list_get_selected (folder_view->list); + folder_uri = folder_view->folder_uri; + folder = folder_view->folder; + store = CAMEL_STORE (folder->parent_store); + + draft_or_outbox = + em_utils_folder_is_drafts (folder, folder_uri) || + em_utils_folder_is_outbox (folder, folder_uri); + if (!draft_or_outbox) { + has_junk = !(store->flags & CAMEL_STORE_VJUNK); + has_not_junk = TRUE; + } + + for (ii = 0; ii < uids->len; ii++) { + CamelMessageInfo *info; + guint32 flags; + + info = camel_folder_get_message_info ( + folder, uids->pdata[ii]); + if (info == NULL) + continue; + + flags = camel_message_info_flags (info); + + if (flags & CAMEL_MESSAGE_SEEN) + has_read = TRUE; + else + has_unread = TRUE; + + if (flags & CAMEL_MESSAGE_DELETED) + has_deleted = TRUE; + else + has_undeleted = TRUE; + + if (flags & CAMEL_MESSAGE_FLAGGED) + has_important = TRUE; + else + has_unimportant = TRUE; + + tag = camel_message_info_user_tag (info, "follow-up"); + if (tag != NULL && *tag != '\0') { + can_clear_flags = TRUE; + tag = camel_message_info_user_tag ( + info, "completed-on"); + if (tag != NULL && *tag != '\0') + can_flag_completed = TRUE; + } else + can_flag_for_followup = TRUE; + } + + if (uids->len == 1) + state |= E_MAIL_SHELL_CONTENT_SELECTION_SINGLE; + if (uids->len > 1) + state |= E_MAIL_SHELL_CONTENT_SELECTION_MULTIPLE; + if (!draft_or_outbox && uids->len == 1) + state |= E_MAIL_SHELL_CONTENT_SELECTION_CAN_ADD_SENDER; +#if 0 /* FIXME */ + if (can_edit) + state |= E_MAIL_SHELL_CONTENT_SELECTION_CAN_EDIT; +#endif + if (can_clear_flags) + state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_CLEAR; + if (can_flag_completed) + state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_COMPLETED; + if (can_flag_for_followup) + state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_FOLLOWUP; + if (has_deleted) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_DELETED; + if (has_important) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_IMPORTANT; + if (has_junk) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_JUNK; + if (has_not_junk) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_NOT_JUNK; + if (has_read) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_READ; + if (has_undeleted) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNDELETED; + if (has_unimportant) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNIMPORTANT; + if (has_unread) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNREAD; +#if 0 /* FIXME */ + if (has_callto_uri) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_CALLTO; + if (has_http_uri) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_HTTP; + if (has_mailto_uri) + state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_MAILTO; + if (is_mailing_list) + state |= E_MAIL_SHELL_CONTENT_SELECTION_IS_MAILING_LIST; +#endif + + em_utils_uids_free (uids); return state; } |