diff options
-rw-r--r-- | mail/e-mail-browser.c | 94 | ||||
-rw-r--r-- | mail/e-mail-browser.h | 2 | ||||
-rw-r--r-- | ui/evolution-mail-reader.ui | 4 | ||||
-rw-r--r-- | ui/evolution-shell.ui | 12 | ||||
-rw-r--r-- | widgets/misc/e-focus-tracker.c | 31 |
5 files changed, 138 insertions, 5 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index b0172ad3c2..59c09b6039 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -29,6 +29,7 @@ #include "e-util/e-plugin-ui.h" #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" +#include "widgets/misc/e-popup-action.h" #include "widgets/misc/e-preview-pane.h" #include "mail/e-mail-reader.h" @@ -45,6 +46,7 @@ struct _EMailBrowserPrivate { GtkUIManager *ui_manager; + EFocusTracker *focus_tracker; EShellBackend *shell_backend; GtkActionGroup *action_group; EMFormatHTMLDisplay *html_display; @@ -60,6 +62,7 @@ struct _EMailBrowserPrivate { enum { PROP_0, + PROP_FOCUS_TRACKER, PROP_SHELL_BACKEND, PROP_SHOW_DELETED, PROP_UI_MANAGER @@ -78,6 +81,15 @@ static const gchar *ui = " <separator/>" " <menuitem action='close'/>" " </menu>" +" <menu action='edit-menu'>" +" <placeholder name='selection-actions'>" +" <menuitem action='cut-clipboard'/>" +" <menuitem action='copy-clipboard'/>" +" <menuitem action='paste-clipboard'/>" +" <separator/>" +" <menuitem action='select-all'/>" +" </placeholder>" +" </menu>" " </menubar>" "</ui>"; @@ -97,6 +109,34 @@ static GtkActionEntry mail_browser_entries[] = { N_("Close this window"), G_CALLBACK (action_close_cb) }, + { "copy-clipboard", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy the selection"), + NULL }, /* Handled by EFocusTracker */ + + { "cut-clipboard", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut the selection"), + NULL }, /* Handled by EFocusTracker */ + + { "paste-clipboard", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste the clipboard"), + NULL }, /* Handled by EFocusTracker */ + + { "select-all", + GTK_STOCK_SELECT_ALL, + NULL, + NULL, + N_("Select all text"), + NULL }, /* Handled by EFocusTracker */ + /*** Menus ***/ { "file-menu", @@ -121,6 +161,13 @@ static GtkActionEntry mail_browser_entries[] = { NULL } }; +static EPopupActionEntry mail_browser_popup_entries[] = { + + { "popup-copy-clipboard", + NULL, + "copy-clipboard" } +}; + static void mail_browser_menu_item_select_cb (EMailBrowser *browser, GtkWidget *widget) @@ -302,6 +349,12 @@ mail_browser_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_FOCUS_TRACKER: + g_value_set_object ( + value, e_mail_browser_get_focus_tracker ( + E_MAIL_BROWSER (object))); + return; + case PROP_SHELL_BACKEND: g_value_set_object ( value, e_mail_reader_get_shell_backend ( @@ -336,6 +389,11 @@ mail_browser_dispose (GObject *object) priv->ui_manager = NULL; } + if (priv->focus_tracker != NULL) { + g_object_unref (priv->focus_tracker); + priv->focus_tracker = NULL; + } + if (priv->shell_backend != NULL) { g_object_unref (priv->shell_backend); priv->shell_backend = NULL; @@ -388,10 +446,12 @@ mail_browser_constructed (GObject *object) EMailReader *reader; EShellBackend *shell_backend; EShell *shell; + EFocusTracker *focus_tracker; ESearchBar *search_bar; GConfBridge *bridge; GtkAccelGroup *accel_group; GtkActionGroup *action_group; + GtkAction *action; GtkUIManager *ui_manager; GtkWidget *container; GtkWidget *widget; @@ -440,6 +500,9 @@ mail_browser_constructed (GObject *object) gtk_action_group_add_actions ( action_group, mail_browser_entries, G_N_ELEMENTS (mail_browser_entries), object); + e_action_group_add_popup_actions ( + action_group, mail_browser_popup_entries, + G_N_ELEMENTS (mail_browser_popup_entries)); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); e_load_ui_manager_definition (ui_manager, E_MAIL_READER_UI_DEFINITION); @@ -455,6 +518,19 @@ mail_browser_constructed (GObject *object) ui_manager, "connect-proxy", G_CALLBACK (mail_browser_connect_proxy_cb), object); + /* Configure an EFocusTracker to manage selection actions. */ + + focus_tracker = e_focus_tracker_new (GTK_WINDOW (object)); + action = gtk_action_group_get_action (action_group, "cut-clipboard"); + e_focus_tracker_set_cut_clipboard_action (focus_tracker, action); + action = gtk_action_group_get_action (action_group, "copy-clipboard"); + e_focus_tracker_set_copy_clipboard_action (focus_tracker, action); + action = gtk_action_group_get_action (action_group, "paste-clipboard"); + e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); + action = gtk_action_group_get_action (action_group, "select-all"); + e_focus_tracker_set_select_all_action (focus_tracker, action); + priv->focus_tracker = focus_tracker; + /* Construct window widgets. */ widget = gtk_vbox_new (FALSE, 0); @@ -647,6 +723,16 @@ mail_browser_class_init (EMailBrowserClass *class) g_object_class_install_property ( object_class, + PROP_FOCUS_TRACKER, + g_param_spec_object ( + "focus-tracker", + _("Focus Tracker"), + NULL, + E_TYPE_FOCUS_TRACKER, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, PROP_SHELL_BACKEND, g_param_spec_object ( "shell-backend", @@ -772,6 +858,14 @@ e_mail_browser_set_show_deleted (EMailBrowser *browser, g_object_notify (G_OBJECT (browser), "show-deleted"); } +EFocusTracker * +e_mail_browser_get_focus_tracker (EMailBrowser *browser) +{ + g_return_val_if_fail (E_IS_MAIL_BROWSER (browser), NULL); + + return browser->priv->focus_tracker; +} + GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser) { diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h index f2fd4d9131..e097691bef 100644 --- a/mail/e-mail-browser.h +++ b/mail/e-mail-browser.h @@ -23,6 +23,7 @@ #define E_MAIL_BROWSER_H #include <gtk/gtk.h> +#include <misc/e-focus-tracker.h> #include <shell/e-shell-backend.h> /* Standard GObject macros */ @@ -65,6 +66,7 @@ void e_mail_browser_close (EMailBrowser *browser); gboolean e_mail_browser_get_show_deleted (EMailBrowser *browser); void e_mail_browser_set_show_deleted (EMailBrowser *browser, gboolean show_deleted); +EFocusTracker * e_mail_browser_get_focus_tracker(EMailBrowser *browser); GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser); G_END_DECLS diff --git a/ui/evolution-mail-reader.ui b/ui/evolution-mail-reader.ui index b54f4b970e..dc87cf08e5 100644 --- a/ui/evolution-mail-reader.ui +++ b/ui/evolution-mail-reader.ui @@ -10,6 +10,8 @@ </placeholder> </menu> <menu action='edit-menu'> + <placeholder name='selection-actions'/> + <separator/> <placeholder name='edit-actions'> <menuitem action='mail-delete'/> <menuitem action='mail-undelete'/> @@ -141,6 +143,8 @@ </placeholder> </popup> <popup name='mail-preview-popup'> + <menuitem action='popup-copy-clipboard'/> + <separator/> <menuitem action='mail-popup-reply-sender'/> <menuitem action='mail-popup-reply-all'/> <menuitem action='mail-popup-forward'/> diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui index 654d322f60..fab9255989 100644 --- a/ui/evolution-shell.ui +++ b/ui/evolution-shell.ui @@ -20,11 +20,13 @@ <menuitem action='quit'/> </menu> <menu action='edit-menu'> - <menuitem action='cut-clipboard'/> - <menuitem action='copy-clipboard'/> - <menuitem action='paste-clipboard'/> - <separator/> - <menuitem action='select-all'/> + <placeholder name='selection-actions'> + <menuitem action='cut-clipboard'/> + <menuitem action='copy-clipboard'/> + <menuitem action='paste-clipboard'/> + <separator/> + <menuitem action='select-all'/> + </placeholder> <separator/> <placeholder name='edit-actions'/> <separator/> diff --git a/widgets/misc/e-focus-tracker.c b/widgets/misc/e-focus-tracker.c index 8eb1b25d56..882b54726c 100644 --- a/widgets/misc/e-focus-tracker.c +++ b/widgets/misc/e-focus-tracker.c @@ -532,7 +532,38 @@ focus_tracker_class_init (EFocusTrackerClass *class) static void focus_tracker_init (EFocusTracker *focus_tracker) { + GtkAction *action; + focus_tracker->priv = E_FOCUS_TRACKER_GET_PRIVATE (focus_tracker); + + /* Define dummy actions. These will most likely be overridden, + * but for cases where they're not it ensures ESelectable objects + * will always get a valid GtkAction when they ask us for one. */ + + action = gtk_action_new ( + "cut-clipboard", NULL, + _("Cut the selection"), GTK_STOCK_CUT); + focus_tracker->priv->cut_clipboard = action; + + action = gtk_action_new ( + "copy-clipboard", NULL, + _("Copy the selection"), GTK_STOCK_COPY); + focus_tracker->priv->copy_clipboard = action; + + action = gtk_action_new ( + "paste-clipboard", NULL, + _("Paste the clipboard"), GTK_STOCK_PASTE); + focus_tracker->priv->paste_clipboard = action; + + action = gtk_action_new ( + "delete-selection", NULL, + _("Delete the selection"), GTK_STOCK_DELETE); + focus_tracker->priv->delete_selection = action; + + action = gtk_action_new ( + "select-all", NULL, + _("Select all text"), GTK_STOCK_SELECT_ALL); + focus_tracker->priv->select_all = action; } GType |