added background fill; added info load per image

This commit is contained in:
itdominator 2023-09-24 16:39:18 -05:00
parent f10c6d9afd
commit b6d2e9ec54
5 changed files with 27 additions and 3 deletions

View File

@ -25,6 +25,12 @@ def daemon_threaded_wrapper(fn):
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start() threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
return wrapper return wrapper
def sizeof_fmt_def(num, suffix="B"):
for unit in ["", "K", "M", "G", "T", "Pi", "Ei", "Zi"]:
if abs(num) < 1024.0:
return f"{num:3.1f} {unit}{suffix}"
num /= 1024.0
return f"{num:.1f} Yi{suffix}"
# NOTE: Just reminding myself we can add to builtins two different ways... # NOTE: Just reminding myself we can add to builtins two different ways...
@ -40,4 +46,5 @@ builtins.logger = Logger(settings.get_home_config_path(), \
builtins.threaded = threaded_wrapper builtins.threaded = threaded_wrapper
builtins.daemon_threaded = daemon_threaded_wrapper builtins.daemon_threaded = daemon_threaded_wrapper
builtins.sizeof_fmt = sizeof_fmt_def
builtins.event_sleep_time = 0.05 builtins.event_sleep_time = 0.05

View File

@ -20,6 +20,7 @@ class RightBox(Gtk.Box):
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()
self._subscribe_to_events()
self._load_widgets() self._load_widgets()
self.show_all() self.show_all()
@ -33,7 +34,14 @@ class RightBox(Gtk.Box):
def _setup_signals(self): def _setup_signals(self):
... ...
def _subscribe_to_events(self):
event_system.subscribe("background_fill", self._toggle_background)
def _load_widgets(self): def _load_widgets(self):
self.add(ButtonControls()) self.add(ButtonControls())
self.add(PathLabel()) self.add(PathLabel())
self.add(ImageViewScroll()) self.add(ImageViewScroll())
def _toggle_background(self):
ctx = self.get_style_context()
ctx.remove_class("background-fill") if ctx.has_class("background-fill") else ctx.add_class("background-fill")

View File

@ -1,4 +1,5 @@
# Python imports # Python imports
from os.path import getsize
import inspect import inspect
# Lib imports # Lib imports
@ -74,7 +75,6 @@ class ImageView(ImageViewMixin, Gtk.Image):
self.animation = None self.animation = None
self._stop_animation() self._stop_animation()
event_system.emit("update_path_label", (path,))
if path.endswith(".gif"): if path.endswith(".gif"):
self.set_as_gif(path) self.set_as_gif(path)
return return
@ -86,6 +86,12 @@ class ImageView(ImageViewMixin, Gtk.Image):
self.set_as_static(path) self.set_as_static(path)
self.pixbuff = self.work_pixbuff.copy() self.pixbuff = self.work_pixbuff.copy()
width = self.pixbuff.get_width()
height = self.pixbuff.get_height()
size = sizeof_fmt( getsize(path) )
path = f"{path} | {width} x {height} | {size}"
event_system.emit("update_path_label", (path,))
if self.fit_to_win: if self.fit_to_win:
self._fit_to_container() self._fit_to_container()
else: else:

View File

@ -39,8 +39,7 @@ class PathLabel(Gtk.Label):
... ...
def update_path_label(self, path = None): def update_path_label(self, path = None):
if not path: if not path: return
return
self.set_label(path) self.set_label(path)
self.set_tooltip_text(path) self.set_tooltip_text(path)

View File

@ -11,3 +11,7 @@
.button-highlighted { .button-highlighted {
background-color: #AB7E45; background-color: #AB7E45;
} }
.background-fill {
background: rgba(39, 43, 52, 1);
}