diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2011-06-08 20:09:14 (GMT) |
---|---|---|
committer | Sascha Silbe <silbe@activitycentral.com> | 2011-06-18 11:31:31 (GMT) |
commit | 7072ec5913ff6e1447666adf825c46edb0074a93 (patch) | |
tree | 6aa6354b7bbf1cb095072d12e7a15b233a26af17 /webactivity.py | |
parent | b102e4c61d753c219a7d03c3c5255c1da1f3100a (diff) |
Set and restore index in the history (OLPC #10779 / SL #2499)
Restoring the history index instead of (re)loading the active URL will
"distribute" the history over the Back and Forward buttons exactly the same
as before Stop + Resume instead of putting it all on the Back button.
[tweaked description]
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
Acked-By: Sascha Silbe <silbe@activitycentral.com>
Diffstat (limited to 'webactivity.py')
-rw-r--r-- | webactivity.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/webactivity.py b/webactivity.py index fc9e913..dade56a 100644 --- a/webactivity.py +++ b/webactivity.py @@ -459,6 +459,10 @@ class WebActivity(activity.Activity): link['owner'], -1, link['hash']) logging.debug('########## reading %s', data) self._tabbed_view.set_session(self.model.data['history']) + for number, tab in enumerate(self.model.data['currents']): + browser = self._tabbed_view.get_nth_page(number) + browser.set_history_index(tab['history_index']) + self._tabbed_view.set_current_page(self.model.data['current_tab']) elif self.metadata['mime_type'] == 'text/uri-list': data = self._get_data_from_file_path(file_path) @@ -470,19 +474,6 @@ class WebActivity(activity.Activity): 'list of multiple uris by now.') else: self._tabbed_view.props.current_browser.load_uri(file_path) - self._load_urls() - - def _load_urls(self): - if self.model.data['currents'] != None: - first = True - for current_tab in self.model.data['currents']: - if first: - browser = self._tabbed_view.current_browser - first = False - else: - browser = Browser() - self._tabbed_view._append_tab(browser) - browser.load_uri(current_tab['url']) def write_file(self, file_path): if not self.metadata['mime_type']: @@ -504,9 +495,12 @@ class WebActivity(activity.Activity): for n in range(0, self._tabbed_view.get_n_pages()): n_browser = self._tabbed_view.get_nth_page(n) if n_browser != None: - nsiuri = browser.progress.location - ui_uri = browser.get_url_from_nsiuri(nsiuri) - info = {'title': browser.props.title, 'url': ui_uri} + nsiuri = n_browser.progress.location + ui_uri = n_browser.get_url_from_nsiuri(nsiuri) + history_index = n_browser.get_history_index() + info = {'title': n_browser.props.title, 'url': ui_uri, + 'history_index': history_index} + self.model.data['currents'].append(info) f = open(file_path, 'w') |