From c7fa1ce251c6468ed230d62b018ce3b29c063f16 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Thu, 22 Mar 2012 19:07:54 +0000 Subject: Basic PDF reading When a request is made with a MIME type 'application/pdf', a new tab is opened next to the current one to show the document. If the document is remote, a download starts, and the progress is shown in the toolbar's URL entry. It can be cancelled with the X button, the same for cancelling the loading. Basic navigation is provided to allow a quick read of the PDF. The user can also save the document to the Journal to store it, and later it may be opened in Read for featureful usage. The controls are in a floating toolbar, at the bottom of the document. The PDF tabs are restored between sessions as expected. If the user clicks on a hyperlink in a PDF, a new tab is opened next to the current to browse it. This uses Evince, the same backend to display the PDF document as Read. And WebKit to download the document, as per other downloads in Browse. Signed-off-by: Manuel QuiƱones Acked-by: Simon Schampijer --- (limited to 'webtoolbar.py') diff --git a/webtoolbar.py b/webtoolbar.py index 098f832..7525053 100644 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -34,6 +34,7 @@ from sugar3.activity.widgets import StopButton # import filepicker import places from sugarmenuitem import SugarMenuItem +from browser import Browser _MAX_HISTORY_ENTRIES = 15 @@ -331,6 +332,11 @@ class PrimaryToolbar(ToolbarBase): self._set_title(_('Untitled')) self._set_address(self._browser.props.uri) + if isinstance(self._browser, Browser): + self.entry.props.editable = True + else: + self.entry.props.editable = False + self._title_changed_hid = self._browser.connect( 'notify::title', self._title_changed_cb) self._uri_changed_hid = self._browser.connect( @@ -379,7 +385,11 @@ class PrimaryToolbar(ToolbarBase): can_go_forward = self._browser.can_go_forward() self._forward.props.sensitive = can_go_forward - self._reload_session_history() + is_webkit_browser = isinstance(self._browser, Browser) + self._link_add.props.sensitive = is_webkit_browser + self._go_home.props.sensitive = is_webkit_browser + if is_webkit_browser: + self._reload_session_history() def _entry_activate_cb(self, entry): url = entry.props.text -- cgit v0.9.1