aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@igalia.com>2012-12-10 22:21:19 +0800
committerDiego Escalante Urrelo <diegoe@gnome.org>2013-01-05 04:38:52 +0800
commit997b046b63c66566561402cfafc6d0a25322a02b (patch)
tree0eb889cdad3f269576e07e924f7ade15aa5bb990 /src
parent6f0ffa44c1bca2927e3e1a337fa1ce7349bd0e66 (diff)
downloadgsoc2013-epiphany-997b046b63c66566561402cfafc6d0a25322a02b.tar.gz
gsoc2013-epiphany-997b046b63c66566561402cfafc6d0a25322a02b.tar.zst
gsoc2013-epiphany-997b046b63c66566561402cfafc6d0a25322a02b.zip
e-window: add a smarter CopyEmailAddress action
It omits the mailto: in mail links and has a different string in the context menu, to make this clear. https://bugzilla.gnome.org/show_bug.cgi?id=688166
Diffstat (limited to 'src')
-rw-r--r--src/ephy-window.c24
-rw-r--r--src/popup-commands.c4
-rw-r--r--src/resources/epiphany-ui.xml1
3 files changed, 27 insertions, 2 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index adb7e956d..4b4598976 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -240,6 +240,8 @@ static const GtkActionEntry ephy_popups_entries [] = {
NULL, NULL, G_CALLBACK (popup_cmd_bookmark_link) },
{ "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
NULL, G_CALLBACK (popup_cmd_copy_link_address) },
+ { "CopyEmailAddress", NULL, N_("_Copy E-mail Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_link_address) },
/* Images. */
@@ -1920,8 +1922,17 @@ populate_context_menu (WebKitWebView *web_view,
add_action_to_context_menu (context_menu,
priv->popups_action_group, "BookmarkLink");
}
- add_action_to_context_menu (context_menu,
- priv->popups_action_group, "CopyLinkAddress");
+
+ if (g_str_has_prefix (uri, "mailto:"))
+ {
+ add_action_to_context_menu (context_menu,
+ priv->popups_action_group, "CopyEmailAddress");
+ }
+ else
+ {
+ add_action_to_context_menu (context_menu,
+ priv->popups_action_group, "CopyLinkAddress");
+ }
}
else if (webkit_hit_test_result_context_is_editable (hit_test_result))
{
@@ -2021,6 +2032,7 @@ show_embed_popup (EphyWindow *window,
guint context;
const char *popup;
gboolean can_open_in_new;
+ gboolean mailto;
GtkWidget *widget;
guint button;
char *uri;
@@ -2028,6 +2040,7 @@ show_embed_popup (EphyWindow *window,
g_object_get (hit_test_result, "link-uri", &uri, NULL);
can_open_in_new = uri && ephy_embed_utils_address_has_web_scheme (uri);
+ mailto = g_str_has_prefix (uri, "mailto:");
g_free (uri);
g_object_get (hit_test_result, "context", &context, NULL);
@@ -2036,6 +2049,13 @@ show_embed_popup (EphyWindow *window,
if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (priv->popups_action_group, "CopyEmailAddress");
+ gtk_action_set_visible (action, mailto);
+ action = gtk_action_group_get_action (priv->popups_action_group, "CopyLinkAddress");
+ gtk_action_set_visible (action, !mailto);
+
popup = "/EphyLinkPopup";
update_edit_actions_sensitivity (window, TRUE);
}
diff --git a/src/popup-commands.c b/src/popup-commands.c
index c9177886c..0380e86d4 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -204,6 +204,10 @@ popup_cmd_copy_link_address (GtkAction *action,
{
ephy_embed_event_get_property (event, "link-uri", &value);
address = g_value_get_string (&value);
+
+ if (g_str_has_prefix (address, "mailto:"))
+ address = address + 7;
+
popup_cmd_copy_to_clipboard (window, address);
g_value_unset (&value);
}
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
index 4afa856fe..976dddce4 100644
--- a/src/resources/epiphany-ui.xml
+++ b/src/resources/epiphany-ui.xml
@@ -49,6 +49,7 @@
<menuitem name="DownloadLinkAsLP" action="DownloadLinkAs"/>
<menuitem name="BookmarkLinkLP" action="BookmarkLink"/>
<menuitem name="CopyLinkAddressLP" action="CopyLinkAddress"/>
+ <menuitem name="CopyEmailAddressLP" action="CopyEmailAddress"/>
<separator />
<menuitem name="OpenImageLP" action="OpenImage"/>
<menuitem name="SaveImageAsLP" action="SaveImageAs"/>