Skip to content

Commit

Permalink
Merge pull request #9601 from keymanapp/fix/linux/9600_snapFirefox
Browse files Browse the repository at this point in the history
fix(linux): Correctly open files linked from help page
  • Loading branch information
ermshiperete authored Sep 21, 2023
2 parents 82d15b6 + b764a1c commit b7314f1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions linux/keyman-config/keyman_config/welcome.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3

import logging
import os
import webbrowser

import gi
Expand Down Expand Up @@ -55,17 +56,25 @@ def __init__(self, parent, welcomeurl, keyboardname, newlyInstalled=False):
def doc_policy(self, web_view, decision, decision_type):
logging.info("Checking policy")
logging.debug("received policy decision request of type: {0}".format(decision_type.value_name))
if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION or \
decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION:
if decision_type in [
WebKit2.PolicyDecisionType.NAVIGATION_ACTION,
WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION,
]:
nav_action = decision.get_navigation_action()
request = nav_action.get_request()
uri = request.get_uri()
logging.debug("nav request is for uri %s", uri)
if "welcome.htm" not in uri:
logging.debug("opening uri %s in webbrowser")
if not uri.startswith("file://"):
logging.debug("opening external uri %s in webbrowser", uri)
webbrowser.open(uri)
decision.ignore()
return True
elif ".htm" not in uri:
cmd = f'xdg-open {uri}'
logging.debug('opening uri in default app: %s', cmd)
os.system(cmd)
decision.ignore()
return True
return False

def on_openweb_clicked(self, button):
Expand Down

0 comments on commit b7314f1

Please sign in to comment.