diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-10-28 16:45:06 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-10-28 16:45:06 +0800 |
commit | f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab (patch) | |
tree | d9df6864d5ca1d7ec1d900129980b79d51c5b676 | |
parent | 0d2d45cf9ed4f66b2bda719985c9cf9c3ad2c3d1 (diff) | |
download | gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar.gz gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar.bz2 gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar.lz gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar.xz gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.tar.zst gsoc2013-evolution-f43bc7ed11621ab41bbae861c81d4ddb8b5bb0ab.zip |
Add a menu to the Forward toolbar button.
Allows users to choose different mail forwarding methods without
navigating the main menu. Suggested by Ng Oon-Ee on evolution-list.
-rw-r--r-- | mail/e-mail-reader.c | 62 | ||||
-rw-r--r-- | ui/evolution-mail-reader.ui | 10 | ||||
-rw-r--r-- | widgets/misc/Makefile.am | 2 | ||||
-rw-r--r-- | widgets/misc/e-menu-tool-action.c | 75 | ||||
-rw-r--r-- | widgets/misc/e-menu-tool-action.h | 71 |
5 files changed, 212 insertions, 8 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index c60054b266..a81352ce12 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -36,6 +36,7 @@ #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" #include "widgets/misc/e-popup-action.h" +#include "widgets/misc/e-menu-tool-action.h" #include "mail/e-mail-browser.h" #include "mail/e-mail-display.h" @@ -1175,13 +1176,6 @@ static GtkActionEntry mail_reader_entries[] = { N_("Flag the selected messages for follow-up"), G_CALLBACK (action_mail_flag_for_followup_cb) }, - { "mail-forward", - "mail-forward", - N_("_Forward"), - "<Control>f", - N_("Forward the selected message to someone"), - G_CALLBACK (action_mail_forward_cb) }, - { "mail-forward-attached", NULL, N_("_Attached"), @@ -1189,6 +1183,13 @@ static GtkActionEntry mail_reader_entries[] = { N_("Forward the selected message to someone as an attachment"), G_CALLBACK (action_mail_forward_attached_cb) }, + { "mail-forward-attached-full", + NULL, + N_("Forward As _Attached"), + NULL, + N_("Forward the selected message to someone as an attachment"), + G_CALLBACK (action_mail_forward_attached_cb) }, + { "mail-forward-inline", NULL, N_("_Inline"), @@ -1196,6 +1197,13 @@ static GtkActionEntry mail_reader_entries[] = { N_("Forward the selected message in the body of a new message"), G_CALLBACK (action_mail_forward_inline_cb) }, + { "mail-forward-inline-full", + NULL, + N_("Forward As _Inline"), + NULL, + N_("Forward the selected message in the body of a new message"), + G_CALLBACK (action_mail_forward_inline_cb) }, + { "mail-forward-quoted", NULL, N_("_Quoted"), @@ -1203,6 +1211,13 @@ static GtkActionEntry mail_reader_entries[] = { N_("Forward the selected message quoted like a reply"), G_CALLBACK (action_mail_forward_quoted_cb) }, + { "mail-forward-quoted-full", + NULL, + N_("Forward As _Quoted"), + NULL, + N_("Forward the selected message quoted like a reply"), + G_CALLBACK (action_mail_forward_quoted_cb) }, + { "mail-load-images", "image-x-generic", N_("_Load Images"), @@ -2049,16 +2064,31 @@ mail_reader_update_actions (EMailReader *reader) action = e_mail_reader_get_action (reader, action_name); gtk_action_set_sensitive (action, sensitive); + action_name = "mail-forward-attached-full"; + sensitive = have_an_account && any_messages_selected; + 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-inline-full"; + 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-forward-quoted-full"; + 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); @@ -2312,6 +2342,7 @@ e_mail_reader_init (EMailReader *reader) EShellBackend *shell_backend; EShellSettings *shell_settings; EMFormatHTMLDisplay *html_display; + EMenuToolAction *menu_tool_action; EWebView *web_view; GtkActionGroup *action_group; MessageList *message_list; @@ -2344,6 +2375,23 @@ e_mail_reader_init (EMailReader *reader) mail_reader_init_charset_actions (reader); + /* The "mail-forward" action is special: it uses a GtkMenuToolButton + * for its toolbar item type. So we have to create it separately. */ + + menu_tool_action = e_menu_tool_action_new ( + "mail-forward", _("_Forward"), + _("Forward the selected message to someone"), NULL); + + gtk_action_set_icon_name ( + GTK_ACTION (menu_tool_action), "mail-forward"); + + g_signal_connect ( + menu_tool_action, "activate", + G_CALLBACK (action_mail_forward_cb), reader); + + gtk_action_group_add_action_with_accel ( + action_group, GTK_ACTION (menu_tool_action), "<Control>f"); + /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); diff --git a/ui/evolution-mail-reader.ui b/ui/evolution-mail-reader.ui index 12dea8bf50..1209144486 100644 --- a/ui/evolution-mail-reader.ui +++ b/ui/evolution-mail-reader.ui @@ -112,7 +112,15 @@ <placeholder name='mail-toolbar-common'> <toolitem action='mail-reply-sender'/> <toolitem action='mail-reply-all'/> - <toolitem action='mail-forward'/> + <toolitem action='mail-forward'> + <menu action='mail-forward-as-menu'> + <menuitem action='mail-forward-attached-full'/> + <menuitem action='mail-forward-inline-full'/> + <menuitem action='mail-forward-quoted-full'/> + <separator/> + <menuitem action='mail-redirect'/> + </menu> + </toolitem> <separator/> <toolitem action='mail-print'/> <toolitem action='mail-delete'/> diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am index bf6291a0b2..d98acf3c2a 100644 --- a/widgets/misc/Makefile.am +++ b/widgets/misc/Makefile.am @@ -55,6 +55,7 @@ widgetsinclude_HEADERS = \ e-image-chooser.h \ e-import-assistant.h \ e-map.h \ + e-menu-tool-action.h \ e-menu-tool-button.h \ e-online-button.h \ e-paned.h \ @@ -133,6 +134,7 @@ libemiscwidgets_la_SOURCES = \ e-image-chooser.c \ e-import-assistant.c \ e-map.c \ + e-menu-tool-action.c \ e-menu-tool-button.c \ e-online-button.c \ e-paned.c \ diff --git a/widgets/misc/e-menu-tool-action.c b/widgets/misc/e-menu-tool-action.c new file mode 100644 index 0000000000..2cfe2783db --- /dev/null +++ b/widgets/misc/e-menu-tool-action.c @@ -0,0 +1,75 @@ +/* + * e-menu-tool-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-menu-tool-action.h" + +static gpointer parent_class; + +static void +menu_tool_action_class_init (EMenuToolActionClass *class) +{ + GtkActionClass *action_class; + + parent_class = g_type_class_peek_parent (class); + + action_class = GTK_ACTION_CLASS (class); + action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; +} + +GType +e_menu_tool_action_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMenuToolActionClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) menu_tool_action_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMenuToolAction), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_ACTION, "EMenuToolAction", &type_info, 0); + } + + return type; +} + +EMenuToolAction * +e_menu_tool_action_new (const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *stock_id) +{ + g_return_val_if_fail (name != NULL, NULL); + + return g_object_new ( + E_TYPE_MENU_TOOL_ACTION, + "name", name, "label", label, "tooltip", + tooltip, "stock-id", stock_id, NULL); +} diff --git a/widgets/misc/e-menu-tool-action.h b/widgets/misc/e-menu-tool-action.h new file mode 100644 index 0000000000..e642edf958 --- /dev/null +++ b/widgets/misc/e-menu-tool-action.h @@ -0,0 +1,71 @@ +/* + * e-menu-tool-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) + * + */ + +/* This is a trivial GtkAction subclass that sets the toolbar + * item type to GtkMenuToolButton instead of GtkToolButton. */ + +#ifndef E_MENU_TOOL_ACTION_H +#define E_MENU_TOOL_ACTION_H + +#include <gtk/gtk.h> + +/* Standard GObject macros */ +#define E_TYPE_MENU_TOOL_ACTION \ + (e_menu_tool_action_get_type ()) +#define E_MENU_TOOL_ACTION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolAction)) +#define E_MENU_TOOL_ACTION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass)) +#define E_IS_MENU_TOOL_ACTION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MENU_TOOL_ACTION)) +#define E_IS_MENU_TOOL_ACTION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MENU_TOOL_ACTION)) +#define E_MENU_TOOL_ACTION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass)) + +G_BEGIN_DECLS + +typedef struct _EMenuToolAction EMenuToolAction; +typedef struct _EMenuToolActionClass EMenuToolActionClass; + +struct _EMenuToolAction { + GtkAction parent; +}; + +struct _EMenuToolActionClass { + GtkActionClass parent_class; +}; + +GType e_menu_tool_action_get_type (void); +EMenuToolAction * + e_menu_tool_action_new (const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *stock_id); + +G_END_DECLS + +#endif /* E_MENU_TOOL_ACTION_H */ |