[Sugar-devel] [PATCH Browse v3] Revert zoom with the original value SL #3540
Manuel Kaufmann
humitos at gmail.com
Sun Apr 29 11:47:49 EDT 2012
New functionality to go back to the original zoom value. Added
an icon next to zoom properties in View Toolbar. This function
can be used with the hotkey "Control + 0" as well.
Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
browser.py | 1 +
viewtoolbar.py | 11 +++++++++++
webactivity.py | 4 ++++
3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/browser.py b/browser.py
index 259d888..796915e 100644
--- a/browser.py
+++ b/browser.py
@@ -38,6 +38,7 @@ import globalhistory
import downloadmanager
from pdfviewer import PDFTabPage
+ZOOM_ORIGINAL = 1.0
_ZOOM_AMOUNT = 0.1
_LIBRARY_PATH = '/usr/share/library-common/index.html'
diff --git a/viewtoolbar.py b/viewtoolbar.py
index 0226df8..57baf81 100644
--- a/viewtoolbar.py
+++ b/viewtoolbar.py
@@ -23,6 +23,7 @@ from gi.repository import GObject
from sugar3.graphics.toolbutton import ToolButton
from browser import Browser
+from browser import ZOOM_ORIGINAL
class ViewToolbar(Gtk.Toolbar):
@@ -47,6 +48,12 @@ class ViewToolbar(Gtk.Toolbar):
self.insert(self.zoomin, -1)
self.zoomin.show()
+ self.zoomequal = ToolButton('zoom-original')
+ self.zoomequal.set_tooltip(_('Zoom equal'))
+ self.zoomequal.connect('clicked', self.__zoomequal_clicked_cb)
+ self.insert(self.zoomequal, -1)
+ self.zoomequal.show()
+
self.separator = Gtk.SeparatorToolItem()
self.separator.set_draw(True)
self.insert(self.separator, -1)
@@ -83,6 +90,10 @@ class ViewToolbar(Gtk.Toolbar):
self.zoomin.set_sensitive(is_webkit_browser)
self.zoomout.set_sensitive(is_webkit_browser)
+ def __zoomequal_clicked_cb(self, button):
+ tabbed_view = self._activity.get_canvas()
+ tabbed_view.props.current_browser.set_zoom_level(ZOOM_ORIGINAL)
+
def __zoomin_clicked_cb(self, button):
tabbed_view = self._activity.get_canvas()
tabbed_view.props.current_browser.zoom_in()
diff --git a/webactivity.py b/webactivity.py
index 156ea3c..9345a45 100644
--- a/webactivity.py
+++ b/webactivity.py
@@ -128,6 +128,7 @@ def _set_char_preference(name, value):
from browser import TabbedView
+from browser import ZOOM_ORIGINAL
from webtoolbar import PrimaryToolbar
from edittoolbar import EditToolbar
from viewtoolbar import ViewToolbar
@@ -448,6 +449,9 @@ class WebActivity(activity.Activity):
elif key_name in ['plus', 'equal']:
_logger.debug('keyboard: Zoom in')
browser.zoom_in()
+ elif key_name == '0':
+ _logger.debug('keyboard: Zoom equal')
+ browser.set_zoom_level(ZOOM_ORIGINAL)
elif key_name == 'Left':
_logger.debug('keyboard: Go back')
browser.go_back()
--
1.7.7.6
More information about the Sugar-devel
mailing list