diff --git a/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py b/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py index 832b965..a82f925 100644 --- a/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py +++ b/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py @@ -3,7 +3,8 @@ # @date 2023/08/08 14:07:26 -import gi, os, sys, json, shutil, hashlib, random +import gi, os, sys, json +import webbrowser, shutil, hashlib, random gi.require_version('Gtk', '3.0') gi.require_version("WebKit2", "4.1") @@ -288,6 +289,25 @@ class WebEngine(WebKit2.WebView): return (_error, output) + def _shell_handler(self, params = {}): + _error = None + output = None + path = params.get('path') + + match(params.get('action')): + case 'openExternal': + webbrowser.open(params.get('url')) + + case 'showItemInFolder': + os.system(f"xdg-open '{path}'") + + case 'openPath': + os.system(f"xdg-open '{path}'") + + case 'trashItem': + pass + + def _fs_handler(self, params = {}): _error = None diff --git a/usr/lib/python3/dist-packages/webengine/gtk3/inject.js b/usr/lib/python3/dist-packages/webengine/gtk3/inject.js index c508c3d..b5a4827 100644 --- a/usr/lib/python3/dist-packages/webengine/gtk3/inject.js +++ b/usr/lib/python3/dist-packages/webengine/gtk3/inject.js @@ -241,6 +241,12 @@ return native.env.LANG } }, + shell: { + openExternal(url) {}, + showItemInFolder(path) {}, + openPath(path) {}, + trashItem(path) {} + }, fs: { access(filepath, mode = 'r') { return handler('fs', { action: 'access', mode, filepath })