From c1ed748a912539bb47cd2453e56fc2211dec955e Mon Sep 17 00:00:00 2001 From: DYefremov Date: Fri, 17 Apr 2026 00:56:53 +0300 Subject: [PATCH] add custom progress bar class --- app/ui/uicommons.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py index 802e768e..4dfb75a6 100644 --- a/app/ui/uicommons.py +++ b/app/ui/uicommons.py @@ -434,5 +434,27 @@ MOVE_KEYS = {KeyboardKey.UP, KeyboardKey.PAGE_UP, KeyboardKey.HOME_KP, KeyboardKey.END_KP, KeyboardKey.PAGE_UP_KP, KeyboardKey.PAGE_DOWN_KP} + +class LoadingProgressBar(Gtk.ProgressBar): + """ A custom class for a progress bar. + + Used as an alternative to Gtk.Spinner to reduce CPU load. + """ + __gtype_name__ = "LoadingProgressBar" + + def __init__(self, **properties): + super().__init__(**properties) + + self.connect("notify::visible", self.on_visible) + + def on_visible(self, bar, param): + if self.get_visible(): + GLib.timeout_add(500, self.update, priority=GLib.PRIORITY_LOW) + + def update(self): + self.pulse() + return self.get_visible() + + if __name__ == "__main__": pass