Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sessionstore.py
diff options
context:
space:
mode:
Diffstat (limited to 'sessionstore.py')
-rw-r--r--sessionstore.py45
1 files changed, 16 insertions, 29 deletions
diff --git a/sessionstore.py b/sessionstore.py
index 674f4fe..c1287a9 100644
--- a/sessionstore.py
+++ b/sessionstore.py
@@ -18,32 +18,32 @@
# http://lxr.mozilla.org/seamonkey/source/browser/components/sessionstore
import logging
+from gi.repository import WebKit
def get_session(browser):
- return ''
- session_history = browser.web_navigation.sessionHistory
-
- if session_history.count == 0:
+ session_history = browser.get_back_forward_list()
+ if session_history.get_back_length() == 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)
+ # FIXME: this is adding the latest page twice:
+ browser.load_uri(session_history.get_current_item().get_uri())
else:
browser.load_uri('about:blank')
def _get_history(history):
- logging.debug('%r', history.count)
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 reversed(range(history.get_back_length())):
+ entry_orig = history.get_nth_item(i * -1)
+ entry_dest = {'url': entry_orig.get_uri(),
+ 'title': entry_orig.get_title()}
entries_dest.append(entry_dest)
@@ -51,21 +51,8 @@ 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)
-
- 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'])
-
- history_internal.addEntry(entry, True)
+ history.clear()
+ for entry in history_data:
+ uri, title = entry['url'], entry['title']
+ history_item = WebKit.WebHistoryItem.new_with_data(uri, title)
+ history.add_item(history_item)