launch oml in gtk webkit frame on linux

This commit is contained in:
j 2015-11-03 12:13:27 +01:00
parent 00f395e304
commit 2c71bc44f2
2 changed files with 41 additions and 7 deletions

14
ctl
View file

@ -9,6 +9,7 @@ if [ -e oml ]; then
fi fi
BASE=`pwd` BASE=`pwd`
SYSTEM=`uname -s` SYSTEM=`uname -s`
SYSTEM_=`uname -s`
PLATFORM=`uname -m` PLATFORM=`uname -m`
if [ $SYSTEM == "Linux" ]; then if [ $SYSTEM == "Linux" ]; then
@ -48,7 +49,7 @@ if [ "$1" == "start" ]; then
rm "$launchd_plist" rm "$launchd_plist"
fi fi
fi fi
if [ $SYSTEM == "Linux" ]; then if [ $SYSTEM_ == "Linux" ]; then
if [ -e "$HOME/.config/autostart/openmedialibrary.desktop" ]; then if [ -e "$HOME/.config/autostart/openmedialibrary.desktop" ]; then
rm "$HOME/.config/autostart/openmedialibrary.desktop" rm "$HOME/.config/autostart/openmedialibrary.desktop"
fi fi
@ -96,18 +97,19 @@ if [ "$1" == "restart" ]; then
fi fi
fi fi
if [ "$1" == "open" ]; then if [ "$1" == "open" ]; then
"$0" start &
#time to switch to python and use webbrowser.open_tab? #time to switch to python and use webbrowser.open_tab?
echo $SYSTEM
if [ $SYSTEM == "Darwin" ]; then if [ $SYSTEM == "Darwin" ]; then
open "$BASE/$NAME/static/html/load.html" open "/Applications/Open Media Library.app"
else fi
xdg-open "$BASE/$NAME/static/html/load.html" if [ $SYSTEM_ == "Linux" ]; then
exec python3 "$NAME/oml/gtkwebkit.py" $@
fi fi
exit 0 exit 0
fi fi
if [ "$1" == "ui" ]; then if [ "$1" == "ui" ]; then
shift shift
exec python3 $NAME/oml/ui.py $@ exec python3 "$NAME/oml/ui.py" $@
fi fi
if [ "$1" == "update" ]; then if [ "$1" == "update" ]; then
cd "$BASE/$NAME" cd "$BASE/$NAME"

32
oml/gtkwebkit.py Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/python3
import gi
gi.require_version('WebKit2', '4.0')
from gi.repository import WebKit2, Gtk
import os
import subprocess
icon = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../static/png/oml.png')
title = "Open Media Library"
base = os.path.expanduser('~/.local/share/openmedialibrary')
wnd = Gtk.Window()
wnd.set_icon_from_file(icon)
ctx = WebKit2.WebContext.get_default()
web = WebKit2.WebView.new_with_context(ctx)
wnd.connect("destroy", Gtk.main_quit)
wnd.add(web)
wnd.set_wmclass(title, title)
wnd.set_title(title)
wnd.set_default_size(1366, 768)
wnd.show_all()
url = 'file://' + base + '/openmedialibrary/static/html/load.html'
web.load_uri(url)
ctl = base + '/ctl'
p = subprocess.Popen([ctl, 'start'])
Gtk.main()
p = subprocess.Popen([ctl, 'stop'])