[evolution] Bug 693154 - Add "Copy raw email address" mailto: context option
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 693154 - Add "Copy raw email address" mailto: context option
- Date: Wed, 15 Apr 2015 17:45:20 +0000 (UTC)
commit 2e5d98cfdecfceea787686bede3ef1dd1a4164b4
Author: Milan Crha <mcrha redhat com>
Date: Wed Apr 15 19:44:26 2015 +0200
Bug 693154 - Add "Copy raw email address" mailto: context option
e-util/e-web-view.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 600eda8..0de5b81 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -120,6 +120,7 @@ static const gchar *ui =
" <placeholder name='custom-actions-2'>"
" <menuitem action='uri-copy'/>"
" <menuitem action='mailto-copy'/>"
+" <menuitem action='mailto-copy-raw'/>"
" <menuitem action='image-copy'/>"
" <menuitem action='image-save'/>"
" </placeholder>"
@@ -181,13 +182,13 @@ action_http_open_cb (GtkAction *action,
}
static void
-action_mailto_copy_cb (GtkAction *action,
- EWebView *web_view)
+webview_mailto_copy (EWebView *web_view,
+ gboolean only_email_address)
{
CamelURL *curl;
CamelInternetAddress *inet_addr;
GtkClipboard *clipboard;
- const gchar *uri;
+ const gchar *uri, *name = NULL, *email = NULL;
gchar *text;
uri = e_web_view_get_selected_uri (web_view);
@@ -199,9 +200,15 @@ action_mailto_copy_cb (GtkAction *action,
inet_addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
- text = camel_address_format (CAMEL_ADDRESS (inet_addr));
- if (text == NULL || *text == '\0')
- text = g_strdup (uri + strlen ("mailto:"));
+ if (only_email_address &&
+ camel_internet_address_get (inet_addr, 0, &name, &email) &&
+ email && *email) {
+ text = g_strdup (email);
+ } else {
+ text = camel_address_format (CAMEL_ADDRESS (inet_addr));
+ if (text == NULL || *text == '\0')
+ text = g_strdup (uri + strlen ("mailto:"));
+ }
g_object_unref (inet_addr);
camel_url_free (curl);
@@ -218,6 +225,20 @@ action_mailto_copy_cb (GtkAction *action,
}
static void
+action_mailto_copy_cb (GtkAction *action,
+ EWebView *web_view)
+{
+ webview_mailto_copy (web_view, FALSE);
+}
+
+static void
+action_mailto_copy_raw_cb (GtkAction *action,
+ EWebView *web_view)
+{
+ webview_mailto_copy (web_view, TRUE);
+}
+
+static void
action_select_all_cb (GtkAction *action,
EWebView *web_view)
{
@@ -307,6 +328,13 @@ static GtkActionEntry mailto_entries[] = {
N_("Copy the email address to the clipboard"),
G_CALLBACK (action_mailto_copy_cb) },
+ { "mailto-copy-raw",
+ "edit-copy",
+ N_("Copy _Raw Email Address"),
+ NULL,
+ N_("Copy the raw email address to the clipboard"),
+ G_CALLBACK (action_mailto_copy_raw_cb) },
+
{ "send-message",
"mail-message-new",
N_("_Send New Message To..."),
@@ -1182,6 +1210,28 @@ web_view_update_actions (EWebView *web_view)
action_group = e_web_view_get_action_group (web_view, group_name);
gtk_action_group_set_visible (action_group, visible);
+ if (visible) {
+ CamelURL *curl;
+
+ curl = camel_url_new (uri, NULL);
+ if (curl) {
+ CamelInternetAddress *inet_addr;
+ const gchar *name = NULL, *email = NULL;
+ GtkAction *action;
+
+ inet_addr = camel_internet_address_new ();
+ camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
+
+ action = gtk_action_group_get_action (action_group, "mailto-copy-raw");
+ gtk_action_set_visible (action,
+ camel_internet_address_get (inet_addr, 0, &name, &email) &&
+ name && *name && email && *email);
+
+ g_object_unref (inet_addr);
+ camel_url_free (curl);
+ }
+ }
+
group_name = "image";
visible = (cursor_image_src != NULL);
action_group = e_web_view_get_action_group (web_view, group_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]