Ticket #141: linkTypes.py

File linkTypes.py, 1.3 KB (added by norrumar, 13 months ago)

Global plugin for knowing the type of the focused link, in Spanish. It contains a script that can be activated pressing control+shift+a, and reads: Link with anchor (or to a part of the same page), mail link, FTP link or external destination. Messages and documentation in Spanish. Tested on Firefox.

Line 
1
2# Global plugin for knowing the type of focused links, in Spanish
3
4import globalPluginHandler
5import api
6import controlTypes
7import scriptHandler
8import ui
9
10
11class GlobalPlugin(globalPluginHandler.GlobalPlugin):
12
13    def script_typeOfLink(self, gesture):
14        obj=api.getFocusObject()
15        states=obj.states
16        value=obj.value
17        if controlTypes.STATE_LINKED not in states:            return
18        if value.find("#")==0:
19            ui.message("Enlace a documento actual")
20        elif value.find("#")>0:
21            ui.message("Contiene ancla")
22        elif value.find("mailto:")==0:
23            ui.message("Enlace a correo")
24        elif value.find("ftp://")==0:
25            ui.message("Enlace a FTP")
26        else:
27            ui.message("Enlace a destino externo")
28        if scriptHandler.getLastScriptRepeatCount()==1:
29            ui.message(value)
30        elif scriptHandler.getLastScriptRepeatCount()==2 and api.copyToClip(value):
31            ui.message("Ruta copiada al portapapeles")
32
33    script_typeOfLink.__doc__=_("Indica el tipo de enlace que contiene el foco de Windows. Si se pulsa dos veces seguidas, lee la ruta; si se pulsa tres, la copia en el portapapeles")
34
35    __gestures={"kb:control+shift+a": "typeOfLink"}