Added zooms, 1:1, and scal to container
|
@ -13,6 +13,9 @@ class ButtonControls(Gtk.ButtonBox):
|
|||
def __init__(self):
|
||||
super(ButtonControls, self).__init__()
|
||||
|
||||
self.one2one_button = None
|
||||
self.fit_button = None
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._load_widgets()
|
||||
|
@ -27,49 +30,96 @@ class ButtonControls(Gtk.ButtonBox):
|
|||
...
|
||||
|
||||
def _load_widgets(self):
|
||||
icons_path = settings.get_icons_path()
|
||||
center_widget = Gtk.ButtonBox()
|
||||
lrotate_button = Gtk.Button(label = "Rotate Left")
|
||||
vflip_button = Gtk.Button(label = "Flip Vertical")
|
||||
one2one_button = Gtk.ToggleButton(label = "1:1")
|
||||
fit_button = Gtk.ToggleButton(label = "Fit")
|
||||
hflip_button = Gtk.Button(label = "Flip Horizontal")
|
||||
rrotate_button = Gtk.Button(label = "Rotate Right")
|
||||
|
||||
center_widget.add(lrotate_button)
|
||||
center_widget.add(vflip_button)
|
||||
center_widget.add(one2one_button)
|
||||
center_widget.add(fit_button)
|
||||
center_widget.add(hflip_button)
|
||||
center_widget.add(rrotate_button)
|
||||
|
||||
lrotate_button.set_image( Gtk.Image.new_from_icon_name("gtk-undelete", 4) )
|
||||
vflip_button.set_image( Gtk.Image.new_from_icon_name("gtk-orientation-reverse-portrait", 4) )
|
||||
one2one_button.set_image( Gtk.Image.new_from_icon_name("gtk-zoom-100", 4) )
|
||||
fit_button.set_image( Gtk.Image.new_from_icon_name("gtk-zoom-fit", 4) )
|
||||
hflip_button.set_image( Gtk.Image.new_from_icon_name("gtk-orientation-reverse-landscape", 4) )
|
||||
rrotate_button.set_image( Gtk.Image.new_from_icon_name("object-rotate-right", 4) )
|
||||
zoomout_button = Gtk.Button()
|
||||
lrotate_button = Gtk.Button()
|
||||
vflip_button = Gtk.Button()
|
||||
self.one2one_button = Gtk.ToggleButton()
|
||||
self.fit_button = Gtk.ToggleButton()
|
||||
hflip_button = Gtk.Button()
|
||||
rrotate_button = Gtk.Button()
|
||||
zoomin_button = Gtk.Button()
|
||||
|
||||
# TODO: add if check against settings pull to set 1:1 or fit
|
||||
one2one_button.set_active(True)
|
||||
self.one2one_button.set_active(True)
|
||||
self.fit_button.set_active(False)
|
||||
|
||||
zoomout_button.set_tooltip_text("Zoom Out")
|
||||
lrotate_button.set_tooltip_text("Rotate Left")
|
||||
vflip_button.set_tooltip_text("Flip Vertical")
|
||||
self.one2one_button.set_tooltip_text("Zoom 1:1")
|
||||
self.fit_button.set_tooltip_text("Zoom Fit")
|
||||
hflip_button.set_tooltip_text("Flip Horizontal")
|
||||
rrotate_button.set_tooltip_text("Rotate Right")
|
||||
zoomin_button.set_tooltip_text("Zoom In")
|
||||
|
||||
zoomout_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/zoom-out.png") )
|
||||
lrotate_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/rotate-left.png") )
|
||||
vflip_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/flip-virtical.png") )
|
||||
self.one2one_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/zoom-original.png") )
|
||||
self.fit_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/zoom-fit.png") )
|
||||
hflip_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/flip-horizontal.png") )
|
||||
rrotate_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/rotate-right.png") )
|
||||
zoomin_button.set_image( Gtk.Image.new_from_file(f"{icons_path}/zoom-in.png") )
|
||||
|
||||
zoomout_button.set_always_show_image(True)
|
||||
lrotate_button.set_always_show_image(True)
|
||||
vflip_button.set_always_show_image(True)
|
||||
self.one2one_button.set_always_show_image(True)
|
||||
self.fit_button.set_always_show_image(True)
|
||||
hflip_button.set_always_show_image(True)
|
||||
rrotate_button.set_always_show_image(True)
|
||||
zoomin_button.set_always_show_image(True)
|
||||
|
||||
zoomout_button.connect("clicked", self._zoom_out)
|
||||
lrotate_button.connect("clicked", self._rotate_left)
|
||||
vflip_button.connect("clicked", self._vertical_flip)
|
||||
one2one_button.connect("clicked", self._scale_1_two_1)
|
||||
fit_button.connect("clicked", self._fit_to_container)
|
||||
self.one2one_button.connect("button-release-event", self._scale_1_two_1)
|
||||
self.fit_button.connect("button-release-event", self._fit_to_container)
|
||||
hflip_button.connect("clicked", self._horizontal_flip)
|
||||
rrotate_button.connect("clicked", self._rotate_right)
|
||||
zoomin_button.connect("clicked", self._zoom_in)
|
||||
|
||||
center_widget.add(zoomout_button)
|
||||
center_widget.add(lrotate_button)
|
||||
center_widget.add(vflip_button)
|
||||
center_widget.add(self.one2one_button)
|
||||
center_widget.add(self.fit_button)
|
||||
center_widget.add(hflip_button)
|
||||
center_widget.add(rrotate_button)
|
||||
center_widget.add(zoomin_button)
|
||||
|
||||
self.set_center_widget(center_widget)
|
||||
|
||||
def _zoom_out(self, widget = None, eve = None):
|
||||
event_system.emit("zoom_out")
|
||||
|
||||
def _rotate_left(self, widget = None, eve = None):
|
||||
event_system.emit("rotate_left")
|
||||
|
||||
def _vertical_flip(self, widget = None, eve = None):
|
||||
event_system.emit("vertical_flip")
|
||||
|
||||
def _scale_1_two_1(self, widget = None, eve = None):
|
||||
event_system.emit("scale_1_two_1")
|
||||
if eve.button == 1:
|
||||
self.fit_button.set_active(False)
|
||||
self.one2one_button.set_active(True)
|
||||
|
||||
event_system.emit("scale_1_two_1")
|
||||
|
||||
def _fit_to_container(self, widget = None, eve = None):
|
||||
event_system.emit("fit_to_container")
|
||||
if eve.button == 1:
|
||||
self.one2one_button.set_active(False)
|
||||
self.fit_button.set_active(True)
|
||||
|
||||
event_system.emit("fit_to_container")
|
||||
|
||||
def _horizontal_flip(self, widget = None, eve = None):
|
||||
event_system.emit("horizontal_flip")
|
||||
|
||||
def _rotate_right(self, widget = None, eve = None):
|
||||
event_system.emit("rotate_right")
|
||||
|
||||
def _zoom_in(self, widget = None, eve = None):
|
||||
event_system.emit("zoom_in")
|
||||
|
|
|
@ -16,9 +16,10 @@ class ImageView(Gtk.Image):
|
|||
def __init__(self):
|
||||
super(ImageView, self).__init__()
|
||||
|
||||
self.bak_pixbuf = None
|
||||
self.pixbuf = None
|
||||
self.animation = None
|
||||
self.pixbuf = None
|
||||
self.work_pixbuf = None
|
||||
self.animation = None
|
||||
self.fit_to_win = False
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
|
@ -36,6 +37,7 @@ class ImageView(Gtk.Image):
|
|||
...
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("zoom_out", self._zoom_out)
|
||||
event_system.subscribe("handle_file_from_dnd", self._handle_file_from_dnd)
|
||||
event_system.subscribe("vertical_flip", self._vertical_flip)
|
||||
event_system.subscribe("rotate_left", self._rotate_left)
|
||||
|
@ -43,6 +45,7 @@ class ImageView(Gtk.Image):
|
|||
event_system.subscribe("fit_to_container", self._fit_to_container)
|
||||
event_system.subscribe("horizontal_flip", self._horizontal_flip)
|
||||
event_system.subscribe("rotate_right", self._rotate_right)
|
||||
event_system.subscribe("zoom_in", self._zoom_in)
|
||||
|
||||
def _load_widgets(self):
|
||||
...
|
||||
|
@ -55,9 +58,9 @@ class ImageView(Gtk.Image):
|
|||
logger.debug("Start animation stub...")
|
||||
|
||||
def load_path(self, path):
|
||||
self.bak_pixbuf = None
|
||||
self.pixbuf = None
|
||||
self.animation = None
|
||||
self.pixbuf = None
|
||||
self.work_pixbuf = None
|
||||
self.animation = None
|
||||
|
||||
if path.endswith(".gif"):
|
||||
try:
|
||||
|
@ -68,40 +71,92 @@ class ImageView(Gtk.Image):
|
|||
return
|
||||
|
||||
try:
|
||||
self.pixbuf = Gtk.Image.new_from_file(path).get_pixbuf()
|
||||
self.work_pixbuf = Gtk.Image.new_from_file(path).get_pixbuf()
|
||||
except Exception:
|
||||
self.pixbuf = Gtk.Image.new_from_resource(path).get_pixbuf()
|
||||
self.work_pixbuf = Gtk.Image.new_from_resource(path).get_pixbuf()
|
||||
|
||||
self.pixbuf = self.work_pixbuf
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
if self.fit_to_win:
|
||||
self._fit_to_container()
|
||||
|
||||
self.bak_pixbuf = self.pixbuf
|
||||
self.set_from_pixbuf(self.pixbuf)
|
||||
event_system.emit("update_path_label", (path,))
|
||||
|
||||
|
||||
def _zoom_out(self):
|
||||
if self.work_pixbuf:
|
||||
# TODO: Setup scale factor setting to pull from settings...
|
||||
stepx = self.work_pixbuf.get_width() * 0.05
|
||||
stepy = self.work_pixbuf.get_height() * 0.05
|
||||
|
||||
w = self.work_pixbuf.get_width() - stepx
|
||||
h = self.work_pixbuf.get_height() - stepy
|
||||
|
||||
self.work_pixbuf = self.pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _rotate_left(self):
|
||||
if self.pixbuf:
|
||||
self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE)
|
||||
self.set_from_pixbuf(self.pixbuf)
|
||||
if self.work_pixbuf:
|
||||
self.work_pixbuf = self.work_pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE)
|
||||
self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE)
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _vertical_flip(self):
|
||||
if self.pixbuf:
|
||||
self.pixbuf = self.pixbuf.flip(False)
|
||||
self.set_from_pixbuf(self.pixbuf)
|
||||
if self.work_pixbuf:
|
||||
self.work_pixbuf = self.work_pixbuf.flip(False)
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _scale_1_two_1(self):
|
||||
if self.pixbuf:
|
||||
...
|
||||
...
|
||||
self.fit_to_win = False
|
||||
if self.work_pixbuf:
|
||||
self.work_pixbuf = self.pixbuf
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _fit_to_container(self):
|
||||
if self.pixbuf:
|
||||
...
|
||||
...
|
||||
self.fit_to_win = True
|
||||
if self.work_pixbuf:
|
||||
parent_aloc = self.get_parent().get_parent().get_allocation()
|
||||
pw = parent_aloc.width
|
||||
ph = parent_aloc.height
|
||||
iw = self.pixbuf.get_width()
|
||||
ih = self.pixbuf.get_height()
|
||||
w = 0
|
||||
h = 0
|
||||
|
||||
if iw == 0 or ih == 0:
|
||||
return
|
||||
|
||||
w = pw;
|
||||
h = ((ih * w) / iw + 0.5)
|
||||
|
||||
if h > ph:
|
||||
h = ph
|
||||
w = (iw * h) / ih + 0.5
|
||||
|
||||
|
||||
self.work_pixbuf = self.pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _horizontal_flip(self):
|
||||
if self.pixbuf:
|
||||
self.pixbuf = self.pixbuf.flip(True)
|
||||
self.set_from_pixbuf(self.pixbuf)
|
||||
if self.work_pixbuf:
|
||||
self.work_pixbuf = self.work_pixbuf.flip(True)
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _rotate_right(self):
|
||||
if self.pixbuf:
|
||||
self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.CLOCKWISE)
|
||||
self.set_from_pixbuf(self.pixbuf)
|
||||
if self.work_pixbuf:
|
||||
self.work_pixbuf = self.work_pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.CLOCKWISE)
|
||||
self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.CLOCKWISE)
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
||||
def _zoom_in(self):
|
||||
if self.work_pixbuf:
|
||||
# TODO: Setup scale factor setting to pull from settings...
|
||||
stepx = self.work_pixbuf.get_width() * 0.05
|
||||
stepy = self.work_pixbuf.get_height() * 0.05
|
||||
|
||||
w = self.work_pixbuf.get_width() + stepx
|
||||
h = self.work_pixbuf.get_height() + stepy
|
||||
|
||||
self.work_pixbuf = self.pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default
|
||||
self.set_from_pixbuf(self.work_pixbuf)
|
||||
|
|
|
@ -143,6 +143,8 @@ class Settings(StartCheckMixin, Singleton):
|
|||
def get_window_icon(self) -> str: return self._WINDOW_ICON
|
||||
def get_home_path(self) -> str: return self._USER_HOME
|
||||
|
||||
|
||||
def get_icons_path(self) -> str: return self._DEFAULT_ICONS
|
||||
def get_thumbnail_with(self) -> int: return self._config["thumbnail_with"]
|
||||
def get_thumbnail_height(self) -> int: return self._config["thumbnail_height"]
|
||||
def get_max_ring_thumbnail_list(self) -> int: return self._config["max_ring_thumbnail_list"]
|
||||
|
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.0 KiB |