Compare commits

...

2 Commits

6 changed files with 39 additions and 15 deletions

View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import os
home_dir = os.getenv('HOME')
env = {
"HOME_DIR": home_dir,
"CONFIG_DIR": os.path.join(home_dir, '.config'),
"CACHE_DIR": os.path.join(home_dir, '.cache'),
"LANG": os.environ['LANG'] or "en_US.UTF-8"
}

View File

@ -18,6 +18,7 @@ class Inject:
code = open(self.abspath('./inject.js'), 'r').read() code = open(self.abspath('./inject.js'), 'r').read()
frame = WebKit2.UserContentInjectedFrames.ALL_FRAMES frame = WebKit2.UserContentInjectedFrames.ALL_FRAMES
time = WebKit2.UserScriptInjectionTime.END time = WebKit2.UserScriptInjectionTime.END
code = code.replace("'{{env}}'", json.dumps(env)) code = code.replace("'{{env}}'", json.dumps(env))
code = code.replace("{{uuid}}", webview.uuid) code = code.replace("{{uuid}}", webview.uuid)
code = code.replace("{{app_name}}", webview.app_name) code = code.replace("{{app_name}}", webview.app_name)

View File

@ -7,6 +7,9 @@ import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import GdkPixbuf from gi.repository import GdkPixbuf
def noop():
pass
def get_monitor_info(monitor): def get_monitor_info(monitor):
return { return {
"model": monitor.props.model, "model": monitor.props.model,

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
build = (0, 6, 0) build = (0, 6, 1)
version = '.'.join(map(str, build)) version = '.'.join(map(str, build))

View File

@ -31,24 +31,13 @@ try:
except: except:
Keybinder = None Keybinder = None
from ._env import env
from ._version import version from ._version import version
from ._settings import create_setting from ._settings import create_setting
from ._protocal import create_protocal from ._protocal import create_protocal
from ._notify import create_notify from ._notify import create_notify
from ._inject import Inject from ._inject import Inject
from ._utils import get_monitor_info, pixbuf_to_dict, dict_to_pixbuf from ._utils import noop, get_monitor_info, pixbuf_to_dict, dict_to_pixbuf
env = {
"HOME_DIR": os.getenv('HOME'),
"CONFIG_DIR": os.path.join(os.getenv('HOME'), '.config'),
"CACHE_DIR": os.path.join(os.getenv('HOME'), '.cache')
}
def noop():
pass
@ -370,6 +359,9 @@ class WebEngine(WebKit2.WebView):
case 'isdir': case 'isdir':
output = os.path.isdir(filepath) output = os.path.isdir(filepath)
case 'mkdir':
output = os.makedirs(filepath)
return (_error, output) return (_error, output)

View File

@ -103,6 +103,15 @@ function _postMessage(data = {}, uuid = null) {
window.dispatchEvent(ev) window.dispatchEvent(ev)
} }
function readonly(obj, key, value) {
Object.defineProperty(obj, key, {
get() {
return value
},
enumerable: false
})
}
class NativeImage { class NativeImage {
#origin #origin
@ -203,7 +212,7 @@ class EventEmitter {
} }
} }
window.native = new EventEmitter() readonly(window, 'native', new EventEmitter())
native.$on('opener_message', (data, uuid) => _postMessage(data, uuid)) native.$on('opener_message', (data, uuid) => _postMessage(data, uuid))
@ -217,6 +226,9 @@ Object.assign(native, {
}, },
relaunch() { relaunch() {
return handler('app', { action: 'relaunch' }, NO_CALLBACK) return handler('app', { action: 'relaunch' }, NO_CALLBACK)
},
getLocale() {
return native.env.LANG
} }
}, },
fs: { fs: {
@ -265,6 +277,9 @@ Object.assign(native, {
}, },
copy(filepath, target) { copy(filepath, target) {
return handler('fs', { action: 'copy', filepath, target }) return handler('fs', { action: 'copy', filepath, target })
},
mkdir(filepath) {
return handler('fs', { action: 'mkdir', filepath })
} }
}, },
image(filepath) { image(filepath) {