Skip to content

Commit

Permalink
Do not open new windows for internal _blank links
Browse files Browse the repository at this point in the history
In general, the desktop app should work in a single window.

Closes #7
  • Loading branch information
dylanmccall committed Aug 15, 2020
1 parent d693d3e commit bf70bc1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/kolibri_gnome/desktop_launcher/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def __init__(self, *args, **kwargs):

def show(self):
# TODO: Implement this in pyeverywhere
self.gtk_webview.connect('decide-policy', self.__gtk_webview_on_decide_policy)
self.gtk_webview.connect("create", self.__gtk_webview_on_create)

# Maximize windows on Endless OS
Expand All @@ -228,6 +229,17 @@ def show(self):

super().show()

def __gtk_webview_on_decide_policy(self, webview, decision, decision_type):
if decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION:
# Force internal _blank links to open in the same window
target_uri = decision.get_request().get_uri()
frame_name = decision.get_frame_name()
if frame_name == '_blank' and self.delegate.is_kolibri_app_url(target_uri):
decision.ignore()
pew.ui.run_on_main_thread(self.load_url, target_uri)
return True
return False

def __gtk_webview_on_create(self, webview, navigation_action):
# TODO: Implement this behaviour in pyeverywhere, and pass the related
# webview to the new window so it can use
Expand Down

0 comments on commit bf70bc1

Please sign in to comment.