summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2012-09-20 14:11:29 +0000
committerJazzyNico <nicoduf@yahoo.fr>2012-09-20 14:11:29 +0000
commitd99ebfe27cca750966d0483360394a3039cb365e (patch)
tree8bb647a76b2335f4ba050b354d9e4ffe104fa5da
parentFilters. Typo in the filters menu (bump instead of bumps). (diff)
downloadinkscape-d99ebfe27cca750966d0483360394a3039cb365e.tar.gz
inkscape-d99ebfe27cca750966d0483360394a3039cb365e.zip
Fix for Bug #944787 (The command to follow link does not work).
(bzr r11684)
-rw-r--r--share/extensions/Makefile.am2
-rw-r--r--share/extensions/inkscape_follow_link.inx13
-rw-r--r--share/extensions/inkscape_follow_link.py35
-rw-r--r--src/interface.cpp30
4 files changed, 71 insertions, 9 deletions
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am
index 16c8a2cc2..9a8fa6153 100644
--- a/share/extensions/Makefile.am
+++ b/share/extensions/Makefile.am
@@ -79,6 +79,7 @@ extensions = \
ink2canvas.py \
inkex.py \
Inkscape.pm \
+ inkscape_follow_link.py \
inkwebeffect.py \
interp.py \
interp_att_g.py \
@@ -263,6 +264,7 @@ modules = \
handles.inx \
hpgl_output.inx \
ink2canvas.inx \
+ inkscape_follow_link.inx \
inkscape_help_askaquestion.inx \
inkscape_help_commandline.inx \
inkscape_help_faq.inx\
diff --git a/share/extensions/inkscape_follow_link.inx b/share/extensions/inkscape_follow_link.inx
new file mode 100644
index 000000000..d2ee0a8a1
--- /dev/null
+++ b/share/extensions/inkscape_follow_link.inx
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Follow Link</_name>
+ <id>org.inkscape.followlink</id>
+ <dependency type="executable" location="extensions">inkscape_follow_link.py</dependency>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu hidden="true" />
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">inkscape_follow_link.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/inkscape_follow_link.py b/share/extensions/inkscape_follow_link.py
new file mode 100644
index 000000000..bf19cb84f
--- /dev/null
+++ b/share/extensions/inkscape_follow_link.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import threading
+import webbrowser
+
+import inkex
+
+class VisitWebSiteWithoutLockingInkscape(threading.Thread):
+ def __init__(self, url):
+ threading.Thread.__init__ (self)
+ self.url = url
+
+ def run(self):
+ webbrowser.open(self.url)
+
+class FollowLink(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+
+ def effect(self):
+ if (self.options.ids):
+ for id, node in self.selected.iteritems():
+ if node.tag == inkex.addNS('a','svg'):
+ self.url = node.get(inkex.addNS('href','xlink'))
+ vwswli = VisitWebSiteWithoutLockingInkscape(self.url)
+ vwswli.start()
+ #inkex.errormsg("Link: %s" % self.url)
+ break
+
+
+if __name__ == '__main__':
+ e = FollowLink()
+ e.affect(output=False)
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
diff --git a/src/interface.cpp b/src/interface.cpp
index b10ba3077..710211fe7 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -1766,15 +1766,16 @@ void ContextMenu::MakeItemMenu (void)
AddSeparator();
/* Select item */
- mi = manage(new Gtk::MenuItem(_("_Select This"),1));
- if (_desktop->selection->includes(_item)) {
- mi->set_sensitive(FALSE);
- } else {
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis));
+ if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) {
+ mi = manage(new Gtk::MenuItem(_("_Select This"),1));
+ if (_desktop->selection->includes(_item)) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis));
+ }
+ mi->show();
+ append(*mi);
}
- mi->show();
- append(*mi);
-
mi = manage(new Gtk::MenuItem(_("Select Same")));
@@ -2034,7 +2035,18 @@ void ContextMenu::AnchorLinkProperties(void)
void ContextMenu::AnchorLinkFollow(void)
{
- /* shell out to an external browser here */
+
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+ // Opening the selected links with a python extension
+ Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" );
+ if (verb) {
+ SPAction *action = verb->get_action(_desktop);
+ if (action) {
+ sp_action_perform(action, NULL);
+ }
+ }
}
void ContextMenu::AnchorLinkRemove(void)