summaryrefslogtreecommitdiffstats
path: root/share/extensions/inkscape_follow_link.py
blob: bf19cb84f4670d94d776ffc3eb003ba541d76f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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