Finalizing current feature set
This commit is contained in:
parent
43b720724a
commit
7fbca79104
|
@ -25,9 +25,11 @@ class Application(IPCServer):
|
||||||
...
|
...
|
||||||
|
|
||||||
if not self.is_ipc_alive:
|
if not self.is_ipc_alive:
|
||||||
for arg in unknownargs + [args.new_tab,]:
|
collection = unknownargs + [args.file] if args.file and os.path.isfile(args.file) else unknownargs
|
||||||
if os.path.isfile(arg):
|
for arg in collection:
|
||||||
message = f"FILE|{arg}"
|
path = arg.replace("file://", "")
|
||||||
|
if os.path.isfile(path):
|
||||||
|
message = f"FILE|{path}"
|
||||||
self.send_ipc_message(message)
|
self.send_ipc_message(message)
|
||||||
|
|
||||||
raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...")
|
raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...")
|
||||||
|
|
|
@ -18,6 +18,7 @@ class ImageViewScroll(Gtk.ScrolledWindow):
|
||||||
super(ImageViewScroll, self).__init__()
|
super(ImageViewScroll, self).__init__()
|
||||||
|
|
||||||
self.fimages = settings.get_images_filter()
|
self.fimages = settings.get_images_filter()
|
||||||
|
self.curent_dir = None
|
||||||
|
|
||||||
self._setup_styling()
|
self._setup_styling()
|
||||||
self._setup_signals()
|
self._setup_signals()
|
||||||
|
@ -35,6 +36,7 @@ class ImageViewScroll(Gtk.ScrolledWindow):
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
self._set_up_dnd()
|
self._set_up_dnd()
|
||||||
|
self.connect("size-allocate", self._size_request_change)
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
self.add(ImageView())
|
self.add(ImageView())
|
||||||
|
@ -66,39 +68,42 @@ class ImageViewScroll(Gtk.ScrolledWindow):
|
||||||
if len(uris) == 0:
|
if len(uris) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
path, img_list = self.filter_for_images(uris)
|
has_loaded_image, path, img_list = self.filter_for_images(uris)
|
||||||
self._handle_open(path, img_list)
|
self._handle_open(has_loaded_image, path, img_list)
|
||||||
|
|
||||||
def filter_for_images(self, files):
|
def filter_for_images(self, files):
|
||||||
path = files[0].replace("file://", "")
|
path = files[0].replace("file://", "")
|
||||||
img_list = []
|
img_list = []
|
||||||
listedDir = False
|
listedDir = False
|
||||||
|
has_loaded_image = False
|
||||||
if len(files) == 1:
|
|
||||||
if os.path.isdir(path):
|
|
||||||
listedDir = True
|
|
||||||
files = os.listdir(path)
|
|
||||||
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
|
event_system.emit("handle_file_from_dnd", (path,))
|
||||||
path = os.path.dirname(path)
|
path = os.path.dirname(path)
|
||||||
|
has_loaded_image = True
|
||||||
|
|
||||||
|
if not self.curent_dir or not self.curent_dir == path:
|
||||||
|
files = os.listdir(path)
|
||||||
|
self.curent_dir = path
|
||||||
|
else:
|
||||||
|
files = []
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(self.fimages):
|
if file.endswith(self.fimages):
|
||||||
if listedDir:
|
|
||||||
img_list.append(file)
|
img_list.append(file)
|
||||||
else:
|
|
||||||
img_list.append(file.replace("file://", "").replace(f"{path}/", ""))
|
|
||||||
|
|
||||||
return path, img_list
|
return has_loaded_image, path, img_list
|
||||||
|
|
||||||
def _handle_open(self,path, img_list):
|
def _handle_open(self, has_loaded_image, path, img_list):
|
||||||
if len(img_list) == 0:
|
if len(img_list) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(img_list) == 1:
|
if not has_loaded_image:
|
||||||
img = img_list[0]
|
img = img_list[0]
|
||||||
target = os.path.join(path, img)
|
target = os.path.join(path, img)
|
||||||
event_system.emit("handle_file_from_dnd", target)
|
event_system.emit("handle_file_from_dnd", target)
|
||||||
return
|
|
||||||
|
|
||||||
event_system.emit("load_image_list", (path, img_list))
|
event_system.emit("load_image_list", (path, img_list))
|
||||||
|
|
||||||
|
def _size_request_change(self, widget = None, eve = None):
|
||||||
|
event_system.emit("size_allocate")
|
||||||
|
|
|
@ -35,15 +35,16 @@ class ButtonControls(Gtk.ButtonBox):
|
||||||
zoomout_button = Gtk.Button()
|
zoomout_button = Gtk.Button()
|
||||||
lrotate_button = Gtk.Button()
|
lrotate_button = Gtk.Button()
|
||||||
vflip_button = Gtk.Button()
|
vflip_button = Gtk.Button()
|
||||||
self.one2one_button = Gtk.ToggleButton()
|
# NOTE: Toggle Buttons are acting broken for me so workaround ith regular buttons
|
||||||
self.fit_button = Gtk.ToggleButton()
|
self.one2one_button = Gtk.Button()
|
||||||
|
self.fit_button = Gtk.Button()
|
||||||
hflip_button = Gtk.Button()
|
hflip_button = Gtk.Button()
|
||||||
rrotate_button = Gtk.Button()
|
rrotate_button = Gtk.Button()
|
||||||
zoomin_button = Gtk.Button()
|
zoomin_button = Gtk.Button()
|
||||||
|
|
||||||
# TODO: add if check against settings pull to set 1:1 or fit
|
# TODO: add if check against settings pull to set 1:1 or fit
|
||||||
self.one2one_button.set_active(True)
|
self._set_class(self.one2one_button)
|
||||||
self.fit_button.set_active(False)
|
# self._set_class(self.fit_button)
|
||||||
|
|
||||||
zoomout_button.set_tooltip_text("Zoom Out")
|
zoomout_button.set_tooltip_text("Zoom Out")
|
||||||
lrotate_button.set_tooltip_text("Rotate Left")
|
lrotate_button.set_tooltip_text("Rotate Left")
|
||||||
|
@ -103,15 +104,15 @@ class ButtonControls(Gtk.ButtonBox):
|
||||||
|
|
||||||
def _scale_1_two_1(self, widget = None, eve = None):
|
def _scale_1_two_1(self, widget = None, eve = None):
|
||||||
if eve.button == 1:
|
if eve.button == 1:
|
||||||
self.fit_button.set_active(False)
|
self._unset_class(self.fit_button)
|
||||||
self.one2one_button.set_active(True)
|
self._set_class(self.one2one_button)
|
||||||
|
|
||||||
event_system.emit("scale_1_two_1")
|
event_system.emit("scale_1_two_1")
|
||||||
|
|
||||||
def _fit_to_container(self, widget = None, eve = None):
|
def _fit_to_container(self, widget = None, eve = None):
|
||||||
if eve.button == 1:
|
if eve.button == 1:
|
||||||
self.one2one_button.set_active(False)
|
self._unset_class(self.one2one_button)
|
||||||
self.fit_button.set_active(True)
|
self._set_class(self.fit_button)
|
||||||
|
|
||||||
event_system.emit("fit_to_container")
|
event_system.emit("fit_to_container")
|
||||||
|
|
||||||
|
@ -123,3 +124,11 @@ class ButtonControls(Gtk.ButtonBox):
|
||||||
|
|
||||||
def _zoom_in(self, widget = None, eve = None):
|
def _zoom_in(self, widget = None, eve = None):
|
||||||
event_system.emit("zoom_in")
|
event_system.emit("zoom_in")
|
||||||
|
|
||||||
|
def _set_class(self, target):
|
||||||
|
ctx = target.get_style_context()
|
||||||
|
ctx.add_class("button-highlighted")
|
||||||
|
|
||||||
|
def _unset_class(self, target):
|
||||||
|
ctx = target.get_style_context()
|
||||||
|
ctx.remove_class("button-highlighted")
|
||||||
|
|
|
@ -47,6 +47,8 @@ class ImageView(Gtk.Image):
|
||||||
event_system.subscribe("rotate_right", self._rotate_right)
|
event_system.subscribe("rotate_right", self._rotate_right)
|
||||||
event_system.subscribe("zoom_in", self._zoom_in)
|
event_system.subscribe("zoom_in", self._zoom_in)
|
||||||
|
|
||||||
|
event_system.subscribe("size_allocate", self._size_allocate)
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -104,7 +106,8 @@ class ImageView(Gtk.Image):
|
||||||
|
|
||||||
def _vertical_flip(self):
|
def _vertical_flip(self):
|
||||||
if self.work_pixbuf:
|
if self.work_pixbuf:
|
||||||
self.work_pixbuf = self.work_pixbuf.flip(False)
|
self.work_pixbuf = self.work_pixbuf.flip(True)
|
||||||
|
self.pixbuf = self.pixbuf.flip(True)
|
||||||
self.set_from_pixbuf(self.work_pixbuf)
|
self.set_from_pixbuf(self.work_pixbuf)
|
||||||
|
|
||||||
def _scale_1_two_1(self):
|
def _scale_1_two_1(self):
|
||||||
|
@ -140,7 +143,8 @@ class ImageView(Gtk.Image):
|
||||||
|
|
||||||
def _horizontal_flip(self):
|
def _horizontal_flip(self):
|
||||||
if self.work_pixbuf:
|
if self.work_pixbuf:
|
||||||
self.work_pixbuf = self.work_pixbuf.flip(True)
|
self.work_pixbuf = self.work_pixbuf.flip(False)
|
||||||
|
self.pixbuf = self.pixbuf.flip(False)
|
||||||
self.set_from_pixbuf(self.work_pixbuf)
|
self.set_from_pixbuf(self.work_pixbuf)
|
||||||
|
|
||||||
def _rotate_right(self):
|
def _rotate_right(self):
|
||||||
|
@ -160,3 +164,7 @@ class ImageView(Gtk.Image):
|
||||||
|
|
||||||
self.work_pixbuf = self.pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default
|
self.work_pixbuf = self.pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default
|
||||||
self.set_from_pixbuf(self.work_pixbuf)
|
self.set_from_pixbuf(self.work_pixbuf)
|
||||||
|
|
||||||
|
def _size_allocate(self):
|
||||||
|
if self.fit_to_win:
|
||||||
|
self._fit_to_container()
|
||||||
|
|
|
@ -3,3 +3,7 @@
|
||||||
/* Dark Bergundy */
|
/* Dark Bergundy */
|
||||||
border: 2px solid rgba(56, 56, 56, 1);
|
border: 2px solid rgba(56, 56, 56, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-highlighted {
|
||||||
|
background-color: #AB7E45;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue