diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-20 08:05:40 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2009-01-20 08:05:40 +0800 |
commit | 22d41a51fae2d18315887b05000cf7facc36e887 (patch) | |
tree | 044eaaa852ca31a11ea70ec8bfa33c6df8c01891 | |
parent | 8e546420df08f5fe243aa4227be44915fd79b86b (diff) | |
download | gsoc2013-evolution-22d41a51fae2d18315887b05000cf7facc36e887.tar.gz gsoc2013-evolution-22d41a51fae2d18315887b05000cf7facc36e887.tar.zst gsoc2013-evolution-22d41a51fae2d18315887b05000cf7facc36e887.zip |
Formalize the "no disabled items in popup menus" policy in the form of a
GtkAction subclass called EPopupAction. Migrate all the modules over to
using EPopupActions in their popup menus.
Add sensitivity management of GtkActions to EMailReader. Not finished.
svn path=/branches/kill-bonobo/; revision=37106
28 files changed, 1378 insertions, 466 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index ce044d08f1..016563845b 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -709,30 +709,70 @@ static GtkActionEntry contact_entries[] = { N_("_Actions"), NULL, NULL, - NULL }, + NULL } +}; - /*** Address Book Popup Actions ***/ +static EPopupActionEntry contact_popup_entries[] = { { "address-book-popup-delete", - GTK_STOCK_DELETE, - NULL, - NULL, - N_("Delete this address book"), - G_CALLBACK (action_address_book_delete_cb) }, + N_("_Delete"), + "address-book-delete" }, { "address-book-popup-properties", - GTK_STOCK_PROPERTIES, - NULL, + N_("_Properties"), + "address-book-properties" }, + + { "address-book-popup-rename", NULL, - N_("Show properties of this address book"), - G_CALLBACK (action_address_book_properties_cb) }, + "address-book-rename" }, { "address-book-popup-save-as", - GTK_STOCK_SAVE_AS, N_("_Save as vCard..."), + "address-book-save-as" }, + + { "contact-popup-clipboard-copy", + NULL, + "contact-clipboard-copy" }, + + { "contact-popup-clipboard-cut", + NULL, + "contact-clipboard-cut" }, + + { "contact-popup-clipboard-paste", + NULL, + "contact-clipboard-paste" }, + + { "contact-popup-copy", + NULL, + "contact-copy" }, + + { "contact-popup-delete", + NULL, + "contact-delete" }, + + { "contact-popup-forward", + NULL, + "contact-forward" }, + + { "contact-popup-move", + NULL, + "contact-move" }, + + { "contact-popup-open", + NULL, + "contact-open" }, + + { "contact-popup-print", + NULL, + "contact-print" }, + + { "contact-popup-save-as", + NULL, + "contact-save-as" }, + + { "contact-popup-send-message", NULL, - N_("Save the contents of this address book as a vCard"), - G_CALLBACK (action_address_book_save_as_cb) } + "contact-send-message" }, }; static GtkToggleActionEntry contact_toggle_entries[] = { @@ -811,6 +851,9 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) gtk_action_group_add_actions ( action_group, contact_entries, G_N_ELEMENTS (contact_entries), book_shell_view); + e_action_group_add_popup_actions ( + action_group, contact_popup_entries, + G_N_ELEMENTS (contact_popup_entries)); gtk_action_group_add_toggle_actions ( action_group, contact_toggle_entries, G_N_ELEMENTS (contact_toggle_entries), book_shell_view); diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h index bcb1606933..503855dda6 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.h +++ b/addressbook/gui/component/e-book-shell-view-actions.h @@ -31,12 +31,6 @@ E_SHELL_WINDOW_ACTION ((window), "address-book-delete") #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_MOVE(window) \ E_SHELL_WINDOW_ACTION ((window), "address-book-move") -#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_POPUP_DELETE(window) \ - E_SHELL_WINDOW_ACTION ((window), "address-book-popup-delete") -#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_POPUP_PROPERTIES(window) \ - E_SHELL_WINDOW_ACTION ((window), "address-book-popup-properties") -#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_POPUP_SAVE_AS(window) \ - E_SHELL_WINDOW_ACTION ((window), "address-book-popup-save-as") #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PROPERTIES(window) \ E_SHELL_WINDOW_ACTION ((window), "address-book-properties") #define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_RENAME(window) \ diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index 0079ca3ec2..050c13d6eb 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -35,6 +35,7 @@ #include "e-util/gconf-bridge.h" #include "shell/e-shell-content.h" #include "shell/e-shell-sidebar.h" +#include "widgets/misc/e-popup-action.h" #include "addressbook/gui/contact-editor/e-contact-editor.h" #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index 601ce3b596..11cdaf6594 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -193,10 +193,6 @@ book_shell_view_update_actions (EShellView *shell_view) sensitive = has_primary_source && !primary_source_is_system; gtk_action_set_sensitive (action, sensitive); - action = ACTION (ADDRESS_BOOK_POPUP_DELETE); - sensitive = has_primary_source && !primary_source_is_system; - gtk_action_set_sensitive (action, sensitive); - action = ACTION (ADDRESS_BOOK_RENAME); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); diff --git a/calendar/modules/e-cal-shell-view-actions.c b/calendar/modules/e-cal-shell-view-actions.c index c63d3c8315..8b0f0df65b 100644 --- a/calendar/modules/e-cal-shell-view-actions.c +++ b/calendar/modules/e-cal-shell-view-actions.c @@ -812,14 +812,117 @@ static GtkActionEntry calendar_entries[] = { NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_event_schedule_cb) }, - /*** Menus ***/ - - { "calendar-actions-menu", - NULL, - N_("_Actions"), - NULL, - NULL, - NULL } + /*** Menus ***/ + + { "calendar-actions-menu", + NULL, + N_("_Actions"), + NULL, + NULL, + NULL } +}; + +static EPopupActionEntry calendar_popup_entries[] = { + + /* FIXME No equivalent main menu items for the any of the calendar + * popup menu items and for many of the event popup menu items. + * This is an accessibility issue. */ + + { "calendar-popup-copy", + NULL, + "calendar-copy" }, + + { "calendar-popup-delete", + NULL, + "calendar-delete" }, + + { "calendar-popup-go-today", + NULL, + "calendar-go-today" }, + + { "calendar-popup-jump-to", + NULL, + "calendar-jump-to" }, + + { "calendar-popup-properties", + NULL, + "calendar-properties" }, + + { "calendar-popup-rename", + NULL, + "calendar-rename" }, + + { "calendar-popup-select-one", + NULL, + "calendar-select-one" }, + + { "event-popup-clipboard-copy", + NULL, + "event-clipboard-copy" }, + + { "event-popup-clipboard-cut", + NULL, + "event-clipboard-cut" }, + + { "event-popup-clipboard-paste", + NULL, + "event-clipboard-paste" }, + + { "event-popup-copy", + NULL, + "event-copy" }, + + { "event-popup-delegate", + NULL, + "event-delegate" }, + + { "event-popup-delete", + NULL, + "event-delete" }, + + { "event-popup-delete-occurrence", + NULL, + "event-delete-occurrence" }, + + { "event-popup-delete-occurrence-all", + NULL, + "event-delete-occurrence-all" }, + + { "event-popup-forward", + NULL, + "event-forward" }, + + { "event-popup-move", + NULL, + "event-move" }, + + { "event-popup-occurrence-movable", + NULL, + "event-occurrence-movable" }, + + { "event-popup-open", + NULL, + "event-open" }, + + { "event-popup-print", + NULL, + "event-print" }, + + { "event-popup-reply", + NULL, + "event-reply" }, + + { "event-popup-reply-all", + NULL, + "event-reply-all" }, + + { "event-popup-save-as", + NULL, + "event-save-as" }, + + { "event-popup-schedule", + NULL, + "event-schedule" } }; static GtkRadioActionEntry calendar_view_entries[] = { diff --git a/calendar/modules/e-cal-shell-view-private.h b/calendar/modules/e-cal-shell-view-private.h index 3407b660d6..87f816d746 100644 --- a/calendar/modules/e-cal-shell-view-private.h +++ b/calendar/modules/e-cal-shell-view-private.h @@ -30,8 +30,9 @@ #include <libedataserver/e-categories.h> #include <libedataserver/e-data-server-util.h> -#include "e-util/e-dialog-utils.h" #include "e-util/e-util.h" +#include "e-util/e-dialog-utils.h" +#include "widgets/misc/e-popup-action.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/comp-util.h" diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index 554f1651d5..98f8569425 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -647,6 +647,61 @@ static GtkActionEntry memo_entries[] = { G_CALLBACK (action_memo_save_as_cb) } }; +static EPopupActionEntry memo_popup_entries[] = { + + { "memo-list-popup-copy", + NULL, + "memo-list-copy" }, + + { "memo-list-popup-delete", + NULL, + "memo-list-delete" }, + + { "memo-list-popup-properties", + NULL, + "memo-list-properties" }, + + { "memo-list-popup-rename", + NULL, + "memo-list-rename" }, + + { "memo-list-popup-select-one", + NULL, + "memo-list-select-one" }, + + { "memo-popup-clipboard-copy", + NULL, + "memo-clipboard-copy" }, + + { "memo-popup-clipboard-cut", + NULL, + "memo-clipboard-cut" }, + + { "memo-popup-delete", + NULL, + "memo-delete" }, + + { "memo-popup-forward", + NULL, + "memo-forward" }, + + { "memo-popup-open", + NULL, + "memo-open" }, + + { "memo-popup-open-url", + NULL, + "memo-open-url" }, + + { "memo-popup-print", + NULL, + "memo-print" }, + + { "memo-popup-save-as", + NULL, + "memo-save-as" } +}; + static GtkToggleActionEntry memo_toggle_entries[] = { { "memo-preview", @@ -722,6 +777,9 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) gtk_action_group_add_actions ( action_group, memo_entries, G_N_ELEMENTS (memo_entries), memo_shell_view); + e_action_group_add_popup_actions ( + action_group, memo_popup_entries, + G_N_ELEMENTS (memo_popup_entries)); gtk_action_group_add_toggle_actions ( action_group, memo_toggle_entries, G_N_ELEMENTS (memo_toggle_entries), memo_shell_view); diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h index 66d9665c48..8ed9ba1837 100644 --- a/calendar/modules/e-memo-shell-view-private.h +++ b/calendar/modules/e-memo-shell-view-private.h @@ -33,6 +33,7 @@ #include "e-util/e-error.h" #include "e-util/e-util.h" #include "e-util/gconf-bridge.h" +#include "widgets/misc/e-popup-action.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-component-preview.h" diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c index 61a1455809..8e1695afa2 100644 --- a/calendar/modules/e-task-shell-view-actions.c +++ b/calendar/modules/e-task-shell-view-actions.c @@ -802,6 +802,77 @@ static GtkActionEntry task_entries[] = { NULL } }; +static EPopupActionEntry task_popup_entries[] = { + + { "task-list-popup-copy", + NULL, + "task-list-copy" }, + + { "task-list-popup-delete", + NULL, + "task-list-delete" }, + + { "task-list-popup-properties", + NULL, + "task-list-properties" }, + + { "task-list-popup-rename", + NULL, + "task-list-rename" }, + + { "task-list-popup-select-one", + NULL, + "task-list-select-one" }, + + { "task-popup-assign", + NULL, + "task-assign" }, + + { "task-popup-clipboard-copy", + NULL, + "task-clipboard-copy" }, + + { "task-popup-clipboard-cut", + NULL, + "task-clipboard-cut" }, + + { "task-popup-clipboard-paste", + NULL, + "task-clipboard-paste" }, + + { "task-popup-delete", + NULL, + "task-delete" }, + + { "task-popup-forward", + NULL, + "task-forward" }, + + { "task-popup-mark-complete", + NULL, + "task-mark-complete" }, + + { "task-popup-mark-incomplete", + NULL, + "task-mark-incomplete" }, + + { "task-popup-open", + NULL, + "task-open" }, + + { "task-popup-open-url", + NULL, + "task-open-url" }, + + { "task-popup-print", + NULL, + "task-print" }, + + { "task-popup-save-as", + NULL, + "task-save-as" }, +}; + static GtkToggleActionEntry task_toggle_entries[] = { { "task-preview", @@ -912,6 +983,9 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) gtk_action_group_add_actions ( action_group, task_entries, G_N_ELEMENTS (task_entries), task_shell_view); + e_action_group_add_popup_actions ( + action_group, task_popup_entries, + G_N_ELEMENTS (task_popup_entries)); gtk_action_group_add_toggle_actions ( action_group, task_toggle_entries, G_N_ELEMENTS (task_toggle_entries), task_shell_view); diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h index c0e2d97145..ccf7e00521 100644 --- a/calendar/modules/e-task-shell-view-private.h +++ b/calendar/modules/e-task-shell-view-private.h @@ -34,6 +34,7 @@ #include "e-util/e-error.h" #include "e-util/e-util.h" #include "e-util/gconf-bridge.h" +#include "widgets/misc/e-popup-action.h" #include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 697142aa6d..204141b430 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -31,9 +31,11 @@ #endif #include "e-util/e-util.h" +#include "e-util/e-binding.h" #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" #include "widgets/misc/e-charset-picker.h" +#include "widgets/misc/e-popup-action.h" #include "mail/e-mail-browser.h" #include "mail/e-mail-reader-utils.h" @@ -872,7 +874,6 @@ action_mail_select_all_cb (GtkAction *action, EMailReader *reader) { EMFormatHTMLDisplay *html_display; - GtkActionGroup *action_group; GtkHTML *html; const gchar *action_name; gboolean selection_active; @@ -883,8 +884,7 @@ action_mail_select_all_cb (GtkAction *action, gtk_html_select_all (html); action_name = "mail-clipboard-copy"; - action_group = e_mail_reader_get_action_group (reader); - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); selection_active = gtk_html_command (html, "is-selection-active"); gtk_action_set_sensitive (action, selection_active); } @@ -1484,57 +1484,6 @@ static GtkActionEntry mail_reader_entries[] = { N_("Decrease the text size"), G_CALLBACK (action_mail_zoom_out_cb) }, - /*** Popup Menu Variations ***/ - - { "mail-popup-flag-for-followup", - "stock_mail-flag-for-followup", - N_("Mark for Follo_w Up..."), - NULL, - N_("Flag the selected messages for follow-up"), - G_CALLBACK (action_mail_flag_for_followup_cb) }, - - { "mail-popup-mark-important", - "mail-mark-important", - N_("Mark as _Important"), - NULL, - N_("Mark the selected messages as important"), - G_CALLBACK (action_mail_mark_important_cb) }, - - { "mail-popup-mark-junk", - "mail-mark-junk", - N_("Mark as _Junk"), - NULL, - N_("Mark the selected messages as junk"), - G_CALLBACK (action_mail_mark_junk_cb) }, - - { "mail-popup-mark-notjunk", - "mail-mark-notjunk", - N_("Mark as _Not Junk"), - NULL, - N_("Mark the selected messages as not being junk"), - G_CALLBACK (action_mail_mark_notjunk_cb) }, - - { "mail-popup-mark-read", - "mail-mark-read", - N_("Mark as _Read"), - NULL, - N_("Mark the selected messages as having been read"), - G_CALLBACK (action_mail_mark_read_cb) }, - - { "mail-popup-mark-unimportant", - NULL, - N_("Mark as Uni_mportant"), - NULL, - N_("Mark the selected message as unimportant"), - G_CALLBACK (action_mail_mark_unimportant_cb) }, - - { "mail-popup-mark-unread", - "mail-mark-unread", - N_("Mark as _Unread"), - NULL, - N_("Mark the selected messages as not having been read"), - G_CALLBACK (action_mail_mark_unread_cb) }, - /*** Menus ***/ { "mail-create-rule-menu", @@ -1601,6 +1550,77 @@ static GtkActionEntry mail_reader_entries[] = { NULL } }; +static EPopupActionEntry mail_reader_popup_entries[] = { + + { "mail-popup-copy", + NULL, + "mail-copy" }, + + { "mail-popup-delete", + NULL, + "mail-delete" }, + + { "mail-popup-flag-for-followup", + N_("Mark for Follo_w Up..."), + "mail-flag-for-followup" }, + + { "mail-popup-forward", + NULL, + "mail-forward" }, + + { "mail-popup-mark-important", + N_("Mark as _Important"), + "mail-mark-important" }, + + { "mail-popup-mark-junk", + N_("Mark as _Junk"), + "mail-mark-junk" }, + + { "mail-popup-mark-notjunk", + N_("Mark as _Not Junk"), + "mail-mark-notjunk" }, + + { "mail-popup-mark-read", + N_("Mark as _Read"), + "mail-mark-read" }, + + { "mail-popup-mark-unimportant", + N_("Mark as Uni_mportant"), + "mail-mark-unimportant" }, + + { "mail-popup-mark-unread", + N_("Mark as _Unread"), + "mail-mark-unread" }, + + { "mail-popup-message-edit", + NULL, + "mail-message-edit" }, + + { "mail-popup-move", + NULL, + "mail-move" }, + + { "mail-popup-print", + NULL, + "mail-print" }, + + { "mail-popup-reply-all", + NULL, + "mail-reply-all" }, + + { "mail-popup-reply-sender", + NULL, + "mail-reply-sender" }, + + { "mail-popup-save-as", + NULL, + "mail-save-as" }, + + { "mail-popup-undelete", + NULL, + "mail-undelete" } +}; + static GtkToggleActionEntry mail_reader_toggle_entries[] = { { "mail-caret-mode", @@ -1659,14 +1679,12 @@ mail_reader_html_button_release_event_cb (EMailReader *reader, GdkEventButton *button, GtkHTML *html) { - GtkActionGroup *action_group; GtkAction *action; const gchar *action_name; gboolean selection_active; action_name = "mail-clipboard-copy"; - action_group = e_mail_reader_get_action_group (reader); - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); selection_active = gtk_html_command (html, "is-selection-active"); gtk_action_set_sensitive (action, selection_active); @@ -1860,6 +1878,8 @@ mail_reader_message_loaded_cb (CamelFolder *folder, camel_exception_clear (ex); } + e_mail_reader_update_actions (reader); + /* We referenced this in the call to mail_get_messagex(). */ g_object_unref (reader); } @@ -2066,6 +2086,9 @@ e_mail_reader_init (EMailReader *reader) gtk_action_group_add_actions ( action_group, mail_reader_entries, G_N_ELEMENTS (mail_reader_entries), reader); + e_action_group_add_popup_actions ( + action_group, mail_reader_popup_entries, + G_N_ELEMENTS (mail_reader_popup_entries)); gtk_action_group_add_toggle_actions ( action_group, mail_reader_toggle_entries, G_N_ELEMENTS (mail_reader_toggle_entries), reader); @@ -2078,34 +2101,34 @@ e_mail_reader_init (EMailReader *reader) action_name = "mail-caret-mode"; key = "/apps/evolution/mail/display/caret_mode"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); action_name = "mail-show-all-headers"; key = "/apps/evolution/mail/display/show_all_headers"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); /* Fine tuning. */ action_name = "mail-clipboard-copy"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); gtk_action_set_sensitive (action, FALSE); action_name = "mail-delete"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "short-label", _("Delete"), NULL); action_name = "mail-next"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "short-label", _("Next"), NULL); action_name = "mail-previous"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "short-label", _("Previous"), NULL); action_name = "mail-reply-sender"; - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); g_object_set (action, "short-label", _("Reply"), NULL); /* Connect signals. */ @@ -2147,6 +2170,405 @@ e_mail_reader_changed (EMailReader *reader) g_signal_emit (reader, signals[CHANGED], 0); } +guint32 +e_mail_reader_check_state (EMailReader *reader) +{ + MessageList *message_list; + GPtrArray *uids; + CamelFolder *folder; + CamelStore *store = NULL; + 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; + guint ii; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), 0); + + message_list = e_mail_reader_get_message_list (reader); + uids = message_list_get_selected (message_list); + folder_uri = message_list->folder_uri; + folder = message_list->folder; + + if (folder != NULL) + 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 && store != NULL) { + 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_READER_SELECTION_SINGLE; + if (uids->len > 1) + state |= E_MAIL_READER_SELECTION_MULTIPLE; + if (!draft_or_outbox && uids->len == 1) + state |= E_MAIL_READER_SELECTION_CAN_ADD_SENDER; +#if 0 /* FIXME */ + if (can_edit) + state |= E_MAIL_READER_SELECTION_CAN_EDIT; +#endif + if (can_clear_flags) + state |= E_MAIL_READER_SELECTION_FLAG_CLEAR; + if (can_flag_completed) + state |= E_MAIL_READER_SELECTION_FLAG_COMPLETED; + if (can_flag_for_followup) + state |= E_MAIL_READER_SELECTION_FLAG_FOLLOWUP; + if (has_deleted) + state |= E_MAIL_READER_SELECTION_HAS_DELETED; + if (has_important) + state |= E_MAIL_READER_SELECTION_HAS_IMPORTANT; + if (has_junk) + state |= E_MAIL_READER_SELECTION_HAS_JUNK; + if (has_not_junk) + state |= E_MAIL_READER_SELECTION_HAS_NOT_JUNK; + if (has_read) + state |= E_MAIL_READER_SELECTION_HAS_READ; + if (has_undeleted) + state |= E_MAIL_READER_SELECTION_HAS_UNDELETED; + if (has_unimportant) + state |= E_MAIL_READER_SELECTION_HAS_UNIMPORTANT; + if (has_unread) + state |= E_MAIL_READER_SELECTION_HAS_UNREAD; +#if 0 /* FIXME */ + if (has_callto_uri) + state |= E_MAIL_READER_SELECTION_HAS_URI_CALLTO; + if (has_http_uri) + state |= E_MAIL_READER_SELECTION_HAS_URI_HTTP; + if (has_mailto_uri) + state |= E_MAIL_READER_SELECTION_HAS_URI_MAILTO; + if (is_mailing_list) + state |= E_MAIL_READER_SELECTION_IS_MAILING_LIST; +#endif + + em_utils_uids_free (uids); + + return state; + +} + +void +e_mail_reader_update_actions (EMailReader *reader) +{ + GtkAction *action; + GtkActionGroup *action_group; + const gchar *action_name; + gboolean sensitive; + guint32 state; + + /* Be descriptive. */ + gboolean any_messages_selected; + gboolean enable_flag_clear; + gboolean enable_flag_completed; + gboolean enable_flag_for_followup; + gboolean single_message_selected; + 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; + + 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); + + single_message_selected = + (state & E_MAIL_READER_SELECTION_SINGLE); + multiple_messages_selected = + (state & E_MAIL_READER_SELECTION_MULTIPLE); + /* FIXME Missing booleans */ + 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); + /* FIXME Missing booleans */ + 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 = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-forward-attached"; + sensitive = any_messages_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-forward-inline"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-forward-quoted"; + sensitive = 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 = single_message_selected; + 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; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-print-preview"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-redirect"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-reply-all"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-reply-list"; + sensitive = 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-post"; + sensitive = single_message_selected; + action = e_mail_reader_get_action (reader, action_name); + gtk_action_set_sensitive (action, sensitive); + + action_name = "mail-reply-sender"; + sensitive = 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); +} + +GtkAction * +e_mail_reader_get_action (EMailReader *reader, + const gchar *action_name) +{ + GtkActionGroup *action_group; + GtkAction *action; + + g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + action_group = e_mail_reader_get_action_group (reader); + action = gtk_action_group_get_action (action_group, action_name); + + if (action == NULL) + g_critical ( + "%s: action `%s' not found", G_STRFUNC, action_name); + + return action; +} + GtkActionGroup * e_mail_reader_get_action_group (EMailReader *reader) { @@ -2284,7 +2706,6 @@ e_mail_reader_create_charset_menu (EMailReader *reader, GtkUIManager *ui_manager, guint merge_id) { - GtkActionGroup *action_group; GtkAction *action; const gchar *action_name; const gchar *path; @@ -2294,8 +2715,7 @@ e_mail_reader_create_charset_menu (EMailReader *reader, g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager)); action_name = "mail-charset-default"; - action_group = e_mail_reader_get_action_group (reader); - action = gtk_action_group_get_action (action_group, action_name); + action = e_mail_reader_get_action (reader, action_name); g_return_if_fail (action != NULL); list = gtk_radio_action_get_group (GTK_RADIO_ACTION (action)); diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index bf8f986145..4ddf844b6a 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -49,6 +49,28 @@ G_BEGIN_DECLS typedef struct _EMailReader EMailReader; typedef struct _EMailReaderIface EMailReaderIface; +enum { + E_MAIL_READER_SELECTION_SINGLE = 1 << 0, + E_MAIL_READER_SELECTION_MULTIPLE = 1 << 1, + E_MAIL_READER_SELECTION_CAN_ADD_SENDER = 1 << 2, + E_MAIL_READER_SELECTION_CAN_EDIT = 1 << 3, + E_MAIL_READER_SELECTION_FLAG_CLEAR = 1 << 4, + E_MAIL_READER_SELECTION_FLAG_COMPLETED = 1 << 5, + E_MAIL_READER_SELECTION_FLAG_FOLLOWUP = 1 << 6, + E_MAIL_READER_SELECTION_HAS_DELETED = 1 << 7, + E_MAIL_READER_SELECTION_HAS_IMPORTANT = 1 << 8, + E_MAIL_READER_SELECTION_HAS_JUNK = 1 << 9, + E_MAIL_READER_SELECTION_HAS_NOT_JUNK = 1 << 10, + E_MAIL_READER_SELECTION_HAS_READ = 1 << 11, + E_MAIL_READER_SELECTION_HAS_UNDELETED = 1 << 12, + E_MAIL_READER_SELECTION_HAS_UNIMPORTANT = 1 << 13, + E_MAIL_READER_SELECTION_HAS_UNREAD = 1 << 14, + E_MAIL_READER_SELECTION_HAS_URI_CALLTO = 1 << 15, + E_MAIL_READER_SELECTION_HAS_URI_HTTP = 1 << 16, + E_MAIL_READER_SELECTION_HAS_URI_MAILTO = 1 << 17, + E_MAIL_READER_SELECTION_IS_MAILING_LIST = 1 << 18 +}; + struct _EMailReaderIface { GTypeInterface parent_iface; @@ -72,6 +94,10 @@ struct _EMailReaderIface { 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); +GtkAction * e_mail_reader_get_action (EMailReader *reader, + const gchar *action_name); GtkActionGroup * e_mail_reader_get_action_group (EMailReader *reader); gboolean e_mail_reader_get_hide_deleted (EMailReader *reader); diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c index d0d51baf1b..747794b662 100644 --- a/mail/e-mail-shell-content.c +++ b/mail/e-mail-shell-content.c @@ -238,128 +238,7 @@ mail_shell_content_constructed (GObject *object) static guint32 mail_shell_content_check_state (EShellContent *shell_content) { - EMailReader *reader; - EMailShellContent *mail_shell_content; - MessageList *message_list; - 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; - guint ii; - - reader = E_MAIL_READER (shell_content); - message_list = e_mail_reader_get_message_list (reader); - mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content); - uids = message_list_get_selected (message_list); - folder_uri = message_list->folder_uri; - folder = message_list->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; + return e_mail_reader_check_state (E_MAIL_READER (shell_content)); } static GtkActionGroup * diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h index 5a94df559c..9d2358590f 100644 --- a/mail/e-mail-shell-content.h +++ b/mail/e-mail-shell-content.h @@ -52,28 +52,6 @@ typedef struct _EMailShellContent EMailShellContent; typedef struct _EMailShellContentClass EMailShellContentClass; typedef struct _EMailShellContentPrivate EMailShellContentPrivate; -enum { - E_MAIL_SHELL_CONTENT_SELECTION_SINGLE = 1 << 0, - E_MAIL_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1, - E_MAIL_SHELL_CONTENT_SELECTION_CAN_ADD_SENDER = 1 << 2, - E_MAIL_SHELL_CONTENT_SELECTION_CAN_EDIT = 1 << 3, - E_MAIL_SHELL_CONTENT_SELECTION_FLAG_CLEAR = 1 << 4, - E_MAIL_SHELL_CONTENT_SELECTION_FLAG_COMPLETED = 1 << 5, - E_MAIL_SHELL_CONTENT_SELECTION_FLAG_FOLLOWUP = 1 << 6, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_DELETED = 1 << 7, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_IMPORTANT = 1 << 8, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_JUNK = 1 << 9, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_NOT_JUNK = 1 << 10, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_READ = 1 << 11, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNDELETED = 1 << 12, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNIMPORTANT = 1 << 13, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNREAD = 1 << 14, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_CALLTO = 1 << 15, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_HTTP = 1 << 16, - E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_MAILTO = 1 << 17, - E_MAIL_SHELL_CONTENT_SELECTION_IS_MAILING_LIST = 1 << 18 -}; - struct _EMailShellContent { EShellContent parent; EMailShellContentPrivate *priv; diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c index 8037470ffe..a3d7397372 100644 --- a/mail/e-mail-shell-view-actions.c +++ b/mail/e-mail-shell-view-actions.c @@ -725,72 +725,64 @@ static GtkActionEntry mail_entries[] = { N_("Subscribe or unsubscribe to folders on remote servers"), G_CALLBACK (action_mail_tools_subscriptions_cb) }, - /*** Popup Menu Variations ***/ + /*** Menus ***/ - { "mail-popup-folder-copy", - "folder-copy", - N_("_Copy Folder To..."), + { "mail-folder-menu", NULL, - N_("Copy the selected folder into another folder"), - G_CALLBACK (action_mail_folder_copy_cb) }, - - { "mail-popup-folder-delete", - GTK_STOCK_DELETE, + N_("F_older"), NULL, NULL, - N_("Permanently remove this folder"), - G_CALLBACK (action_mail_folder_delete_cb) }, + NULL }, - { "mail-popup-folder-move", - "folder-move", - N_("_Move Folder To..."), + { "mail-preview-menu", NULL, - N_("Move the selected folder into another folder"), - G_CALLBACK (action_mail_folder_move_cb) }, - - { "mail-popup-folder-new", - "folder-new", - N_("_New Folder..."), + N_("_Preview"), NULL, - N_("Create a new folder for storing mail"), - G_CALLBACK (action_mail_folder_new_cb) }, + NULL, + NULL } +}; - { "mail-popup-folder-properties", - GTK_STOCK_PROPERTIES, +static EPopupActionEntry mail_popup_entries[] = { + + { "mail-popup-account-disable", NULL, + "mail-account-disable" }, + + { "mail-popup-empty-trash", NULL, - N_("Change the properties of this folder"), - G_CALLBACK (action_mail_folder_properties_cb) }, + "mail-empty-trash" }, - { "mail-popup-folder-refresh", - GTK_STOCK_REFRESH, + { "mail-popup-flush-outbox", NULL, + "mail-flush-outbox" }, + + { "mail-popup-folder-copy", NULL, - N_("Refresh the folder"), - G_CALLBACK (action_mail_folder_refresh_cb) }, + "mail-folder-copy" }, - { "mail-popup-folder-rename", + { "mail-popup-folder-delete", NULL, - N_("_Rename..."), + "mail-folder-delete" }, + + { "mail-popup-folder-move", NULL, - N_("Change the name of this folder"), - G_CALLBACK (action_mail_folder_rename_cb) }, + "mail-folder-move" }, - /*** Menus ***/ + { "mail-popup-folder-new", + N_("_New Folder..."), + "mail-folder-new" }, - { "mail-folder-menu", - NULL, - N_("F_older"), - NULL, + { "mail-popup-folder-properties", NULL, - NULL }, + "mail-folder-properties" }, - { "mail-preview-menu", - NULL, - N_("_Preview"), + { "mail-popup-folder-refresh", NULL, + "mail-folder-refresh" }, + + { "mail-popup-folder-rename", NULL, - NULL } + "mail-folder-rename" } }; static GtkToggleActionEntry mail_toggle_entries[] = { @@ -1054,6 +1046,9 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) gtk_action_group_add_actions ( action_group, mail_entries, G_N_ELEMENTS (mail_entries), mail_shell_view); + e_action_group_add_popup_actions ( + action_group, mail_popup_entries, + G_N_ELEMENTS (mail_popup_entries)); gtk_action_group_add_toggle_actions ( action_group, mail_toggle_entries, G_N_ELEMENTS (mail_toggle_entries), mail_shell_view); @@ -1088,34 +1083,4 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) object = G_OBJECT (ACTION (MAIL_VIEW_VERTICAL)); key = "/apps/evolution/mail/display/layout"; gconf_bridge_bind_property (bridge, key, object, "current-value"); - - /* Fine tuning. */ - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_COPY)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_COPY)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_DELETE)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_DELETE)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_MOVE)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_MOVE)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_NEW)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_NEW)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_PROPERTIES)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_PROPERTIES)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_REFRESH)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_REFRESH)), "visible"); - - e_binding_new ( - G_OBJECT (ACTION (MAIL_FOLDER_RENAME)), "sensitive", - G_OBJECT (ACTION (MAIL_POPUP_FOLDER_RENAME)), "visible"); } diff --git a/mail/e-mail-shell-view-actions.h b/mail/e-mail-shell-view-actions.h index 55125657b6..7e144ad4d7 100644 --- a/mail/e-mail-shell-view-actions.h +++ b/mail/e-mail-shell-view-actions.h @@ -135,20 +135,6 @@ E_SHELL_WINDOW_ACTION ((window), "mail-next-thread") #define E_SHELL_WINDOW_ACTION_MAIL_NEXT_UNREAD(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-next-unread") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_COPY(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-copy") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_DELETE(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-delete") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_MOVE(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-move") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_NEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-new") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_PROPERTIES(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-properties") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_REFRESH(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-refresh") -#define E_SHELL_WINDOW_ACTION_MAIL_POPUP_FOLDER_RENAME(window) \ - E_SHELL_WINDOW_ACTION ((window), "mail-popup-folder-rename") #define E_SHELL_WINDOW_ACTION_MAIL_PREVIEW(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-preview") #define E_SHELL_WINDOW_ACTION_MAIL_PREVIOUS(window) \ diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h index af9cc1a673..a3f7b8d99e 100644 --- a/mail/e-mail-shell-view-private.h +++ b/mail/e-mail-shell-view-private.h @@ -29,8 +29,8 @@ #include <camel/camel-vtrash-folder.h> #include "e-util/e-util.h" -#include "e-util/e-binding.h" #include "e-util/gconf-bridge.h" +#include "widgets/misc/e-popup-action.h" #include "widgets/menus/gal-view-instance.h" #include "e-mail-reader.h" diff --git a/mail/e-mail-shell-view.c b/mail/e-mail-shell-view.c index f93e72c043..5a338ab011 100644 --- a/mail/e-mail-shell-view.c +++ b/mail/e-mail-shell-view.c @@ -88,6 +88,7 @@ mail_shell_view_update_actions (EShellView *shell_view) { EMailShellViewPrivate *priv; EMailShellSidebar *mail_shell_sidebar; + EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; EMFolderTree *folder_tree; @@ -96,7 +97,6 @@ mail_shell_view_update_actions (EShellView *shell_view) const gchar *label; gchar *uri; gboolean sensitive; - gboolean visible; guint32 state; /* Be descriptive. */ @@ -112,6 +112,9 @@ mail_shell_view_update_actions (EShellView *shell_view) shell_window = e_shell_view_get_shell_window (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + e_mail_reader_update_actions (E_MAIL_READER (shell_content)); + mail_shell_sidebar = priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); @@ -144,21 +147,21 @@ mail_shell_view_update_actions (EShellView *shell_view) } action = ACTION (MAIL_ACCOUNT_DISABLE); - visible = (account != NULL) && folder_is_store; + sensitive = (account != NULL) && folder_is_store; if (account_is_groupwise) label = _("Proxy _Logout"); else label = _("_Disable Account"); - gtk_action_set_visible (action, visible); + gtk_action_set_sensitive (action, sensitive); g_object_set (action, "label", label, NULL); action = ACTION (MAIL_EMPTY_TRASH); - visible = folder_is_trash; - gtk_action_set_visible (action, visible); + sensitive = folder_is_trash; + gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FLUSH_OUTBOX); - visible = folder_is_outbox; - gtk_action_set_visible (action, visible); + sensitive = folder_is_outbox; + gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_COPY); sensitive = !folder_is_store; @@ -182,9 +185,7 @@ mail_shell_view_update_actions (EShellView *shell_view) action = ACTION (MAIL_FOLDER_REFRESH); sensitive = !folder_is_store; - visible = !folder_is_outbox; gtk_action_set_sensitive (action, sensitive); - gtk_action_set_visible (action, visible); action = ACTION (MAIL_FOLDER_RENAME); sensitive = !folder_is_store && folder_can_be_deleted; diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 51846a2bcb..4d94ec3309 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -110,54 +110,54 @@ static const EMFolderViewEnable emfv_enable_map[] = { { "EditCut", EM_POPUP_SELECT_MANY }, { "EditCopy", EM_FOLDER_VIEW_SELECT_SELECTION }, { "EditPaste", EM_POPUP_SELECT_FOLDER }, - { "SelectAllText", EM_POPUP_SELECT_ONE }, +// { "SelectAllText", EM_POPUP_SELECT_ONE }, /* FIXME: should these be single-selection? */ { "MailNext", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_NEXT_MSG }, - { "MailNextFlagged", EM_POPUP_SELECT_MANY }, - { "MailNextUnread", EM_POPUP_SELECT_MANY }, - { "MailNextThread", EM_POPUP_SELECT_MANY }, +// { "MailNextFlagged", EM_POPUP_SELECT_MANY }, +// { "MailNextUnread", EM_POPUP_SELECT_MANY }, +// { "MailNextThread", EM_POPUP_SELECT_MANY }, { "MailPrevious", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_PREV_MSG }, - { "MailPreviousFlagged", EM_POPUP_SELECT_MANY }, - { "MailPreviousUnread", EM_POPUP_SELECT_MANY }, +// { "MailPreviousFlagged", EM_POPUP_SELECT_MANY }, +// { "MailPreviousUnread", EM_POPUP_SELECT_MANY }, { "AddSenderToAddressbook", EM_POPUP_SELECT_ADD_SENDER }, - { "MessageApplyFilters", EM_POPUP_SELECT_MANY }, - { "MessageFilterJunk", EM_POPUP_SELECT_MANY }, - { "MessageCopy", EM_POPUP_SELECT_MANY }, - { "MessageDelete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_DELETE }, - { "MessageDeleteKey", EM_POPUP_SELECT_MANY}, - { "MessageForward", EM_POPUP_SELECT_MANY }, - { "MessageForwardAttached", EM_POPUP_SELECT_MANY }, - { "MessageForwardInline", EM_POPUP_SELECT_ONE }, - { "MessageForwardQuoted", EM_POPUP_SELECT_ONE }, - { "MessageRedirect", EM_POPUP_SELECT_ONE }, - { "MessageMarkAsRead", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_READ }, - { "MessageMarkAsUnRead", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_UNREAD }, - { "MessageMarkAsImportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_IMPORTANT }, - { "MessageMarkAsUnimportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_UNIMPORTANT }, - { "MessageMarkAsJunk", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_JUNK }, - { "MessageMarkAsNotJunk", EM_POPUP_SELECT_MANY}, +// { "MessageApplyFilters", EM_POPUP_SELECT_MANY }, +// { "MessageFilterJunk", EM_POPUP_SELECT_MANY }, +// { "MessageCopy", EM_POPUP_SELECT_MANY }, +// { "MessageDelete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_DELETE }, +// { "MessageDeleteKey", EM_POPUP_SELECT_MANY}, +// { "MessageForward", EM_POPUP_SELECT_MANY }, +// { "MessageForwardAttached", EM_POPUP_SELECT_MANY }, +// { "MessageForwardInline", EM_POPUP_SELECT_ONE }, +// { "MessageForwardQuoted", EM_POPUP_SELECT_ONE }, +// { "MessageRedirect", EM_POPUP_SELECT_ONE }, +// { "MessageMarkAsRead", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_READ }, +// { "MessageMarkAsUnRead", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_UNREAD }, +// { "MessageMarkAsImportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_IMPORTANT }, +// { "MessageMarkAsUnimportant", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_MARK_UNIMPORTANT }, +// { "MessageMarkAsJunk", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_JUNK }, +// { "MessageMarkAsNotJunk", EM_POPUP_SELECT_MANY}, { "MessageFollowUpFlag", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_FOLLOWUP }, { "MessageFollowUpComplete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_COMPLETED }, { "MessageFollowUpClear", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_FLAG_CLEAR }, - { "MessageMove", EM_POPUP_SELECT_MANY }, - { "MessageOpen", EM_POPUP_SELECT_MANY }, - { "MessagePostReply", EM_POPUP_SELECT_ONE }, - { "MessageReplyAll", EM_POPUP_SELECT_ONE }, - { "MessageReplyList", EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST }, - { "MessageReplySender", EM_POPUP_SELECT_ONE }, - { "MessageEdit", EM_POPUP_SELECT_ONE }, - { "MessageSaveAs", EM_POPUP_SELECT_MANY }, +// { "MessageMove", EM_POPUP_SELECT_MANY }, +// { "MessageOpen", EM_POPUP_SELECT_MANY }, +// { "MessagePostReply", EM_POPUP_SELECT_ONE }, +// { "MessageReplyAll", EM_POPUP_SELECT_ONE }, +// { "MessageReplyList", EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST }, +// { "MessageReplySender", EM_POPUP_SELECT_ONE }, +// { "MessageEdit", EM_POPUP_SELECT_ONE }, +// { "MessageSaveAs", EM_POPUP_SELECT_MANY }, { "MessageSearch", EM_POPUP_SELECT_ONE| EM_FOLDER_VIEW_PREVIEW_PRESENT }, - { "MessageUndelete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_UNDELETE }, - { "PrintMessage", EM_POPUP_SELECT_ONE }, - { "PrintPreviewMessage", EM_POPUP_SELECT_ONE }, +// { "MessageUndelete", EM_POPUP_SELECT_MANY|EM_POPUP_SELECT_UNDELETE }, +// { "PrintMessage", EM_POPUP_SELECT_ONE }, +// { "PrintPreviewMessage", EM_POPUP_SELECT_ONE }, - { "TextZoomIn", EM_POPUP_SELECT_ONE }, - { "TextZoomOut", EM_POPUP_SELECT_ONE }, - { "TextZoomReset", EM_POPUP_SELECT_ONE }, +// { "TextZoomIn", EM_POPUP_SELECT_ONE }, +// { "TextZoomOut", EM_POPUP_SELECT_ONE }, +// { "TextZoomReset", EM_POPUP_SELECT_ONE }, { "ToolsFilterMailingList", EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST}, { "ToolsFilterRecipient", EM_POPUP_SELECT_ONE }, @@ -168,11 +168,11 @@ static const EMFolderViewEnable emfv_enable_map[] = { { "ToolsVFolderSender", EM_POPUP_SELECT_ONE }, { "ToolsVFolderSubject", EM_POPUP_SELECT_ONE }, - { "ViewLoadImages", EM_POPUP_SELECT_ONE }, - { "ViewSource", EM_POPUP_SELECT_ONE }, +// { "ViewLoadImages", EM_POPUP_SELECT_ONE }, +// { "ViewSource", EM_POPUP_SELECT_ONE }, - /* always enabled */ - { "MailStop", 0 }, +// /* always enabled */ +// { "MailStop", 0 }, { NULL }, }; diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui index 3444bebb72..59900ea05f 100644 --- a/ui/evolution-calendars.ui +++ b/ui/evolution-calendars.ui @@ -48,48 +48,48 @@ </toolbar> <popup name='calendar-popup'> <menuitem action='calendar-new'/> - <menuitem action='calendar-copy'/> - <menuitem action='calendar-rename'/> + <menuitem action='calendar-popup-copy'/> + <menuitem action='calendar-popup-rename'/> <separator/> - <menuitem action='calendar-delete'/> - <menuitem action='calendar-select-one'/> + <menuitem action='calendar-popup-delete'/> + <menuitem action='calendar-popup-select-one'/> <separator/> - <menuitem action='calendar-properties'/> + <menuitem action='calendar-popup-properties'/> </popup> <popup name='calendar-empty-popup'> <menuitem action='event-new'/> <menuitem action='event-all-day-new'/> <menuitem action='event-meeting-new'/> <separator/> - <menuitem action='event-print'/> + <menuitem action='event-popup-print'/> <separator/> - <menuitem action='event-clipboard-paste'/> + <menuitem action='event-popup-clipboard-paste'/> <separator/> <menuitem action='gal-view-menu'/> - <menuitem action='calendar-go-today'/> - <menuitem action='calendar-jump-to'/> + <menuitem action='calendar-popup-go-today'/> + <menuitem action='calendar-popup-jump-to'/> </popup> <popup name='calendar-event-popup'> - <menuitem action='event-open'/> - <menuitem action='event-save-as'/> - <menuitem action='event-print'/> - <separator/> - <menuitem action='event-clipboard-cut'/> - <menuitem action='event-clipboard-copy'/> - <menuitem action='event-clipboard-paste'/> - <separator/> - <menuitem action='event-copy'/> - <menuitem action='event-move'/> - <menuitem action='event-delegate'/> - <menuitem action='event-schedule'/> - <menuitem action='event-forward'/> - <menuitem action='event-reply'/> - <menuitem action='event-reply-all'/> - <separator/> - <menuitem action='event-occurrence-movable'/> - <menuitem action='event-delete'/> - <menuitem action='event-delete-occurrence'/> - <menuitem action='event-delete-occurrence-all'/> + <menuitem action='event-popup-open'/> + <menuitem action='event-popup-save-as'/> + <menuitem action='event-popup-print'/> + <separator/> + <menuitem action='event-popup-clipboard-cut'/> + <menuitem action='event-popup-clipboard-copy'/> + <menuitem action='event-popup-clipboard-paste'/> + <separator/> + <menuitem action='event-popup-copy'/> + <menuitem action='event-popup-move'/> + <menuitem action='event-popup-delegate'/> + <menuitem action='event-popup-schedule'/> + <menuitem action='event-popup-forward'/> + <menuitem action='event-popup-reply'/> + <menuitem action='event-popup-reply-all'/> + <separator/> + <menuitem action='event-popup-occurrence-movable'/> + <menuitem action='event-popup-delete'/> + <menuitem action='event-popup-delete-occurrence'/> + <menuitem action='event-popup-delete-occurrence-all'/> </popup> <popup name='calendar-memopad-popup'> <menuitem action='calendar-memopad-new'/> diff --git a/ui/evolution-contacts.ui b/ui/evolution-contacts.ui index 0b221c8743..6d42ee0ae2 100644 --- a/ui/evolution-contacts.ui +++ b/ui/evolution-contacts.ui @@ -49,7 +49,7 @@ </toolbar> <popup name='address-book-popup'> <menuitem action='address-book-new'/> - <menuitem action='address-book-rename'/> + <menuitem action='address-book-popup-rename'/> <menuitem action='address-book-popup-save-as'/> <separator/> <menuitem action='address-book-popup-delete'/> @@ -57,23 +57,23 @@ <menuitem action='address-book-popup-properties'/> </popup> <popup name='contact-popup'> - <menuitem action='contact-open'/> + <menuitem action='contact-popup-open'/> <separator/> <menuitem action='contact-new'/> <menuitem action='contact-new-list'/> <separator/> - <menuitem action='contact-save-as'/> - <menuitem action='contact-forward'/> - <menuitem action='contact-send-message'/> - <menuitem action='contact-print'/> + <menuitem action='contact-popup-save-as'/> + <menuitem action='contact-popup-forward'/> + <menuitem action='contact-popup-send-message'/> + <menuitem action='contact-popup-print'/> <separator/> - <menuitem action='contact-copy'/> - <menuitem action='contact-move'/> + <menuitem action='contact-popup-copy'/> + <menuitem action='contact-popup-move'/> <separator/> - <menuitem action='contact-clipboard-cut'/> - <menuitem action='contact-clipboard-copy'/> - <menuitem action='contact-clipboard-paste'/> - <menuitem action='contact-delete'/> + <menuitem action='contact-popup-clipboard-cut'/> + <menuitem action='contact-popup-clipboard-copy'/> + <menuitem action='contact-popup-clipboard-paste'/> + <menuitem action='contact-popup-delete'/> </popup> <popup name='contact-search-options'> <menuitem action='contact-search-name-contains'/> diff --git a/ui/evolution-mail-reader.ui b/ui/evolution-mail-reader.ui index a14db5090d..55e7ee56db 100644 --- a/ui/evolution-mail-reader.ui +++ b/ui/evolution-mail-reader.ui @@ -22,6 +22,7 @@ </placeholder> </menu> <menu action='view-menu'> + <separator/> <placeholder name='mail-message-list-actions'/> <separator/> <placeholder name='mail-message-view-actions'> @@ -124,17 +125,18 @@ </placeholder> </toolbar> <popup name='mail-message-popup'> - <menuitem action='mail-reply-sender'/> - <menuitem action='mail-reply-all'/> - <menuitem action='mail-forward'/> + <menuitem action='mail-popup-reply-sender'/> + <menuitem action='mail-popup-reply-all'/> + <menuitem action='mail-popup-forward'/> <separator/> - <menuitem action='mail-message-edit'/> - <menuitem action='mail-save-as'/> - <menuitem action='mail-print'/> + <menuitem action='mail-popup-message-edit'/> + <menuitem action='mail-popup-save-as'/> + <menuitem action='mail-popup-print'/> <separator/> - <menuitem action='mail-delete'/> - <menuitem action='mail-copy'/> - <menuitem action='mail-move'/> + <menuitem action='mail-popup-delete'/> + <menuitem action='mail-popup-undelete'/> + <menuitem action='mail-popup-copy'/> + <menuitem action='mail-popup-move'/> <separator/> <menuitem action='mail-popup-mark-read'/> <menuitem action='mail-popup-mark-unread'/> diff --git a/ui/evolution-mail.ui b/ui/evolution-mail.ui index cc5a4d348c..5369802139 100644 --- a/ui/evolution-mail.ui +++ b/ui/evolution-mail.ui @@ -21,6 +21,7 @@ <menuitem action='mail-view-vertical'/> </menu> </placeholder> + <separator/> <placeholder name='mail-message-list-actions'> <menuitem action='mail-threads-group-by'/> <menuitem action='mail-threads-expand-all'/> @@ -75,9 +76,9 @@ <separator/> <menuitem action='mail-popup-folder-rename'/> <menuitem action='mail-popup-folder-refresh'/> - <menuitem action='mail-flush-outbox'/> - <menuitem action='mail-empty-trash'/> - <menuitem action='mail-account-disable'/> + <menuitem action='mail-popup-flush-outbox'/> + <menuitem action='mail-popup-empty-trash'/> + <menuitem action='mail-popup-account-disable'/> <separator/> <menuitem action='mail-popup-folder-properties'/> </popup> diff --git a/ui/evolution-memos.ui b/ui/evolution-memos.ui index 73775dc371..28abc7e997 100644 --- a/ui/evolution-memos.ui +++ b/ui/evolution-memos.ui @@ -35,28 +35,28 @@ <popup name='memo-popup'> <menuitem action='memo-new'/> <separator/> - <menuitem action='memo-open'/> - <menuitem action='memo-open-url'/> - <menuitem action='memo-save-as'/> - <menuitem action='memo-print'/> + <menuitem action='memo-popup-open'/> + <menuitem action='memo-popup-open-url'/> + <menuitem action='memo-popup-save-as'/> + <menuitem action='memo-popup-print'/> <separator/> - <menuitem action='memo-clipboard-cut'/> - <menuitem action='memo-clipboard-copy'/> - <menuitem action='memo-clipboard-paste'/> + <menuitem action='memo-popup-clipboard-cut'/> + <menuitem action='memo-popup-clipboard-copy'/> + <menuitem action='memo-popup-clipboard-paste'/> <separator/> - <menuitem action='memo-forward'/> + <menuitem action='memo-popup-forward'/> <separator/> - <menuitem action='memo-delete'/> + <menuitem action='memo-popup-delete'/> </popup> <popup name='memo-list-popup'> <menuitem action='memo-list-new'/> - <menuitem action='memo-list-copy'/> - <menuitem action='memo-list-rename'/> + <menuitem action='memo-list-popup-copy'/> + <menuitem action='memo-list-popup-rename'/> <separator/> - <menuitem action='memo-list-delete'/> - <menuitem action='memo-list-select-one'/> + <menuitem action='memo-list-popup-delete'/> + <menuitem action='memo-list-popup-select-one'/> <separator/> - <menuitem action='memo-list-properties'/> + <menuitem action='memo-list-popup-properties'/> </popup> <popup name='memo-search-options'> <menuitem action='memo-search-summary-contains'/> diff --git a/ui/evolution-tasks.ui b/ui/evolution-tasks.ui index 8b1ea89c9d..073f7d450a 100644 --- a/ui/evolution-tasks.ui +++ b/ui/evolution-tasks.ui @@ -43,31 +43,31 @@ <popup name='task-popup'> <menuitem action='task-new'/> <separator/> - <menuitem action='task-open'/> - <menuitem action='task-open-url'/> - <menuitem action='task-save-as'/> - <menuitem action='task-print'/> + <menuitem action='task-popup-open'/> + <menuitem action='task-popup-open-url'/> + <menuitem action='task-popup-save-as'/> + <menuitem action='task-popup-print'/> <separator/> - <menuitem action='task-clipboard-cut'/> - <menuitem action='task-clipboard-copy'/> - <menuitem action='task-clipboard-paste'/> + <menuitem action='task-popup-clipboard-cut'/> + <menuitem action='task-popup-clipboard-copy'/> + <menuitem action='task-popup-clipboard-paste'/> <separator/> - <menuitem action='task-assign'/> - <menuitem action='task-forward'/> - <menuitem action='task-mark-complete'/> - <menuitem action='task-mark-incomplete'/> + <menuitem action='task-popup-assign'/> + <menuitem action='task-popup-forward'/> + <menuitem action='task-popup-mark-complete'/> + <menuitem action='task-popup-mark-incomplete'/> <separator/> - <menuitem action='task-delete'/> + <menuitem action='task-popup-delete'/> </popup> <popup name='task-list-popup'> <menuitem action='task-list-new'/> - <menuitem action='task-list-copy'/> - <menuitem action='task-list-rename'/> + <menuitem action='task-list-popup-copy'/> + <menuitem action='task-list-popup-rename'/> <separator/> - <menuitem action='task-list-delete'/> - <menuitem action='task-list-select-one'/> + <menuitem action='task-list-popup-delete'/> + <menuitem action='task-list-popup-select-one'/> <separator/> - <menuitem action='task-list-properties'/> + <menuitem action='task-list-popup-properties'/> </popup> <popup name='task-search-options'> <menuitem action='task-search-summary-contains'/> diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am index e5ddeecc06..ce702ec9fd 100644 --- a/widgets/misc/Makefile.am +++ b/widgets/misc/Makefile.am @@ -57,6 +57,7 @@ widgetsinclude_HEADERS = \ e-image-chooser.h \ e-map.h \ e-menu-tool-button.h \ + e-popup-action.h \ e-preferences-window.h \ e-online-button.h \ e-search-bar.h \ @@ -103,6 +104,7 @@ libemiscwidgets_la_SOURCES = \ e-image-chooser.c \ e-map.c \ e-menu-tool-button.c \ + e-popup-action.c \ e-preferences-window.c \ e-online-button.c \ e-search-bar.c \ diff --git a/widgets/misc/e-popup-action.c b/widgets/misc/e-popup-action.c new file mode 100644 index 0000000000..51abc01338 --- /dev/null +++ b/widgets/misc/e-popup-action.c @@ -0,0 +1,285 @@ +/* + * e-popup-action.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-popup-action.h" + +#include <glib/gi18n.h> +#include "e-util/e-binding.h" + +#define E_POPUP_ACTION_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_POPUP_ACTION, EPopupActionPrivate)) + +enum { + PROP_0, + PROP_SOURCE +}; + +struct _EPopupActionPrivate { + GtkAction *source; +}; + +static gpointer parent_class; + +static void +popup_action_set_source (EPopupAction *popup_action, + GtkAction *source) +{ + g_return_if_fail (popup_action->priv->source == NULL); + g_return_if_fail (GTK_IS_ACTION (source)); + + popup_action->priv->source = g_object_ref (source); +} + +static void +popup_action_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SOURCE: + popup_action_set_source ( + E_POPUP_ACTION (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +popup_action_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SOURCE: + g_value_set_object ( + value, e_popup_action_get_source ( + E_POPUP_ACTION (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +popup_action_dispose (GObject *object) +{ + EPopupActionPrivate *priv; + + priv = E_POPUP_ACTION_GET_PRIVATE (object); + + if (priv->source != NULL) { + g_object_unref (priv->source); + priv->source = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +popup_action_constructed (GObject *object) +{ + EPopupActionPrivate *priv; + GObject *source; + gchar *icon_name; + gchar *label; + gchar *stock_id; + gchar *tooltip; + + priv = E_POPUP_ACTION_GET_PRIVATE (object); + + source = G_OBJECT (priv->source); + + g_object_get ( + object, "icon-name", &icon_name, "label", &label, + "stock-id", &stock_id, "tooltip", &tooltip, NULL); + + if (label == NULL) + e_binding_new (source, "label", object, "label"); + + if (tooltip == NULL) + e_binding_new (source, "tooltip", object, "tooltip"); + + if (icon_name == NULL && stock_id == NULL) { + g_free (icon_name); + g_free (stock_id); + + g_object_get ( + source, "icon-name", &icon_name, + "stock-id", &stock_id, NULL); + + if (icon_name == NULL) { + e_binding_new ( + source, "icon-name", object, "icon-name"); + e_binding_new ( + source, "stock-id", object, "stock-id"); + } else { + e_binding_new ( + source, "stock-id", object, "stock-id"); + e_binding_new ( + source, "icon-name", object, "icon-name"); + } + } + + e_binding_new (source, "sensitive", object, "visible"); + + g_free (icon_name); + g_free (label); + g_free (stock_id); + g_free (tooltip); +} + +static void +popup_action_class_init (EPopupActionClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EPopupActionPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = popup_action_set_property; + object_class->get_property = popup_action_get_property; + object_class->dispose = popup_action_dispose; + + g_object_class_install_property ( + object_class, + PROP_SOURCE, + g_param_spec_object ( + "source", + _("Source Action"), + _("The source action to proxy"), + GTK_TYPE_ACTION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +popup_action_init (EPopupAction *popup_action) +{ + popup_action->priv = E_POPUP_ACTION_GET_PRIVATE (popup_action); +} + +GType +e_popup_action_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EPopupActionClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) popup_action_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EPopupAction), + 0, /* n_preallocs */ + (GInstanceInitFunc) popup_action_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_ACTION, "EPopupAction", &type_info, 0); + } + + return type; +} + +EPopupAction * +e_popup_action_new (const gchar *name, + const gchar *label, + GtkAction *source) +{ + EPopupAction *popup_action; + + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (GTK_IS_ACTION (source), NULL); + + popup_action = g_object_new ( + E_TYPE_POPUP_ACTION, "name", name, + "label", label, "source", source, NULL); + + /* XXX This is a hack to work around the fact that GtkAction's + * "label" and "tooltip" properties are not constructor + * properties, even though they're supplied upfront. + * + * See: http://bugzilla.gnome.org/show_bug.cgi?id=568334 */ + popup_action_constructed (G_OBJECT (popup_action)); + + return popup_action; +} + +GtkAction * +e_popup_action_get_source (EPopupAction *popup_action) +{ + g_return_val_if_fail (E_IS_POPUP_ACTION (popup_action), NULL); + + return popup_action->priv->source; +} + +void +e_action_group_add_popup_actions (GtkActionGroup *action_group, + const EPopupActionEntry *entries, + guint n_entries) +{ + guint ii; + + g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); + + for (ii = 0; ii < n_entries; ii++) { + EPopupAction *popup_action; + GtkAction *source; + const gchar *label; + + label = gtk_action_group_translate_string ( + action_group, entries[ii].label); + + source = gtk_action_group_get_action ( + action_group, entries[ii].source); + + if (source == NULL) { + g_warning ( + "Source action '%s' not found in " + "action group '%s'", entries[ii].source, + gtk_action_group_get_name (action_group)); + continue; + } + + popup_action = e_popup_action_new ( + entries[ii].name, label, source); + + g_signal_connect_swapped ( + popup_action, "activate", + G_CALLBACK (gtk_action_activate), + popup_action->priv->source); + + gtk_action_group_add_action ( + action_group, GTK_ACTION (popup_action)); + + g_object_unref (popup_action); + } +} diff --git a/widgets/misc/e-popup-action.h b/widgets/misc/e-popup-action.h new file mode 100644 index 0000000000..6000b5a6ec --- /dev/null +++ b/widgets/misc/e-popup-action.h @@ -0,0 +1,95 @@ +/* + * e-popup-action.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +/* A popup action is an action that lives in a popup menu. It proxies an + * equivalent action in the main menu, with two differences: + * + * 1) If the main menu action is insensitive, the popup action is invisible. + * 2) The popup action may have a different label than the main menu action. + * + * To use: + * + * Create an array of EPopupActionEntry structs. Add the main menu actions + * that serve as "sources" for the popup actions to an action group first. + * Then pass the same action group and the EPopupActionEntry array to + * e_action_group_add_popup_actions() to add popup actions. + */ + +#ifndef E_POPUP_ACTION_H +#define E_POPUP_ACTION_H + +#include <gtk/gtk.h> + +/* Standard GObject macros */ +#define E_TYPE_POPUP_ACTION \ + (e_popup_action_get_type ()) +#define E_POPUP_ACTION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_POPUP_ACTION, EPopupAction)) +#define E_POPUP_ACTION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_POPUP_ACTION, EPopupActionClass)) +#define E_IS_POPUP_ACTION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_POPUP_ACTION)) +#define E_IS_POPUP_ACTION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_POPUP_ACTION)) +#define E_POPUP_ACTION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_POPUP_ACTION, EPopupActionClass)) + +G_BEGIN_DECLS + +typedef struct _EPopupAction EPopupAction; +typedef struct _EPopupActionClass EPopupActionClass; +typedef struct _EPopupActionPrivate EPopupActionPrivate; +typedef struct _EPopupActionEntry EPopupActionEntry; + +struct _EPopupAction { + GtkAction parent; + EPopupActionPrivate *priv; +}; + +struct _EPopupActionClass { + GtkActionClass parent_class; +}; + +struct _EPopupActionEntry { + const gchar *name; + const gchar *label; /* optional: overrides the source action */ + const gchar *source; /* name of the source action */ +}; + +GType e_popup_action_get_type (void); +EPopupAction * e_popup_action_new (const gchar *name, + const gchar *label, + GtkAction *source); +GtkAction * e_popup_action_get_source (EPopupAction *popup_action); + +void e_action_group_add_popup_actions + (GtkActionGroup *action_group, + const EPopupActionEntry *entries, + guint n_entries); + +G_END_DECLS + +#endif /* E_POPUP_ACTION_H */ |