Compare commits
3 Commits
85eb247823
...
3ec5892102
Author | SHA1 | Date |
---|---|---|
Fierelier | 3ec5892102 | |
Fierelier | 8b05d168f7 | |
Fierelier | 14eb91f84c |
|
@ -33,11 +33,6 @@ else:
|
|||
sp = pUp(s)
|
||||
|
||||
# Script start
|
||||
|
||||
# Comment the following line for hardware acceleration
|
||||
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
|
||||
|
||||
#os.environ["WEBKIT_USE_SINGLE_WEB_PROCESS"] = "1" # Deprecated, not required with this code
|
||||
import gi
|
||||
gi.require_version("Gtk","3.0")
|
||||
gi.require_version("WebKit2","4.0")
|
||||
|
@ -66,7 +61,6 @@ def parseUrl(url):
|
|||
|
||||
birdyWebContext = WebKit2.WebContext()
|
||||
birdyWebContext.set_cache_model(WebKit2.CacheModel.DOCUMENT_VIEWER) # Does this even do anything at all?
|
||||
#birdyWebContext.set_process_model(WebKit2.ProcessModel.SHARED_SECONDARY_PROCESS) # Deprecated, not required with this code
|
||||
birdyWebContext.set_spell_checking_enabled(False)
|
||||
birdyWebContext.set_use_system_appearance_for_scrollbars(True)
|
||||
|
||||
|
@ -74,12 +68,13 @@ birdyWebSettings = WebKit2.Settings.new()
|
|||
#birdyWebSettings.set_auto_load_images(False)
|
||||
birdyWebSettings.set_enable_developer_extras(False)
|
||||
birdyWebSettings.set_enable_page_cache(False)
|
||||
birdyWebSettings.set_hardware_acceleration_policy(WebKit2.HardwareAccelerationPolicy.ALWAYS) # WebKit's software acceleration is broken, use LIBGL_ALWAYS_SOFTWARE=1 instead.
|
||||
#birdyWebSettings.set_enable_plugins(False) # Probably best to not uncomment this, I think it causes a memory leak
|
||||
birdyWebSettings.set_hardware_acceleration_policy(WebKit2.HardwareAccelerationPolicy.NEVER)
|
||||
defaultUserAgent = birdyWebSettings.get_user_agent()
|
||||
singleProcessMode = False
|
||||
remakeViewOnNavigation = False # Always entirely remake view on navigation, could break some websites - use for super low memory situations
|
||||
|
||||
def birdyWebViewConstructor(webView):
|
||||
if webView:
|
||||
if webView and singleProcessMode:
|
||||
return WebKit2.WebView.new_with_related_view(webView)
|
||||
|
||||
self = WebKit2.WebView.new_with_context(birdyWebContext)
|
||||
|
@ -120,16 +115,13 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
self.cMenuBar.add(self.cMenuLoadingIndication)
|
||||
|
||||
homepage = "about:blank"
|
||||
self.cLastUrl = "about:blank"
|
||||
self.cUrlEntry = Gtk.Entry()
|
||||
self.cUrlEntry.set_text(homepage)
|
||||
#self.cUrlEntry.props.enable_emoji_completion = True # lol
|
||||
self.cUrlEntry.connect("activate",self.cUrlEntryNavigate)
|
||||
self.cMainBox.add(self.cUrlEntry)
|
||||
self.cWebView = birdyWebViewConstructor(webView)
|
||||
self.cWebView.connect("load-changed",self.cWebViewLoadChanged)
|
||||
self.cWebView.connect("notify::uri",self.cUrlChanged)
|
||||
self.cWebView.connect("notify::title",self.cTitleChanged)
|
||||
self.cMainBox.add(self.cWebView)
|
||||
self.cCreateWebView(webView)
|
||||
self.cWebView.load_uri(homepage)
|
||||
self.cResizeElements()
|
||||
self.set_focus(self.cUrlEntry)
|
||||
|
@ -137,6 +129,13 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
self.show_all()
|
||||
self.cMenuLoadingIndication.hide()
|
||||
|
||||
def cCreateWebView(self,webView):
|
||||
self.cWebView = birdyWebViewConstructor(webView)
|
||||
self.cWebView.connect("load-changed",self.cWebViewLoadChanged)
|
||||
self.cWebView.connect("notify::uri",self.cUrlChanged)
|
||||
self.cWebView.connect("notify::title",self.cTitleChanged)
|
||||
self.cMainBox.add(self.cWebView)
|
||||
|
||||
def cResizeElements(self):
|
||||
# cMenuBar
|
||||
self.cMainBox.move(self.cMenuBar,0,0)
|
||||
|
@ -165,6 +164,15 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
|
||||
def cUrlChanged(self,widget,prop):
|
||||
url = widget.get_uri()
|
||||
|
||||
if url != self.cLastUrl and remakeViewOnNavigation and not singleProcessMode:
|
||||
self.cWebView.destroy()
|
||||
self.cCreateWebView(False)
|
||||
self.cResizeElements()
|
||||
self.show_all()
|
||||
self.cWebView.load_uri(url)
|
||||
|
||||
self.cLastUrl = url
|
||||
if url == "about:blank": return
|
||||
if self.cUrlEntry.get_text() != url: self.cUrlEntry.set_text(url)
|
||||
|
||||
|
@ -187,6 +195,13 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
url = defaultProtocol + "://" + url
|
||||
|
||||
self.set_focus(self.cWebView)
|
||||
|
||||
if not singleProcessMode:
|
||||
self.cWebView.destroy()
|
||||
self.cCreateWebView(False)
|
||||
self.cResizeElements()
|
||||
self.show_all()
|
||||
|
||||
self.cWebView.load_uri(url)
|
||||
|
||||
browserWindows.append(birdyBrowserWindow(False))
|
||||
|
|
Loading…
Reference in New Issue