From 18c756760b78ebdf7680a6cfc44600d90e5cbbb0 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 06 Oct 2010 17:39:37 +0000 Subject: 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. --- diff --git a/browser.py b/browser.py index b0a7ae7..3781e2e 100644 --- a/browser.py +++ b/browser.py @@ -172,6 +172,14 @@ class Browser(WebView): uri = self.web_navigation.currentURI persist.saveURI(uri, self.doc_shell, None, None, None, local_file) + def get_url_from_nsiuri(self, uri): + """ + get a nsIURI object and return a string with the url + """ + cls = components.classes['@mozilla.org/intl/texttosuburi;1'] + texttosuburi = cls.getService(interfaces.nsITextToSubURI) + return texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec) + def zoom_in(self): contentViewer = self.doc_shell.queryInterface( \ interfaces.nsIDocShell).contentViewer diff --git a/progresslistener.py b/progresslistener.py index 23d4966..13886f6 100644 --- a/progresslistener.py +++ b/progresslistener.py @@ -36,6 +36,7 @@ class ProgressListener(gobject.GObject): def __init__(self): gobject.GObject.__init__(self) + self._location = None self.total_requests = 0 self.completed_requests = 0 @@ -57,6 +58,7 @@ class ProgressListener(gobject.GObject): self.completed_requests = 0 def onLocationChange(self, webProgress, request, location): + self._location = location self.emit('location-changed', location) def onProgressChange(self, webProgress, request, curSelfProgress, @@ -90,3 +92,8 @@ class ProgressListener(gobject.GObject): def onStatusChange(self, webProgress, request, status, message): pass + + def _get_location(self): + return self._location + + location = gobject.property(type=object, getter=_get_location) diff --git a/webactivity.py b/webactivity.py index a7c55bb..39bb67e 100644 --- a/webactivity.py +++ b/webactivity.py @@ -412,6 +412,12 @@ class WebActivity(activity.Activity): 'list of multiple uris by now.') else: self._browser.load_uri(file_path) + self._load_urls() + + def _load_urls(self): + if self.model.data['currents'] != None: + for current in self.model.data['currents']: + self._browser.load_uri(current['url']) def write_file(self, file_path): if not self.metadata['mime_type']: @@ -424,6 +430,10 @@ class WebActivity(activity.Activity): self.model.data['history'] = self._browser.get_session() + self.model.data['currents'] = [] + ui_uri = self._browser.get_url_from_nsiuri(self._browser.progress.location) + self.model.data['currents'].append({'title':self._browser.props.title,'url':ui_uri}) + logging.error(self.model.data) f = open(file_path, 'w') try: f.write(self.model.serialize()) diff --git a/webtoolbar.py b/webtoolbar.py index 428fd89..d87dbd8 100644 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -281,11 +281,7 @@ class WebToolbar(gtk.Toolbar): gobject.idle_add(self._reload_session_history, current_page_index) def _location_changed_cb(self, progress_listener, uri): - cls = components.classes['@mozilla.org/intl/texttosuburi;1'] - texttosuburi = cls.getService(interfaces.nsITextToSubURI) - ui_uri = texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec) - - self._set_address(ui_uri) + self._set_address(self._browser.get_url_from_nsiuri(uri)) self._update_navigation_buttons() filepicker.cleanup_temp_files() -- cgit v0.9.1