49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
import gi
|
|
gi.require_version("Gtk","3.0")
|
|
gi.require_version("WebKit2","4.0")
|
|
from gi.repository import Gtk,WebKit2
|
|
|
|
browser = mfp.require("browser")
|
|
|
|
def onResize(obj,event):
|
|
resizeElements(obj,event.width,event.height)
|
|
|
|
def resizeElements(obj,width,height):
|
|
for webView in obj.cWebViews:
|
|
webView.set_size_request(width,height)
|
|
|
|
def onClose(obj):
|
|
browser.windows.remove(obj.cParent)
|
|
for webView in obj.cWebViews: webView.destroy()
|
|
obj.destroy()
|
|
if len(browser.windows) == 0:
|
|
Gtk.main_quit()
|
|
|
|
def create():
|
|
import sys
|
|
self = mfp.Bunch()
|
|
obj = Gtk.Window()
|
|
self.obj = obj
|
|
|
|
obj.cMainWrapper = Gtk.ScrolledWindow()
|
|
obj.add(obj.cMainWrapper)
|
|
obj.cMain = Gtk.Fixed()
|
|
obj.cMainWrapper.add(obj.cMain)
|
|
|
|
obj.cParent = self
|
|
obj.set_title(mfp.require("browser").name)
|
|
obj.resize(640,480)
|
|
obj.connect("configure-event",onResize)
|
|
obj.connect("destroy",onClose)
|
|
|
|
webView = WebKit2.WebView()
|
|
obj.cWebViews = []
|
|
obj.cWebViews.append(webView)
|
|
obj.cMain.add(webView)
|
|
webView.load_uri(sys.argv[1])
|
|
obj.set_focus(webView)
|
|
|
|
resizeElements(obj,640,480)
|
|
|
|
obj.show_all()
|
|
return self |