From 41fb08c059159dbd690f40cd9fe96fa44e3349f7 Mon Sep 17 00:00:00 2001 From: Wojciech Nawrocki Date: Sat, 19 Sep 2020 22:56:22 -0400 Subject: [PATCH] notify: allow displaying progress --- lib/solaar/ui/notify.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/solaar/ui/notify.py b/lib/solaar/ui/notify.py index 0cb0a34c..80bf7493 100644 --- a/lib/solaar/ui/notify.py +++ b/lib/solaar/ui/notify.py @@ -103,8 +103,10 @@ if available: except Exception: _log.exception('showing %s', n) - def show(dev, reason=None, icon=None): - """Show a notification with title and text.""" + def show(dev, reason=None, icon=None, progress=None): + """Show a notification with title and text. + Optionally displays the `progress` integer value + in [0, 100] as a progress bar.""" if available and Notify.is_initted(): summary = dev.name @@ -130,6 +132,8 @@ if available: urgency = Notify.Urgency.LOW if dev.status else Notify.Urgency.NORMAL n.set_urgency(urgency) n.set_hint('desktop-entry', GLib.Variant('s', NAME.lower())) + if progress: + n.set_hint('value', GLib.Variant('i', progress)) try: # if _log.isEnabledFor(_DEBUG):