diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-09-05 23:35:02 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-09-05 23:35:02 +0800 |
commit | 016805f54d602763358da78f45b4779bd85763b1 (patch) | |
tree | 87c21aa8b82ccee9dff6732de22b30b39c4810f5 /mail | |
parent | 7ec8fed125463d5eda4bcf306378d0cf528d0ca8 (diff) | |
download | gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar.gz gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar.bz2 gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar.lz gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar.xz gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.tar.zst gsoc2013-evolution-016805f54d602763358da78f45b4779bd85763b1.zip |
Get the mailing-list-actions plugin working.
Also get mail-to-task working for the message browser window.
Came up with a new technique for managing actions and action groups in
the process. Also gave the EMailReader interface an "update-actions"
signal for plugins to connect to.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 6 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 533 | ||||
-rw-r--r-- | mail/e-mail-reader.h | 1 |
3 files changed, 282 insertions, 258 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index fb79932653..ea860c016f 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -26,6 +26,7 @@ #include <camel/camel-folder.h> #include "e-util/e-util.h" +#include "e-util/e-plugin-ui.h" #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" @@ -372,6 +373,7 @@ mail_browser_constructed (GObject *object) GtkHTML *html; const gchar *domain; const gchar *key; + const gchar *id; guint merge_id; priv = E_MAIL_BROWSER_GET_PRIVATE (object); @@ -479,6 +481,10 @@ mail_browser_constructed (GObject *object) object = G_OBJECT (reader); key = "/apps/evolution/mail/display/show_deleted"; gconf_bridge_bind_property (bridge, key, object, "show-deleted"); + + id = "org.gnome.evolution.mail.browser"; + e_plugin_ui_register_manager (ui_manager, id, object); + e_plugin_ui_enable_manager (ui_manager, id); } static gboolean diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 96ed8cf379..72f79181f8 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -54,6 +54,7 @@ enum { CHANGED, FOLDER_LOADED, SHOW_SEARCH_BAR, + UPDATE_ACTIONS, LAST_SIGNAL }; @@ -1883,6 +1884,269 @@ mail_reader_set_message (EMailReader *reader, } static void +mail_reader_update_actions (EMailReader *reader) +{ + EShell *shell; + EShellBackend *shell_backend; + EShellSettings *shell_settings; + GtkAction *action; + GtkActionGroup *action_group; + const gchar *action_name; + gboolean sensitive; + guint32 state; + + /* Be descriptive. */ + gboolean any_messages_selected; + gboolean disable_printing; + gboolean enable_flag_clear; + gboolean enable_flag_completed; + gboolean enable_flag_for_followup; + gboolean have_an_account; + gboolean multiple_messages_selected; + gboolean selection_has_deleted_messages; + gboolean selection_has_important_messages; + gboolean selection_has_junk_messages; + gboolean selection_has_not_junk_messages; + gboolean selection_has_read_messages; + gboolean selection_has_undeleted_messages; + gboolean selection_has_unimportant_messages; + gboolean selection_has_unread_messages; + gboolean selection_is_mailing_list; + gboolean single_message_selected; + + action_group = e_mail_reader_get_action_group (reader); + 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); + + disable_printing = e_shell_settings_get_boolean ( + shell_settings, "disable-printing"); + + have_an_account = + (state & E_MAIL_READER_HAVE_ACCOUNT); + single_message_selected = + (state & E_MAIL_READER_SELECTION_SINGLE); + multiple_messages_selected = + (state & E_MAIL_READER_SELECTION_MULTIPLE); + /* FIXME Missing CAN_ADD_SENDER */ + enable_flag_clear = + (state & E_MAIL_READER_SELECTION_FLAG_CLEAR); + enable_flag_completed = + (state & E_MAIL_READER_SELECTION_FLAG_COMPLETED); + enable_flag_for_followup = + (state & E_MAIL_READER_SELECTION_FLAG_FOLLOWUP); + selection_has_deleted_messages = + (state & E_MAIL_READER_SELECTION_HAS_DELETED); + selection_has_important_messages = + (state & E_MAIL_READER_SELECTION_HAS_IMPORTANT); + selection_has_junk_messages = + (state & E_MAIL_READER_SELECTION_HAS_JUNK); + selection_has_not_junk_messages = + (state & E_MAIL_READER_SELECTION_HAS_NOT_JUNK); + selection_has_read_messages = + (state & E_MAIL_READER_SELECTION_HAS_READ); + selection_has_undeleted_messages = + (state & E_MAIL_READER_SELECTION_HAS_UNDELETED); + selection_has_unimportant_messages = + (state & E_MAIL_READER_SELECTION_HAS_UNIMPORTANT); + selection_has_unread_messages = + (state & E_MAIL_READER_SELECTION_HAS_UNREAD); + selection_is_mailing_list = + (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST); + + any_messages_selected = + (single_message_selected || multiple_messages_selected); + + action_name = "mail-check-for-junk"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-copy"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-delete"; + sensitive = selection_has_undeleted_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-filters-apply"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-forward"; + sensitive = have_an_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; + 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; + 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; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-load-images"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-important"; + sensitive = selection_has_unimportant_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-junk"; + sensitive = selection_has_not_junk_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-notjunk"; + sensitive = selection_has_junk_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-read"; + sensitive = selection_has_unread_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-unimportant"; + sensitive = selection_has_important_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-mark-unread"; + sensitive = selection_has_read_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-message-edit"; + sensitive = have_an_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; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-message-open"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-move"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-next-important"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-next-thread"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-next-unread"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-previous-important"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-previous-unread"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-print"; + sensitive = single_message_selected && !disable_printing; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-print-preview"; + sensitive = single_message_selected && !disable_printing; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-redirect"; + sensitive = have_an_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; + 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 && + 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; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-save-as"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-select-all"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-show-source"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-undelete"; + sensitive = selection_has_deleted_messages; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-zoom-100"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-zoom-in"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-zoom-out"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); +} + +static void mail_reader_init_charset_actions (EMailReader *reader) { GtkActionGroup *action_group; @@ -1916,6 +2180,7 @@ mail_reader_class_init (EMailReaderIface *iface) { iface->set_folder = mail_reader_set_folder; iface->set_message = mail_reader_set_message; + iface->update_actions = mail_reader_update_actions; signals[CHANGED] = g_signal_new ( "changed", @@ -1941,6 +2206,15 @@ mail_reader_class_init (EMailReaderIface *iface) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + signals[UPDATE_ACTIONS] = g_signal_new ( + "update-actions", + G_OBJECT_CLASS_TYPE (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); } GType @@ -2289,266 +2563,9 @@ e_mail_reader_check_state (EMailReader *reader) void e_mail_reader_update_actions (EMailReader *reader) { - EShell *shell; - EShellBackend *shell_backend; - EShellSettings *shell_settings; - GtkAction *action; - GtkActionGroup *action_group; - const gchar *action_name; - gboolean sensitive; - guint32 state; - - /* Be descriptive. */ - gboolean any_messages_selected; - gboolean disable_printing; - gboolean enable_flag_clear; - gboolean enable_flag_completed; - gboolean enable_flag_for_followup; - gboolean have_an_account; - gboolean multiple_messages_selected; - gboolean selection_has_deleted_messages; - gboolean selection_has_important_messages; - gboolean selection_has_junk_messages; - gboolean selection_has_not_junk_messages; - gboolean selection_has_read_messages; - gboolean selection_has_undeleted_messages; - gboolean selection_has_unimportant_messages; - gboolean selection_has_unread_messages; - gboolean selection_is_mailing_list; - gboolean single_message_selected; - g_return_if_fail (E_IS_MAIL_READER (reader)); - action_group = e_mail_reader_get_action_group (reader); - 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); - - disable_printing = e_shell_settings_get_boolean ( - shell_settings, "disable-printing"); - - have_an_account = - (state & E_MAIL_READER_HAVE_ACCOUNT); - single_message_selected = - (state & E_MAIL_READER_SELECTION_SINGLE); - multiple_messages_selected = - (state & E_MAIL_READER_SELECTION_MULTIPLE); - /* FIXME Missing CAN_ADD_SENDER */ - enable_flag_clear = - (state & E_MAIL_READER_SELECTION_FLAG_CLEAR); - enable_flag_completed = - (state & E_MAIL_READER_SELECTION_FLAG_COMPLETED); - enable_flag_for_followup = - (state & E_MAIL_READER_SELECTION_FLAG_FOLLOWUP); - selection_has_deleted_messages = - (state & E_MAIL_READER_SELECTION_HAS_DELETED); - selection_has_important_messages = - (state & E_MAIL_READER_SELECTION_HAS_IMPORTANT); - selection_has_junk_messages = - (state & E_MAIL_READER_SELECTION_HAS_JUNK); - selection_has_not_junk_messages = - (state & E_MAIL_READER_SELECTION_HAS_NOT_JUNK); - selection_has_read_messages = - (state & E_MAIL_READER_SELECTION_HAS_READ); - selection_has_undeleted_messages = - (state & E_MAIL_READER_SELECTION_HAS_UNDELETED); - selection_has_unimportant_messages = - (state & E_MAIL_READER_SELECTION_HAS_UNIMPORTANT); - selection_has_unread_messages = - (state & E_MAIL_READER_SELECTION_HAS_UNREAD); - selection_is_mailing_list = - (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST); - - any_messages_selected = - (single_message_selected || multiple_messages_selected); - - action_name = "mail-check-for-junk"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-copy"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-delete"; - sensitive = selection_has_undeleted_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-filters-apply"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-forward"; - sensitive = have_an_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; - 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; - 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; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-load-images"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-important"; - sensitive = selection_has_unimportant_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-junk"; - sensitive = selection_has_not_junk_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-notjunk"; - sensitive = selection_has_junk_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-read"; - sensitive = selection_has_unread_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-unimportant"; - sensitive = selection_has_important_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-mark-unread"; - sensitive = selection_has_read_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-message-edit"; - sensitive = have_an_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; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-message-open"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-move"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-next-important"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-next-thread"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-next-unread"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-previous-important"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-previous-unread"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-print"; - sensitive = single_message_selected && !disable_printing; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-print-preview"; - sensitive = single_message_selected && !disable_printing; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-redirect"; - sensitive = have_an_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; - 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 && - 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; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-save-as"; - sensitive = any_messages_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-select-all"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-show-source"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-undelete"; - sensitive = selection_has_deleted_messages; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-zoom-100"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-zoom-in"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); - - action_name = "mail-zoom-out"; - sensitive = single_message_selected; - action = e_mail_reader_get_action (reader, action_name); - gtk_action_set_sensitive (action, sensitive); + g_signal_emit (reader, signals[UPDATE_ACTIONS], 0); } GtkAction * diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index 6830e4f84c..d1b713d051 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -94,6 +94,7 @@ struct _EMailReaderIface { /* Signals */ void (*show_search_bar) (EMailReader *reader); + void (*update_actions) (EMailReader *reader); }; GType e_mail_reader_get_type (void); |