diff options
author | Simon Schampijer <simon@schampijer.de> | 2012-01-12 20:55:39 (GMT) |
---|---|---|
committer | Manuel QuiƱones <manuq@laptop.org> | 2012-01-23 11:50:15 (GMT) |
commit | ca4ae1c7374304c872a4f38f670aa590e45150ff (patch) | |
tree | b7ef10de690710063c1c84a3d2af6e34d2f0d798 /browser.py | |
parent | 2274e5c13fd331c9ed6305859445011e9b4d6098 (diff) |
Bring back download functionality using WebKit
This brings back the download functionality to
Browse using WebKit, it handles the cases when you
click on a link and the Browser is not setup to view
this file.
Requesting a download through Palettes is still to
come.
The code is inspired by the download code in Surf.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'browser.py')
-rw-r--r-- | browser.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -35,6 +35,7 @@ from sugar3.graphics.icon import Icon from widgets import BrowserNotebook import globalhistory +import downloadmanager _ZOOM_AMOUNT = 0.1 _LIBRARY_PATH = '/usr/share/library-common/index.html' @@ -389,6 +390,9 @@ class Browser(WebKit.WebView): self._global_history = globalhistory.get_global_history() self.connect('notify::load-status', self.__load_status_changed_cb) self.connect('notify::title', self.__title_changed_cb) + self.connect('download-requested', self.__download_requested_cb) + self.connect('mime-type-policy-decision-requested', + self.__mime_type_policy_cb) def get_history(self): """Return the browsing history of this browser.""" @@ -478,6 +482,16 @@ class Browser(WebKit.WebView): title = unicode(title, 'utf-8') self._global_history.set_page_title(uri, title) + def __mime_type_policy_cb(self, webview, frame, request, mimetype, + policy_decision): + if not self.can_show_mime_type(mimetype): + policy_decision.download() + return True + + def __download_requested_cb(self, browser, download): + downloadmanager.add_download(download, browser) + return True + class PopupDialog(Gtk.Window): def __init__(self): |