From 9edb5937736282c61ec2f657c3fbabac7322a44a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Aug 2019 09:52:27 +0530 Subject: [PATCH] Move forward_gesture() to ui_operations --- src/pyj/read_book/globals.pyj | 1 + src/pyj/read_book/touch.pyj | 5 ++--- src/pyj/read_book/ui.pyj | 4 ++++ src/pyj/viewer-main.pyj | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/globals.pyj b/src/pyj/read_book/globals.pyj index d52c1b7fa3..d2ba28b0c2 100644 --- a/src/pyj/read_book/globals.pyj +++ b/src/pyj/read_book/globals.pyj @@ -74,4 +74,5 @@ ui_operations = { 'show_error': None, 'redisplay_book': None, 'reload_book': None, + 'forward_gesture': None, } diff --git a/src/pyj/read_book/touch.pyj b/src/pyj/read_book/touch.pyj index 83c05f6883..8858350fd3 100644 --- a/src/pyj/read_book/touch.pyj +++ b/src/pyj/read_book/touch.pyj @@ -2,8 +2,7 @@ # License: GPL v3 Copyright: 2016, Kovid Goyal from __python__ import bound_methods, hash_literals -from book_list.globals import get_read_ui -from read_book.globals import get_boss +from read_book.globals import get_boss, ui_operations from read_book.viewport import scroll_viewport HOLD_THRESHOLD = 750 # milliseconds @@ -257,7 +256,7 @@ class BookTouchHandler(TouchHandler): return gesture.type = 'show-chrome' if self.for_side_margin: - get_read_ui().view.forward_gesture(gesture) + ui_operations.forward_gesture(gesture) else: get_boss().handle_gesture(gesture) diff --git a/src/pyj/read_book/ui.pyj b/src/pyj/read_book/ui.pyj index b355ccd57a..e3dd29cffc 100644 --- a/src/pyj/read_book/ui.pyj +++ b/src/pyj/read_book/ui.pyj @@ -62,6 +62,7 @@ class ReadUI: ui_operations.show_error = self.show_error.bind(self) ui_operations.redisplay_book = self.redisplay_book.bind(self) ui_operations.reload_book = self.reload_book.bind(self) + ui_operations.forward_gesture = self.forward_gesture.bind(self) def on_resize(self): self.view.on_resize() @@ -145,6 +146,9 @@ class ReadUI: def redisplay_book(self): self.view.redisplay_book() + def forward_gesture(self, gesture): + self.view.forward_gesture(gesture) + def update_font_size(self): self.view.update_font_size() diff --git a/src/pyj/viewer-main.pyj b/src/pyj/viewer-main.pyj index 502ecfecf0..c35382f783 100644 --- a/src/pyj/viewer-main.pyj +++ b/src/pyj/viewer-main.pyj @@ -214,6 +214,10 @@ def reload_book(): to_python.reload_book() +def forward_gesture(gesture): + view.forward_gesture(gesture) + + if window is window.top: # main ui_operations.get_file = get_file @@ -222,6 +226,7 @@ if window is window.top: ui_operations.show_error = show_error ui_operations.redisplay_book = redisplay_book ui_operations.reload_book = reload_book + ui_operations.forward_gesture = forward_gesture document.body.appendChild(E.div(id='view')) window.onerror = onerror create_modal_container()