scanner: Set initial ProgressBar visibility based on queue length

ProgressBars might be created after tasks have been pushed onto the
queue. Instead of setting initial visibility to False unconditionally,
we can check if queue length is greater than 1

Fixes: Issue #9 (Fix ProgressBar initial visibility)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-10-13 13:51:16 -04:00
parent 53c61160bc
commit 3afaea664b
2 changed files with 2 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class TestScannerProgressBar(unittest.TestCase):
for i in range(3): q.push(FakeTask())
self.assertTrue(pb.get_visible())
self.assertTrue(widgets.ProgressBar(q).get_visible())
for i in [ 1, 2, 0 ]:
q.run()

View File

@ -16,7 +16,7 @@ class ProgressBar(Gtk.ProgressBar):
self.set_valign(Gtk.Align.CENTER)
self.set_hexpand(True)
self.set_visible(False)
self.set_visible(len(queue.tasks) > 0)
def on_task_pushed(self, queue, task):
self.set_visible(True)