Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucian Branescu Mihaila <lucian.branescu@gmail.com>2010-06-17 23:22:12 (GMT)
committer Lucian Branescu Mihaila <lucian.branescu@gmail.com>2010-06-17 23:22:12 (GMT)
commitc6b5a1509d612bfe23692ea294152df0b7cbb870 (patch)
tree3efadfa5dc1e3cac6e960ef3e8b38f57024818e5
parenta8b17436c94ec188857c4a06efa6ade64a0ef20b (diff)
Implement sessionstore for webkit.
-rw-r--r--browser.py13
-rw-r--r--sessionstore.py38
2 files changed, 19 insertions, 32 deletions
diff --git a/browser.py b/browser.py
index 891d06c..952ec70 100644
--- a/browser.py
+++ b/browser.py
@@ -31,6 +31,7 @@ from sugar import env
from sugar.activity import activity
from sugar.graphics import style
+import sessionstore
from palettes import ContentInvoker
#from sessionhistory import HistoryListener
#from progresslistener import ProgressListener
@@ -171,21 +172,15 @@ class TabLabel(gtk.HBox):
class Browser(webkit.WebView):
__gtype_name__ = 'Browser'
- __gsignals__ = {
- 'is-setup': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([]))
- }
-
def __init__(self):
webkit.WebView.__init__(self)
#self.history = HistoryListener()
#self.progress = ProgressListener()
- def do_setup(self):
-
- self.emit('is-setup')
+
+ def load_uri(self, uri):
+ pass
def get_session(self):
return sessionstore.get_session(self)
diff --git a/sessionstore.py b/sessionstore.py
index 08ba4a2..7b78812 100644
--- a/sessionstore.py
+++ b/sessionstore.py
@@ -20,29 +20,31 @@
import logging
def get_session(browser):
- session_history = browser.web_navigation.sessionHistory
+ session_history = browser.get_back_forward_list()
- if session_history.count == 0:
+ if len(session_history) == 0:
return ''
return _get_history(session_history)
def set_session(browser, data):
- _set_history(browser.web_navigation.sessionHistory, data)
+ session_history = browser.get_back_forward_list()
+
+ _set_history(session_history, data)
if data:
- browser.web_navigation.gotoIndex(len(data) - 1)
+ session_history.go_to_item(len(data) -1)
else:
browser.load_uri('about:blank')
def _get_history(history):
- logging.debug('%r' % history.count)
+ logging.debug('%r' % len(history))
entries_dest = []
- for i in range(0, history.count):
- entry_orig = history.getEntryAtIndex(i, False)
- entry_dest = {'url': entry_orig.URI.spec,
- 'title': entry_orig.title}
+ for i in range(0, len(history)):
+ entry_orig = history.get_nth_item(i)
+ entry_dest = {'url': entry_orig.props.uri,
+ 'title': entry_orig.props.title}
entries_dest.append(entry_dest)
@@ -50,21 +52,11 @@ def _get_history(history):
def _set_history(history, history_data):
- history_internal = history.queryInterface(interfaces.nsISHistoryInternal)
-
- if history_internal.count > 0:
- history_internal.purgeHistory(history_internal.count)
-
+ history.clear()
+
for entry_dict in history_data:
logging.debug('entry_dict: %r' % entry_dict)
- entry_class = components.classes[ \
- "@mozilla.org/browser/session-history-entry;1"]
- entry = entry_class.createInstance(interfaces.nsISHEntry)
- io_service_class = components.classes[ \
- "@mozilla.org/network/io-service;1"]
- io_service = io_service_class.getService(interfaces.nsIIOService)
- entry.setURI(io_service.newURI(entry_dict['url'], None, None))
- entry.setTitle(entry_dict['title'])
+ entry = webkit.WebHistoryItem(entry_dict['url'], entry_dict['title'])
- history_internal.addEntry(entry, True)
+ history.add_item(entry)