[Pkg-sugar-commit] [sugar-browse-activity] 08/18: fix #2383 : Browse: history not right when resuming

Jonas Smedegaard dr at jones.dk
Mon Apr 20 09:47:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 108.1
in repository sugar-browse-activity.

commit 18c756760b78ebdf7680a6cfc44600d90e5cbbb0
Author: Gonzalo Odiard <godiard at sugarlabs.org>
Date:   Wed Oct 6 14:39:37 2010 -0300

    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.
---
 browser.py          |  8 ++++++++
 progresslistener.py |  7 +++++++
 webactivity.py      | 10 ++++++++++
 webtoolbar.py       |  6 +-----
 4 files changed, 26 insertions(+), 5 deletions(-)

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()
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-browse-activity.git



More information about the pkg-sugar-commit mailing list