diff --git a/src/new-src/app.py b/src/new-src/app.py index 85809d6..0836309 100644 --- a/src/new-src/app.py +++ b/src/new-src/app.py @@ -25,9 +25,11 @@ class Application(IPCServer): ... if not self.is_ipc_alive: - for arg in unknownargs + [args.new_tab,]: - if os.path.isfile(arg): - message = f"FILE|{arg}" + collection = unknownargs + [args.file] if args.file and os.path.isfile(args.file) else unknownargs + for arg in collection: + path = arg.replace("file://", "") + if os.path.isfile(path): + message = f"FILE|{path}" self.send_ipc_message(message) raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...") diff --git a/src/new-src/core/containers/image_view_scroll.py b/src/new-src/core/containers/image_view_scroll.py index c605d8a..da58b3f 100644 --- a/src/new-src/core/containers/image_view_scroll.py +++ b/src/new-src/core/containers/image_view_scroll.py @@ -17,7 +17,8 @@ class ImageViewScroll(Gtk.ScrolledWindow): def __init__(self): 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_signals() @@ -35,6 +36,7 @@ class ImageViewScroll(Gtk.ScrolledWindow): def _setup_signals(self): self._set_up_dnd() + self.connect("size-allocate", self._size_request_change) def _load_widgets(self): self.add(ImageView()) @@ -66,39 +68,42 @@ class ImageViewScroll(Gtk.ScrolledWindow): if len(uris) == 0: return - path, img_list = self.filter_for_images(uris) - self._handle_open(path, img_list) + has_loaded_image, path, img_list = self.filter_for_images(uris) + self._handle_open(has_loaded_image, path, img_list) def filter_for_images(self, files): path = files[0].replace("file://", "") img_list = [] listedDir = False - - if len(files) == 1: - if os.path.isdir(path): - listedDir = True - files = os.listdir(path) + has_loaded_image = False if not os.path.isdir(path): + event_system.emit("handle_file_from_dnd", (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: if file.endswith(self.fimages): - if listedDir: - img_list.append(file) - else: - img_list.append(file.replace("file://", "").replace(f"{path}/", "")) + img_list.append(file) - 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: return - if len(img_list) == 1: + if not has_loaded_image: img = img_list[0] target = os.path.join(path, img) event_system.emit("handle_file_from_dnd", target) - return event_system.emit("load_image_list", (path, img_list)) + + def _size_request_change(self, widget = None, eve = None): + event_system.emit("size_allocate") diff --git a/src/new-src/core/widgets/button_controls.py b/src/new-src/core/widgets/button_controls.py index 517615d..82d911d 100644 --- a/src/new-src/core/widgets/button_controls.py +++ b/src/new-src/core/widgets/button_controls.py @@ -35,15 +35,16 @@ class ButtonControls(Gtk.ButtonBox): zoomout_button = Gtk.Button() lrotate_button = Gtk.Button() vflip_button = Gtk.Button() - self.one2one_button = Gtk.ToggleButton() - self.fit_button = Gtk.ToggleButton() + # NOTE: Toggle Buttons are acting broken for me so workaround ith regular buttons + self.one2one_button = Gtk.Button() + self.fit_button = Gtk.Button() 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 - self.one2one_button.set_active(True) - self.fit_button.set_active(False) + self._set_class(self.one2one_button) + # self._set_class(self.fit_button) zoomout_button.set_tooltip_text("Zoom Out") 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): if eve.button == 1: - self.fit_button.set_active(False) - self.one2one_button.set_active(True) + self._unset_class(self.fit_button) + self._set_class(self.one2one_button) event_system.emit("scale_1_two_1") def _fit_to_container(self, widget = None, eve = None): if eve.button == 1: - self.one2one_button.set_active(False) - self.fit_button.set_active(True) + self._unset_class(self.one2one_button) + self._set_class(self.fit_button) event_system.emit("fit_to_container") @@ -123,3 +124,11 @@ class ButtonControls(Gtk.ButtonBox): def _zoom_in(self, widget = None, eve = None): 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") diff --git a/src/new-src/core/widgets/image_view.py b/src/new-src/core/widgets/image_view.py index 7919f42..3c8f7b7 100644 --- a/src/new-src/core/widgets/image_view.py +++ b/src/new-src/core/widgets/image_view.py @@ -47,6 +47,8 @@ class ImageView(Gtk.Image): event_system.subscribe("rotate_right", self._rotate_right) event_system.subscribe("zoom_in", self._zoom_in) + event_system.subscribe("size_allocate", self._size_allocate) + def _load_widgets(self): ... @@ -104,7 +106,8 @@ class ImageView(Gtk.Image): def _vertical_flip(self): 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) def _scale_1_two_1(self): @@ -140,7 +143,8 @@ class ImageView(Gtk.Image): def _horizontal_flip(self): 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) 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.set_from_pixbuf(self.work_pixbuf) + + def _size_allocate(self): + if self.fit_to_win: + self._fit_to_container() diff --git a/user_config/usr/share/mirage2/stylesheet.css b/user_config/usr/share/mirage2/stylesheet.css index 6cb1fd1..0b4b7b6 100644 --- a/user_config/usr/share/mirage2/stylesheet.css +++ b/user_config/usr/share/mirage2/stylesheet.css @@ -3,3 +3,7 @@ /* Dark Bergundy */ border: 2px solid rgba(56, 56, 56, 1); } + +.button-highlighted { + background-color: #AB7E45; +}