blob: 9dd6751b8f40da7eba914b23c411ca09df6579a2 (
plain)
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
48
49
50
51
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()
|