41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
# Copyright 2021 (c) Anna Schumaker.
|
|
from gi.repository import Gtk
|
|
|
|
Runtime = Gtk.Label()
|
|
Runtime.set_halign(Gtk.Align.END)
|
|
Runtime.set_hexpand(True)
|
|
|
|
Visible = Gtk.Label()
|
|
Visible.set_halign(Gtk.Align.START)
|
|
Visible.set_hexpand(True)
|
|
|
|
def set_runtime(seconds):
|
|
res = [ ]
|
|
m, s = divmod(seconds, 60)
|
|
h, m = divmod(m, 60)
|
|
d, h = divmod(h, 24)
|
|
if d > 0:
|
|
res.append(f"{d} day{'s' if d != 1 else ''}")
|
|
if h > 0:
|
|
res.append(f"{h} hour{'s' if h != 1 else ''}")
|
|
if m > 0:
|
|
res.append(f"{m} minute{'s' if m != 1 else ''}")
|
|
if s > 0 or seconds == 0:
|
|
res.append(f"{s} second{'s' if s != 1 else ''}")
|
|
Runtime.set_text(", ".join(res))
|
|
set_runtime(0)
|
|
|
|
def set_visible_count(count):
|
|
if count == 1:
|
|
Visible.set_text(f"Showing {count} track")
|
|
else:
|
|
Visible.set_text(f"Showing {count} tracks")
|
|
set_visible_count(0)
|
|
|
|
|
|
Box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
|
Box.set_margin_start(5)
|
|
Box.set_margin_end(5)
|
|
Box.append(Visible)
|
|
Box.append(Runtime)
|