Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser.py
diff options
context:
space:
mode:
authorManuel QuiƱones <manuq@laptop.org>2012-01-06 14:22:48 (GMT)
committer Simon Schampijer <simon@schampijer.de>2012-01-06 19:25:24 (GMT)
commitd50001dc6f26b31e39689a20a6540ad4f2e525ba (patch)
treec418ab0448f2eb471c216695766f089b3c399ca5 /browser.py
parent766ae15770617580c0cba22a7118d13dc175d3cc (diff)
Global history for URL autocompletion in URL entry
The sqlite backend to store the global history is maintained. There are two fields in the database that are left unused: bookmark and gecko_flags. Signed-off-by: Manuel QuiƱones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'browser.py')
-rw-r--r--browser.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/browser.py b/browser.py
index 0ff0b77..aad54a7 100644
--- a/browser.py
+++ b/browser.py
@@ -34,6 +34,7 @@ from sugar3.graphics import style
from sugar3.graphics.icon import Icon
from widgets import BrowserNotebook
+import globalhistory
_ZOOM_AMOUNT = 0.1
_LIBRARY_PATH = '/usr/share/library-common/index.html'
@@ -357,6 +358,11 @@ class Browser(WebKit.WebView):
def __init__(self):
WebKit.WebView.__init__(self)
+ # Reference to the global history and callbacks to handle it:
+ self._global_history = globalhistory.get_global_history()
+ self.connect('notify::load-status', self.__load_status_changed_cb)
+ self.connect('notify::title', self.__title_changed_cb)
+
def get_history(self):
"""Return the browsing history of this browser."""
back_forward_list = self.get_back_forward_list()
@@ -429,6 +435,22 @@ class Browser(WebKit.WebView):
def open_new_tab(self, url):
self.emit('new-tab', url)
+ def __load_status_changed_cb(self, widget, param):
+ """Add the url to the global history or update it."""
+ status = widget.get_load_status()
+ if status <= WebKit.LoadStatus.COMMITTED:
+ uri = self.get_uri()
+ self._global_history.add_page(uri)
+
+ def __title_changed_cb(self, widget, param):
+ """Update title in global history."""
+ uri = self.get_uri()
+ if self.props.title is not None:
+ title = self.props.title
+ if not isinstance(title, unicode):
+ title = unicode(title, 'utf-8')
+ self._global_history.set_page_title(uri, title)
+
class PopupDialog(Gtk.Window):
def __init__(self):