added background fill; added info load per image
This commit is contained in:
parent
f10c6d9afd
commit
b6d2e9ec54
|
@ -25,6 +25,12 @@ def daemon_threaded_wrapper(fn):
|
|||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
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...
|
||||
|
@ -40,4 +46,5 @@ builtins.logger = Logger(settings.get_home_config_path(), \
|
|||
|
||||
builtins.threaded = threaded_wrapper
|
||||
builtins.daemon_threaded = daemon_threaded_wrapper
|
||||
builtins.sizeof_fmt = sizeof_fmt_def
|
||||
builtins.event_sleep_time = 0.05
|
||||
|
|
|
@ -20,6 +20,7 @@ class RightBox(Gtk.Box):
|
|||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
@ -33,7 +34,14 @@ class RightBox(Gtk.Box):
|
|||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("background_fill", self._toggle_background)
|
||||
|
||||
def _load_widgets(self):
|
||||
self.add(ButtonControls())
|
||||
self.add(PathLabel())
|
||||
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")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Python imports
|
||||
from os.path import getsize
|
||||
import inspect
|
||||
|
||||
# Lib imports
|
||||
|
@ -74,7 +75,6 @@ class ImageView(ImageViewMixin, Gtk.Image):
|
|||
self.animation = None
|
||||
|
||||
self._stop_animation()
|
||||
event_system.emit("update_path_label", (path,))
|
||||
if path.endswith(".gif"):
|
||||
self.set_as_gif(path)
|
||||
return
|
||||
|
@ -86,6 +86,12 @@ class ImageView(ImageViewMixin, Gtk.Image):
|
|||
self.set_as_static(path)
|
||||
|
||||
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:
|
||||
self._fit_to_container()
|
||||
else:
|
||||
|
|
|
@ -39,8 +39,7 @@ class PathLabel(Gtk.Label):
|
|||
...
|
||||
|
||||
def update_path_label(self, path = None):
|
||||
if not path:
|
||||
return
|
||||
if not path: return
|
||||
|
||||
self.set_label(path)
|
||||
self.set_tooltip_text(path)
|
||||
|
|
|
@ -11,3 +11,7 @@
|
|||
.button-highlighted {
|
||||
background-color: #AB7E45;
|
||||
}
|
||||
|
||||
.background-fill {
|
||||
background: rgba(39, 43, 52, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue