aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/e-account-utils.c42
-rw-r--r--e-util/e-account-utils.h1
-rw-r--r--mail/e-mail-browser.c4
-rw-r--r--mail/e-mail-reader.c56
-rw-r--r--mail/e-mail-reader.h8
-rw-r--r--modules/mail/e-mail-shell-view.c12
-rw-r--r--plugins/mail-to-task/mail-to-task.c8
-rw-r--r--plugins/mailing-list-actions/mailing-list-actions.c3
8 files changed, 94 insertions, 40 deletions
diff --git a/e-util/e-account-utils.c b/e-util/e-account-utils.c
index 4395542f7c..66242408ac 100644
--- a/e-util/e-account-utils.c
+++ b/e-util/e-account-utils.c
@@ -137,3 +137,45 @@ e_get_account_by_uid (const gchar *uid)
/* XXX EAccountList misuses const. */
return (EAccount *) account;
}
+
+/**
+ * e_get_any_enabled_account:
+ *
+ * Returns the default mail account if it's enabled, otherwise the first
+ * enabled mail account in the global #EAccountList, or finally %NULL if
+ * all mail accounts are disabled or none exist.
+ *
+ * Returns: an enabled #EAccount, or %NULL if there are none
+ **/
+EAccount *
+e_get_any_enabled_account (void)
+{
+ EAccount *account;
+ EAccountList *account_list;
+ EIterator *iter;
+
+ account = e_get_default_account ();
+ if (account != NULL && account->enabled)
+ return account;
+
+ account = NULL;
+
+ account_list = e_get_account_list ();
+ iter = e_list_get_iterator (E_LIST (account_list));
+
+ while (e_iterator_is_valid (iter) && account == NULL) {
+ EAccount *candidate;
+
+ /* XXX EIterator misuses const. */
+ candidate = (EAccount *) e_iterator_get (iter);
+
+ if (candidate->enabled)
+ account = candidate;
+ else
+ e_iterator_next (iter);
+ }
+
+ g_object_unref (iter);
+
+ return account;
+}
diff --git a/e-util/e-account-utils.h b/e-util/e-account-utils.h
index f2ae8fc5dc..f8c5c968a4 100644
--- a/e-util/e-account-utils.h
+++ b/e-util/e-account-utils.h
@@ -29,6 +29,7 @@ EAccount * e_get_default_account (void);
void e_set_default_account (EAccount *account);
EAccount * e_get_account_by_name (const gchar *name);
EAccount * e_get_account_by_uid (const gchar *uid);
+EAccount * e_get_any_enabled_account (void);
G_END_DECLS
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 062623124d..86cc929182 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -295,6 +295,7 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
{
EMailReader *reader;
GtkMenu *menu;
+ guint32 state;
if (uri != NULL)
return FALSE;
@@ -302,7 +303,8 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
reader = E_MAIL_READER (browser);
menu = e_mail_reader_get_popup_menu (reader);
- e_mail_reader_update_actions (reader);
+ state = e_mail_reader_check_state (reader);
+ e_mail_reader_update_actions (reader, state);
if (event == NULL)
gtk_menu_popup (
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 795dfcd40f..e0a9fdb299 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -28,6 +28,7 @@
#include <X11/XF86keysym.h>
#endif
+#include "e-util/e-account-utils.h"
#include "e-util/e-binding.h"
#include "e-util/e-charset.h"
#include "e-util/e-util.h"
@@ -2112,7 +2113,8 @@ mail_reader_set_message (EMailReader *reader,
}
static void
-mail_reader_update_actions (EMailReader *reader)
+mail_reader_update_actions (EMailReader *reader,
+ guint32 state)
{
EShell *shell;
EShellBackend *shell_backend;
@@ -2120,7 +2122,6 @@ mail_reader_update_actions (EMailReader *reader)
GtkAction *action;
const gchar *action_name;
gboolean sensitive;
- guint32 state;
/* Be descriptive. */
gboolean any_messages_selected;
@@ -2128,7 +2129,7 @@ mail_reader_update_actions (EMailReader *reader)
gboolean enable_flag_clear;
gboolean enable_flag_completed;
gboolean enable_flag_for_followup;
- gboolean have_an_account;
+ gboolean have_enabled_account;
gboolean multiple_messages_selected;
gboolean selection_has_deleted_messages;
gboolean selection_has_important_messages;
@@ -2141,8 +2142,6 @@ mail_reader_update_actions (EMailReader *reader)
gboolean selection_is_mailing_list;
gboolean single_message_selected;
- state = e_mail_reader_check_state (reader);
-
shell_backend = e_mail_reader_get_shell_backend (reader);
shell = e_shell_backend_get_shell (shell_backend);
shell_settings = e_shell_get_shell_settings (shell);
@@ -2154,8 +2153,8 @@ mail_reader_update_actions (EMailReader *reader)
disable_printing = FALSE;
#endif
- have_an_account =
- (state & E_MAIL_READER_HAVE_ACCOUNT);
+ have_enabled_account =
+ (state & E_MAIL_READER_HAVE_ENABLED_ACCOUNT);
single_message_selected =
(state & E_MAIL_READER_SELECTION_SINGLE);
multiple_messages_selected =
@@ -2240,42 +2239,42 @@ mail_reader_update_actions (EMailReader *reader)
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward";
- sensitive = have_an_account && any_messages_selected;
+ sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-attached";
- sensitive = have_an_account && any_messages_selected;
+ sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-attached-full";
- sensitive = have_an_account && any_messages_selected;
+ sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-as-menu";
- sensitive = have_an_account && any_messages_selected;
+ sensitive = have_enabled_account && any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-inline";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-inline-full";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-quoted";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-forward-quoted-full";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
@@ -2327,12 +2326,12 @@ mail_reader_update_actions (EMailReader *reader)
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-message-edit";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-message-new";
- sensitive = have_an_account;
+ sensitive = have_enabled_account;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
@@ -2392,23 +2391,23 @@ mail_reader_update_actions (EMailReader *reader)
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-redirect";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-all";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-list";
- sensitive = have_an_account && single_message_selected &&
+ sensitive = have_enabled_account && single_message_selected &&
selection_is_mailing_list;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-reply-sender";
- sensitive = have_an_account && single_message_selected;
+ sensitive = have_enabled_account && single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
@@ -2524,8 +2523,9 @@ mail_reader_class_init (EMailReaderIface *iface)
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EMailReaderIface, update_actions),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1,
+ G_TYPE_UINT);
}
GType
@@ -2752,6 +2752,7 @@ e_mail_reader_check_state (EMailReader *reader)
gboolean has_undeleted = FALSE;
gboolean has_unimportant = FALSE;
gboolean has_unread = FALSE;
+ gboolean have_enabled_account = FALSE;
gboolean drafts_or_outbox;
gboolean store_supports_vjunk = FALSE;
gboolean is_mailing_list;
@@ -2854,8 +2855,8 @@ e_mail_reader_check_state (EMailReader *reader)
camel_folder_free_message_info (folder, info);
}
- if (em_utils_check_user_can_send_mail ())
- state |= E_MAIL_READER_HAVE_ACCOUNT;
+ if (e_get_any_enabled_account () != NULL)
+ state |= E_MAIL_READER_HAVE_ENABLED_ACCOUNT;
if (uids->len == 1)
state |= E_MAIL_READER_SELECTION_SINGLE;
if (uids->len > 1)
@@ -2896,11 +2897,12 @@ e_mail_reader_check_state (EMailReader *reader)
}
void
-e_mail_reader_update_actions (EMailReader *reader)
+e_mail_reader_update_actions (EMailReader *reader,
+ guint32 state)
{
g_return_if_fail (E_IS_MAIL_READER (reader));
- g_signal_emit (reader, signals[UPDATE_ACTIONS], 0);
+ g_signal_emit (reader, signals[UPDATE_ACTIONS], 0, state);
}
GtkAction *
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 53fcd09a26..f85aeec65f 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -60,7 +60,7 @@ typedef struct _EMailReader EMailReader;
typedef struct _EMailReaderIface EMailReaderIface;
enum {
- E_MAIL_READER_HAVE_ACCOUNT = 1 << 0,
+ E_MAIL_READER_HAVE_ENABLED_ACCOUNT = 1 << 0,
E_MAIL_READER_SELECTION_SINGLE = 1 << 1,
E_MAIL_READER_SELECTION_MULTIPLE = 1 << 2,
E_MAIL_READER_SELECTION_CAN_ADD_SENDER = 1 << 3,
@@ -102,14 +102,16 @@ struct _EMailReaderIface {
/* Signals */
void (*show_search_bar) (EMailReader *reader);
- void (*update_actions) (EMailReader *reader);
+ void (*update_actions) (EMailReader *reader,
+ guint32 state);
};
GType e_mail_reader_get_type (void);
void e_mail_reader_init (EMailReader *reader);
void e_mail_reader_changed (EMailReader *reader);
guint32 e_mail_reader_check_state (EMailReader *reader);
-void e_mail_reader_update_actions (EMailReader *reader);
+void e_mail_reader_update_actions (EMailReader *reader,
+ guint32 state);
GtkAction * e_mail_reader_get_action (EMailReader *reader,
const gchar *action_name);
GtkActionGroup *
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 3bee268afb..f3b70433bf 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -785,6 +785,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
gboolean folder_is_trash;
gboolean folder_has_unread_rec = FALSE;
gboolean folder_tree_and_message_list_agree = TRUE;
+ gboolean have_enabled_account;
/* Chain up to parent's update_actions() method. */
E_SHELL_VIEW_CLASS (parent_class)->update_actions (shell_view);
@@ -795,7 +796,11 @@ mail_shell_view_update_actions (EShellView *shell_view)
mail_shell_content = mail_shell_view->priv->mail_shell_content;
reader = E_MAIL_READER (mail_shell_content);
- e_mail_reader_update_actions (reader);
+ state = e_mail_reader_check_state (reader);
+ e_mail_reader_update_actions (reader, state);
+
+ have_enabled_account =
+ (state & E_MAIL_READER_HAVE_ENABLED_ACCOUNT);
mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
@@ -857,6 +862,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
g_free (uri);
}
+
action = ACTION (MAIL_ACCOUNT_DISABLE);
sensitive = (account != NULL) && folder_is_store;
if (account_is_groupwise)
@@ -920,6 +926,10 @@ mail_shell_view_update_actions (EShellView *shell_view)
sensitive = folder_has_unread_rec && !folder_is_store;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (MAIL_TOOLS_SUBSCRIPTIONS);
+ sensitive = have_enabled_account;
+ gtk_action_set_sensitive (action, sensitive);
+
e_mail_shell_view_update_popup_labels (mail_shell_view);
}
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 504dca64a0..b62b10f3db 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -1100,12 +1100,10 @@ static GtkActionEntry single_selection_entries[] = {
static void
update_actions_any_cb (EMailReader *reader,
+ guint32 state,
GtkActionGroup *action_group)
{
gboolean sensitive;
- guint32 state;
-
- state = e_mail_reader_check_state (reader);
sensitive =
(state & E_MAIL_READER_SELECTION_SINGLE) ||
@@ -1116,12 +1114,10 @@ update_actions_any_cb (EMailReader *reader,
static void
update_actions_one_cb (EMailReader *reader,
+ guint32 state,
GtkActionGroup *action_group)
{
gboolean sensitive;
- guint32 state;
-
- state = e_mail_reader_check_state (reader);
sensitive = (state & E_MAIL_READER_SELECTION_SINGLE);
diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c
index 33101db8cd..ce60275db7 100644
--- a/plugins/mailing-list-actions/mailing-list-actions.c
+++ b/plugins/mailing-list-actions/mailing-list-actions.c
@@ -335,12 +335,11 @@ static GtkActionEntry mailing_list_entries[] = {
static void
update_actions_cb (EMailReader *reader,
+ guint32 state,
GtkActionGroup *action_group)
{
gboolean sensitive;
- guint32 state;
- state = e_mail_reader_check_state (reader);
sensitive = (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST);
gtk_action_group_set_sensitive (action_group, sensitive);
}