diff options
Diffstat (limited to 'ms-office-online')
-rwxr-xr-x | ms-office-online | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ms-office-online b/ms-office-online new file mode 100755 index 000000000000..9dd6751b8f40 --- /dev/null +++ b/ms-office-online @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# coding: utf-8 +try: + from j.AK import Api, AppWindow, settings + +except Exception as err: + print("Ops something went wrong: " + str(err)) + +import os, subprocess +from gi.repository import Gtk, WebKit2 + +def same_frame(): + # open url in same window + return tuple(settings("webkit", "same_frame")) + +class applicationWindow(AppWindow): + """ + extends AK.AppWindow functionality + """ + + def __init__(self): + super(applicationWindow, self).__init__() + def on_decide_policy(webview, decision, decision_type): + """ + :param webview: + :param decision: + :param decision_type: + :return: if is not a predicted url open in separate window. + """ + + def check_Link(url): + + if url.startswith(same_frame()): + self.webview.load_uri(url) + + else: + # use existing office settings.json + os.chdir("/usr/share/ms-office/msoffice/") + # open url in a new window + subprocess.call(["jak", url]) + + if decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION: + url = decision.get_navigation_action().get_request().get_uri() + check_Link(url) + + + self.webview.load_uri(settings("app", "route")) + self.webview.connect("decide-policy", on_decide_policy) + + +applicationWindow() +Gtk.main() |