Accurate URL bar, add site title and loading indicator
This commit is contained in:
parent
64a760021e
commit
85eb247823
|
@ -89,6 +89,8 @@ def birdyWebViewConstructor(webView):
|
|||
class birdyBrowserWindow(Gtk.Window):
|
||||
def __init__(self,webView,*args,**kwargs):
|
||||
super().__init__(*args,**kwargs)
|
||||
self.cTitle = "webkit-inabox-gtk"
|
||||
self.set_title(self.cTitle)
|
||||
self.cWidth = 640
|
||||
self.cHeight = 480
|
||||
self.resize(self.cWidth,self.cHeight)
|
||||
|
@ -113,6 +115,10 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
self.cFileMenuButton.set_submenu(self.cFileMenu)
|
||||
self.cMenuBar.add(self.cFileMenuButton)
|
||||
|
||||
# Menu - Loading indication
|
||||
self.cMenuLoadingIndication = Gtk.MenuItem.new_with_label("Loading...")
|
||||
self.cMenuBar.add(self.cMenuLoadingIndication)
|
||||
|
||||
homepage = "about:blank"
|
||||
self.cUrlEntry = Gtk.Entry()
|
||||
self.cUrlEntry.set_text(homepage)
|
||||
|
@ -121,12 +127,15 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
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.cWebView.load_uri(homepage)
|
||||
self.cResizeElements()
|
||||
self.set_focus(self.cUrlEntry)
|
||||
self.cUrlEntry.select_region(0,2)
|
||||
self.show_all()
|
||||
self.cMenuLoadingIndication.hide()
|
||||
|
||||
def cResizeElements(self):
|
||||
# cMenuBar
|
||||
|
@ -154,12 +163,20 @@ class birdyBrowserWindow(Gtk.Window):
|
|||
if len(browserWindows) > 0: return
|
||||
Gtk.main_quit()
|
||||
|
||||
def cWebViewLoadChanged(self,widget,event):
|
||||
def cUrlChanged(self,widget,prop):
|
||||
url = widget.get_uri()
|
||||
if url == "about:blank": return
|
||||
if self.cUrlEntry.get_text() != url: self.cUrlEntry.set_text(url)
|
||||
|
||||
def cTitleChanged(self,widget,prop):
|
||||
self.set_title(widget.get_title() + " - " +self.cTitle)
|
||||
|
||||
def cWebViewLoadChanged(self,widget,event):
|
||||
if event == WebKit2.LoadEvent.STARTED:
|
||||
self.cMenuLoadingIndication.show()
|
||||
|
||||
#if event == WebKit2.LoadEvent.FINISHED:
|
||||
# birdyWebContext.clear_cache() # This might cause a memory leak?
|
||||
if event == WebKit2.LoadEvent.FINISHED:
|
||||
self.cMenuLoadingIndication.hide()
|
||||
|
||||
def cOpenWindow(self,*args,**kwargs):
|
||||
browserWindows.append(birdyBrowserWindow(self.cWebView))
|
||||
|
|
Loading…
Reference in New Issue