From 585a2a7882f6c6d7e4b1860ebf492d33001c321c Mon Sep 17 00:00:00 2001
From: Gonzalo Odiard <godiard@sugarlabs.org>
Date: Tue, 5 Oct 2010 07:59:02 -0300
Subject: [PATCH] fix #2383 - Browse: history not right when resuming
Previously Browse does not saved the current tabs opened, saved
the history and assumes the last url in the history is the current.
---
webactivity.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/webactivity.py b/webactivity.py
index bba1032..71c6fe1 100644
a
|
b
|
class WebActivity(activity.Activity): |
423 | 423 | 'list of multiple uris by now.') |
424 | 424 | else: |
425 | 425 | self._tabbed_view.props.current_browser.load_uri(file_path) |
| 426 | self.load_urls() |
| 427 | |
| 428 | def load_urls(self): |
| 429 | if self.model.data['currents'] != None: |
| 430 | first = True |
| 431 | for current_tab in self.model.data['currents']: |
| 432 | if first: |
| 433 | browser = self._tabbed_view.current_browser |
| 434 | first = False |
| 435 | else: |
| 436 | browser = Browser() |
| 437 | self._tabbed_view._append_tab(browser) |
| 438 | browser.load_uri(current_tab['url']) |
426 | 439 | |
427 | 440 | def write_file(self, file_path): |
428 | 441 | if not self.metadata['mime_type']: |
… |
… |
class WebActivity(activity.Activity): |
439 | 452 | self.model.data['history'] = self._tabbed_view.get_session() |
440 | 453 | self.model.data['current_tab'] = self._tabbed_view.get_current_page() |
441 | 454 | |
| 455 | self.model.data['currents'] = [] |
| 456 | for n in range(0,self._tabbed_view.get_n_pages()): |
| 457 | n_browser = self._tabbed_view.get_nth_page(n) |
| 458 | if n_browser != None: |
| 459 | uri = browser.progress.location |
| 460 | cls = components.classes['@mozilla.org/intl/texttosuburi;1'] |
| 461 | texttosuburi = cls.getService(components.interfaces.nsITextToSubURI) |
| 462 | ui_uri = texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec) |
| 463 | self.model.data['currents'].append({'title':browser.props.title,'url':ui_uri}) |
| 464 | |
442 | 465 | f = open(file_path, 'w') |
443 | 466 | try: |
444 | 467 | logging.debug('########## writing %s' % self.model.serialize()) |