-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.py
47 lines (37 loc) · 1.12 KB
/
maps.py
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
36
37
38
39
40
41
42
43
44
45
46
47
__kupfer_name__ = _("Google Maps")
__kupfer_actions__ = ("GoogleMaps", )
__description__ = _("Search address in gmaps")
__version__ = "2019-3"
__author__ = "thorko"
import http.client
import urllib.parse
from kupfer.obj import Action, TextLeaf
from kupfer import launch, plugin_support, config
_ALTERNATIVES = (
"Google",
)
URLS = {
"Google" : "https://www.google.com/maps/place/",
}
__kupfer_settings__ = plugin_support.PluginSettings(
{
"key": "search_engine",
"label": _("Your search engine"),
"type": str,
"value": "Google",
"alternatives": _ALTERNATIVES,
}
)
class GoogleMaps (Action):
def __init__(self):
Action.__init__(self, _("Maps"))
def activate(self, leaf):
engine = __kupfer_settings__["search_engine"]
query_url = URLS[engine] + "?" + urllib.parse.urlencode({"q": leaf.object})
launch.show_url(query_url)
def item_types(self):
yield TextLeaf
def get_description(self):
return _("Search address with gmaps")
def get_icon_name(self):
return "edit-find"