diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2012-09-10 19:25:38 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-09-10 19:25:38 (GMT) |
commit | 12021bd6de3800042befa003db87c09f6fcad97d (patch) | |
tree | 578e35661f6fa5dd04f635328cd166b5d969e8f7 /epubview | |
parent | 11435850ea587da2c3f7cebfad7d5a7fdc37bdb2 (diff) |
Keep the text position in the epub files - SL #3861
When the zoom level change or the index view to is shown / hidden.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'epubview')
-rw-r--r-- | epubview/epubview.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/epubview/epubview.py b/epubview/epubview.py index b200d36..e317d11 100644 --- a/epubview/epubview.py +++ b/epubview/epubview.py @@ -153,7 +153,9 @@ class _View(Gtk.HBox): ''' Sets the current zoom level ''' + scrollbar_pos = self.get_vertical_pos() self._view.set_zoom_level(value / 100.0) + self.set_vertical_pos(scrollbar_pos) def _get_scale(self): ''' @@ -172,7 +174,9 @@ class _View(Gtk.HBox): Zooms in (increases zoom level by 0.1) ''' if self.can_zoom_in(): + scrollbar_pos = self.get_vertical_pos() self._set_scale(self._get_scale() + 0.1) + self.set_vertical_pos(scrollbar_pos) return True else: return False @@ -182,11 +186,26 @@ class _View(Gtk.HBox): Zooms out (decreases zoom level by 0.1) ''' if self.can_zoom_out(): + scrollbar_pos = self.get_vertical_pos() self._set_scale(self._get_scale() - 0.1) + self.set_vertical_pos(scrollbar_pos) return True else: return False + def get_vertical_pos(self): + """ + Used to save the scrolled position and restore when needed + """ + return self._v_vscrollbar.get_adjustment().get_value() + + def set_vertical_pos(self, position): + """ + Used to save the scrolled position and restore when needed + """ + self._v_vscrollbar.get_adjustment().set_value(position) + + def can_zoom_in(self): ''' Returns True if it is possible to zoom in further |