summaryrefslogtreecommitdiffstats
path: root/share/extensions/inkscape_follow_link.py
blob: 426651f9e096146b240d929d073958cae9fbf711 (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
#!/usr/bin/env python
# coding=utf-8

import threading
import webbrowser

import inkex
from inkex import Anchor

class ThreadWebsite(threading.Thread):
    """Visit the website without locking inkscape"""
    def __init__(self, url):
        threading.Thread.__init__(self)
        self.url = url

    def run(self):
        webbrowser.open(self.url)

class FollowLink(inkex.EffectExtension):
    """Get the first selected item and follow it's href/url"""
    def effect(self):
        for node in self.svg.selection.filter(Anchor):
            vwswli = ThreadWebsite(node.get('xlink:href'))
            vwswli.start()
            break

if __name__ == '__main__':
    FollowLink().run()