summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-12-04 18:58:16 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2015-12-04 18:58:16 +0200
commit5751770158c9a27b55599424bb2650f4f4d9e130 (patch)
treef218d6ea651b65cbe5bc1b5245e1ed5e7b181097
parent125332508ff83acb7f0240f6d1f32db68a2d03aa (diff)
Fix various issues with scroll by page
-rw-r--r--lekha/app.py46
1 files changed, 34 insertions, 12 deletions
diff --git a/lekha/app.py b/lekha/app.py
index f4e0194..542ebe7 100644
--- a/lekha/app.py
+++ b/lekha/app.py
@@ -133,18 +133,18 @@ class AppWindow(StandardWindow):
133 main_box.show() 133 main_box.show()
134 134
135 def _event_handler(self, obj, src, tp, ev): 135 def _event_handler(self, obj, src, tp, ev):
136 content = self.tabs.currentContent
136 if tp == EVAS_CALLBACK_MOUSE_WHEEL: 137 if tp == EVAS_CALLBACK_MOUSE_WHEEL:
137 content = self.tabs.currentContent
138 if not content: 138 if not content:
139 return True 139 return True
140 if content.scroll_freeze_get(): 140 if ev.modifier_is_set("Control"):
141 if ev.direction == 0: 141 if ev.direction == 0:
142 if ev.z == 1: 142 if ev.z == 1:
143 content.zoom_out() 143 content.zoom_out()
144 else: 144 else:
145 content.zoom_in() 145 content.zoom_in()
146 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD 146 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
147 elif self.settings["scroll_by_page"]: # TODO: setting for this 147 elif self.settings["scroll_by_page"]:
148 if ev.direction == 0: 148 if ev.direction == 0:
149 visible = content.visible_pages 149 visible = content.visible_pages
150 if not visible: 150 if not visible:
@@ -158,27 +158,43 @@ class AppWindow(StandardWindow):
158 elif tp == EVAS_CALLBACK_KEY_UP: 158 elif tp == EVAS_CALLBACK_KEY_UP:
159 key = ev.key 159 key = ev.key
160 if key == "plus": 160 if key == "plus":
161 if self.tabs.currentContent: 161 if content:
162 self.tabs.currentContent.zoom_in() 162 content.zoom_in()
163 elif key == "minus": 163 elif key == "minus":
164 if self.tabs.currentContent: 164 if content:
165 self.tabs.currentContent.zoom_out() 165 content.zoom_out()
166 elif key == "Escape": 166 elif key == "Escape":
167 if self.fullscreen: 167 if self.fullscreen:
168 self.fullscreen = False 168 self.fullscreen = False
169 elif key == "F11": 169 elif key == "F11":
170 self.fullscreen = not self.fullscreen 170 self.fullscreen = not self.fullscreen
171 elif key == "Control_L" or key == "Control_R": 171 elif key == "Control_L" or key == "Control_R":
172 if self.tabs.currentContent: 172 if content:
173 self.tabs.currentContent.scroll_thaw() 173 content.scroll_thaw()
174 elif key == "Page_Up" or key == "Up":
175 if self.settings["scroll_by_page"]:
176 visible = content.visible_pages
177 if not visible:
178 return True
179 visible = visible[0]
180 content.page_show_by_num(visible-1)
181 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
182 elif key == "Page_Down" or key == "Down":
183 if self.settings["scroll_by_page"]:
184 visible = content.visible_pages
185 if not visible:
186 return True
187 visible = visible[0]
188 content.page_show_by_num(visible+1)
189 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
174 else: 190 else:
175 return True 191 return True
176 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD 192 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
177 elif tp == EVAS_CALLBACK_KEY_DOWN: 193 elif tp == EVAS_CALLBACK_KEY_DOWN:
178 key = ev.key 194 key = ev.key
179 if key == "Control_L" or key == "Control_R": 195 if key == "Control_L" or key == "Control_R":
180 if self.tabs.currentContent: 196 if content:
181 self.tabs.currentContent.scroll_freeze() 197 content.scroll_freeze()
182 else: 198 else:
183 return True 199 return True
184 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD 200 ev.event_flags |= EVAS_EVENT_FLAG_ON_HOLD
@@ -249,7 +265,13 @@ class AppWindow(StandardWindow):
249 chk = Check(self, text="Scroll By Page") 265 chk = Check(self, text="Scroll By Page")
250 chk.state = self.settings["scroll_by_page"] 266 chk.state = self.settings["scroll_by_page"]
251 def _scroll_by_page_cb(obj): 267 def _scroll_by_page_cb(obj):
252 self.settings["scroll_by_page"] = obj.state 268 target_state = obj.state
269 self.settings["scroll_by_page"] = target_state
270 if self.tabs.currentContent:
271 if target_state:
272 self.tabs.currentContent.scroll_freeze()
273 else:
274 self.tabs.currentContent.scroll_thaw()
253 h.dismiss() 275 h.dismiss()
254 chk.callback_changed_add(_scroll_by_page_cb) 276 chk.callback_changed_add(_scroll_by_page_cb)
255 277