Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/evinceadapter.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-09-05 14:51:33 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-09-10 14:19:33 (GMT)
commitef1810e61bf4658a48191fcff238857e1458b21b (patch)
treea3c1674169eeb84a1debeaf0ed2ad83a9756c04a /evinceadapter.py
parentabe02384fbcc42b82706240c924e646cb77b72ad (diff)
Enable touch kindle like interaction in pdf backend
Change pages with touch in the region x < width * 1/3 and x > width * 3/4 Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'evinceadapter.py')
-rw-r--r--evinceadapter.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/evinceadapter.py b/evinceadapter.py
index 2aaa216..b09e755 100644
--- a/evinceadapter.py
+++ b/evinceadapter.py
@@ -5,6 +5,7 @@ import time
from gi.repository import GObject
from gi.repository import Gtk
+from gi.repository import Gdk
from gi.repository import EvinceDocument
from gi.repository import EvinceView
@@ -37,6 +38,10 @@ class EvinceViewer():
activity._scrolled.add(self._view)
self._view.show()
+ self._view.set_events(self._view.get_events() |
+ Gdk.EventMask.TOUCH_MASK)
+ self._view.connect('event', self.__view_touch_event_cb)
+
activity._hbox.pack_start(activity._scrolled, True, True, 0)
activity._scrolled.show()
@@ -66,6 +71,15 @@ class EvinceViewer():
self._model.set_max_scale(max_scale * self.dpi / 72.0)
"""
+ def __view_touch_event_cb(self, widget, event):
+ if event.type == Gdk.EventType.TOUCH_BEGIN:
+ x = event.touch.x
+ view_width = widget.get_allocation().width
+ if x > view_width * 3 / 4:
+ self._view.scroll(Gtk.ScrollType.PAGE_FORWARD, False)
+ elif x < view_width * 1 / 4:
+ self._view.scroll(Gtk.ScrollType.PAGE_BACKWARD, False)
+
def __handle_link_cb(self, widget, url_object):
url = url_object.get_uri()
logging.debug('Create journal entry for URL: %s', url)