diff --git a/src/core/containers/image_view_scroll.py b/src/core/containers/image_view_scroll.py index 5807688..2e920cd 100644 --- a/src/core/containers/image_view_scroll.py +++ b/src/core/containers/image_view_scroll.py @@ -39,6 +39,7 @@ class ImageViewScroll(Gtk.ScrolledWindow): def _setup_signals(self): self._set_up_dnd() self.connect("size-allocate", self._size_request_change) + self.connect('scroll-event', self.on_scroll) def _load_widgets(self): self.add(ImageView()) @@ -116,3 +117,21 @@ class ImageViewScroll(Gtk.ScrolledWindow): if self.size_request.width != rect.width or self.size_request.height != rect.height: self.size_request = rect GLib.idle_add(event_system.emit, *("size_allocate",)) + + def on_scroll(self, widget = None, event = None): + accel_mask = Gtk.accelerator_get_default_mod_mask() + direction = event.get_scroll_deltas()[2] + if event.state & accel_mask == Gdk.ModifierType.CONTROL_MASK: + adjustment = self.get_hadjustment() + current_val = adjustment.get_value() + step_val = adjustment.get_step_increment() + + if direction > 0: # NOTE: scroll left + adjustment.set_value(current_val - step_val) + else: # NOTE: scroll right + adjustment.set_value(current_val + step_val) + else: + if direction > 0: + event_system.emit("zoom_out") + else: + event_system.emit("zoom_in") diff --git a/src/core/controller.py b/src/core/controller.py index 77c0e79..4b3d8ae 100644 --- a/src/core/controller.py +++ b/src/core/controller.py @@ -44,7 +44,7 @@ class Controller(SignalsMixins, ControllerData): event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar) def _tggl_top_main_menubar(self): - print("_tggl_top_main_menubar > stub...") + logger.debug("_tggl_top_main_menubar > stub...") def setup_builder_and_container(self): self.builder = Gtk.Builder() diff --git a/src/core/widgets/image.py b/src/core/widgets/image.py index a72df90..2334536 100644 --- a/src/core/widgets/image.py +++ b/src/core/widgets/image.py @@ -61,7 +61,7 @@ class Image(Gtk.EventBox): pixbuf = None if PImage and path.endswith(".webp"): - return ImageView.image2pixbuf(path, w, h) + pixbuf = ImageView.image2pixbuf(path) if path.endswith(".gif"): pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(path).get_static_image() diff --git a/src/core/widgets/image_view.py b/src/core/widgets/image_view.py index 3441016..85c6e59 100644 --- a/src/core/widgets/image_view.py +++ b/src/core/widgets/image_view.py @@ -42,7 +42,6 @@ class ImageView(ImageViewMixin, Gtk.Image): def _setup_styling(self): ... - def _setup_signals(self): ... @@ -106,19 +105,15 @@ class ImageView(ImageViewMixin, Gtk.Image): self.work_pixbuff = Gtk.Image.new_from_resource(path).get_pixbuf() def set_as_webp(self, path): - w = settings.get_thumbnail_with() - h = settings.get_thumbnail_height() - self.work_pixbuff = self.image2pixbuf(path, w, h) + self.work_pixbuff = self.image2pixbuf(path) @staticmethod - def image2pixbuf(path, _w, _h): + def image2pixbuf(path): """Convert Pillow image to GdkPixbuf""" im = PImage.open(path) data = im.tobytes() data = Bytes.new(data) w, h = im.size - pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB, + return GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB, False, 8, w, h, w * 3) - - return pixbuf.scale_simple(_w, _h, 2) # 2 = BILINEAR and is best by default diff --git a/src/core/widgets/image_view_mixin.py b/src/core/widgets/image_view_mixin.py index 7e1e90b..60a4e81 100644 --- a/src/core/widgets/image_view_mixin.py +++ b/src/core/widgets/image_view_mixin.py @@ -23,7 +23,6 @@ class ImageViewMixin: self.set_from_pixbuf(self.work_pixbuff) def _rotate_left(self): - print("flipl") if self.work_pixbuff and self.pixbuff: self.work_pixbuff = self.work_pixbuff.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE) self.pixbuff = self.pixbuff.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE)