Start work on special handling for remote file hyperlinks

This commit is contained in:
Kovid Goyal 2020-09-04 20:05:51 +05:30
parent 399a1f8fee
commit b552173185
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -490,8 +490,29 @@ class Window:
get_boss().child_monitor.set_iutf8_winid(self.id, on)
def open_url(self, url: str, hyperlink_id: int) -> None:
if hyperlink_id:
from urllib.parse import urlparse
try:
purl = urlparse(url)
except Exception:
return
if (not purl.scheme or purl.scheme == 'file'):
if purl.netloc:
from socket import gethostname
try:
hostname = gethostname()
except Exception:
hostname = ''
remote_hostname = purl.netloc.partition(':')[0]
if remote_hostname and remote_hostname != hostname:
self.handle_remote_file(purl.netloc, purl.path)
return
get_boss().open_url(url)
def handle_remote_file(self, netloc: str, remote_path: str) -> None:
pass
def focus_changed(self, focused: bool) -> None:
if self.destroyed:
return