Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
path: root/viewtoolbar.py
diff options
authorManuel Quiñones <manuq@laptop.org>2012-03-22 19:07:54 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-03-22 19:07:54 (GMT)
commitc7fa1ce251c6468ed230d62b018ce3b29c063f16 (patch)
tree592efde51c4d3859f866e2432be3b747648d1849 /viewtoolbar.py
parent6b2733eb740da1e8bf02d3807d62f26c4631aced (diff)
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 <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'viewtoolbar.py')
1 files changed, 23 insertions, 0 deletions
diff --git a/viewtoolbar.py b/viewtoolbar.py
index 7daadc9..0226df8 100644
--- a/viewtoolbar.py
+++ b/viewtoolbar.py
@@ -22,11 +22,15 @@ from gi.repository import GObject
from sugar3.graphics.toolbutton import ToolButton
+from browser import Browser
class ViewToolbar(Gtk.Toolbar):
def __init__(self, activity):
+ self._browser = None
self._activity = activity
self._activity.tray.connect('unmap', self.__unmap_cb)
self._activity.tray.connect('map', self.__map_cb)
@@ -60,6 +64,25 @@ class ViewToolbar(Gtk.Toolbar):
self.insert(self.traybutton, -1)
+ tabbed_view = self._activity.get_canvas()
+ if tabbed_view.get_n_pages():
+ self._connect_to_browser(tabbed_view.props.current_browser)
+ tabbed_view.connect_after('switch-page', self.__switch_page_cb)
+ def __switch_page_cb(self, tabbed_view, page, page_num):
+ self._connect_to_browser(tabbed_view.props.current_browser)
+ def _connect_to_browser(self, browser):
+ self._browser = browser
+ self._update_zoom_buttons()
+ def _update_zoom_buttons(self):
+ is_webkit_browser = isinstance(self._browser, Browser)
+ self.zoomin.set_sensitive(is_webkit_browser)
+ self.zoomout.set_sensitive(is_webkit_browser)
def __zoomin_clicked_cb(self, button):
tabbed_view = self._activity.get_canvas()