Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Ortiz <rafael@activitycentral.com>2011-07-15 16:55:44 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2011-07-15 16:55:44 (GMT)
commit7e2548bfed38b73a21a82ea6d349991fbe05780a (patch)
treed4e4680a49d9d392266582216538ef60217a9a6b
parent099a61486ee7decb1ef7bce48364f6713ae6ddb4 (diff)
matching mainlineHEADmaster
-rw-r--r--browser.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/browser.py b/browser.py
index b9c1f69..733b12c 100644
--- a/browser.py
+++ b/browser.py
@@ -44,18 +44,24 @@ from progresslistener import ProgressListener
_ZOOM_AMOUNT = 0.1
-class GetSourceListener(object):
+class SaveListener(object):
_com_interfaces_ = interfaces.nsIWebProgressListener
- def __init__(self, file_path, async_cb, async_err_cb):
- self._file_path = file_path
- self._async_cb = async_cb
- self._async_err_cb = async_err_cb
+ def __init__(self, user_data, callback):
+ self._user_data = user_data
+ self._callback = callback
def onStateChange(self, webProgress, request, stateFlags, status):
- if (stateFlags & interfaces.nsIWebProgressListener.STATE_IS_REQUEST and
- stateFlags & interfaces.nsIWebProgressListener.STATE_STOP):
- self._async_cb(self._file_path)
+ listener_class = interfaces.nsIWebProgressListener
+ if (stateFlags & listener_class.STATE_IS_REQUEST and
+ stateFlags & listener_class.STATE_STOP):
+ self._callback(self._user_data)
+
+ # Contrary to the documentation, STATE_IS_REQUEST is _not_ always set
+ # if STATE_IS_DOCUMENT is set.
+ if (stateFlags & listener_class.STATE_IS_DOCUMENT and
+ stateFlags & listener_class.STATE_STOP):
+ self._callback(self._user_data)
def onProgressChange(self, progress, request, curSelfProgress,
maxSelfProgress, curTotalProgress, maxTotalProgress):
@@ -328,7 +334,7 @@ class Browser(WebView):
local_file = cls.createInstance(interfaces.nsILocalFile)
local_file.initWithPath(file_path)
- progresslistener = GetSourceListener(file_path, async_cb, async_err_cb)
+ progresslistener = SaveListener(file_path, async_cb)
persist.progressListener = xpcom.server.WrapObject(
progresslistener, interfaces.nsIWebProgressListener)
@@ -351,6 +357,12 @@ class Browser(WebView):
interfaces.nsIMarkupDocumentViewer)
markupDocumentViewer.fullZoom -= _ZOOM_AMOUNT
+ def get_history_index(self):
+ return self.web_navigation.sessionHistory.index
+
+ def set_history_index(self, index):
+ self.web_navigation.gotoIndex(index)
+
class PopupDialog(gtk.Window):
def __init__(self):