Fix scroll commands when it is a smooth scroll event
Thomas Ross
3 years ago
4249 | 4249 | |
4250 | 4250 | def mousewheel_scrolled(self, widget, event): |
4251 | 4251 | if event.type == Gdk.EventType.SCROLL: |
4252 | direction = 0 | |
4253 | if event.direction == Gdk.ScrollDirection.UP: | |
4254 | direction = 1 | |
4255 | elif event.direction == Gdk.ScrollDirection.DOWN: | |
4256 | direction = -1 | |
4257 | elif event.direction == Gdk.ScrollDirection.SMOOTH: | |
4258 | __, x_delta, y_delta = event.get_scroll_deltas() | |
4259 | if y_delta > 0: | |
4260 | direction = -1 | |
4261 | elif y_delta < 0: | |
4262 | direction = 1 | |
4263 | ||
4252 | 4264 | # Zooming of the image by Ctrl-mousewheel |
4253 | 4265 | if event.get_state() & Gdk.ModifierType.CONTROL_MASK: |
4254 | if event.direction == Gdk.ScrollDirection.UP: | |
4266 | if direction == 1: | |
4255 | 4267 | self.zoom_in(None, None, None) |
4256 | elif event.direction == Gdk.ScrollDirection.DOWN: | |
4268 | elif direction == -1: | |
4257 | 4269 | self.zoom_out(None, None, None) |
4270 | ||
4258 | 4271 | return True |
4259 | 4272 | # Navigation of images with mousewheel: |
4260 | 4273 | else: |
4261 | if event.direction == Gdk.ScrollDirection.UP: | |
4274 | if direction == 1: | |
4262 | 4275 | self.goto_prev_image(None, None, None) |
4263 | elif event.direction == Gdk.ScrollDirection.DOWN: | |
4276 | elif direction == -1: | |
4264 | 4277 | self.goto_next_image(None, None, None) |
4278 | ||
4265 | 4279 | return True |
4266 | 4280 | |
4267 | 4281 | def mouse_moved(self, widget, event): |