playlist: Make the currently playing track bold

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-07-17 21:27:26 -04:00
parent b1ece1cd1d
commit dece303a09
2 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# Copyright 2021 (c) Anna Schumaker.
from lib import settings
from gi.repository import Gtk
from gi.repository import Gtk, GLib
import audio
class Column(Gtk.ColumnViewColumn):
def __init__(self, title, field, width=-1, expand=False, align=0):
@ -28,7 +29,10 @@ class Column(Gtk.ColumnViewColumn):
def on_bind(self, factory, listitem):
track = listitem.get_item()
listitem.get_child().set_text(track[self.field])
text = GLib.markup_escape_text(track[self.field])
if track == audio.Player.track:
text = f"<b>{text}</b>"
listitem.get_child().set_markup(text)
listitem.get_child().set_xalign(self.align)
def on_setup(self, factory, listitem):

View File

@ -3,6 +3,7 @@ from . import controls
from . import runtime
from lib import bus
from gi.repository import GObject, Gio
import audio
class TagModel(GObject.GObject, Gio.ListModel):
def __init__(self, tag=None):
@ -11,6 +12,7 @@ class TagModel(GObject.GObject, Gio.ListModel):
self.bus = bus.Bus(1)
self.items = [ ]
self.__set_tag__(tag)
audio.Player.TrackChanged.register(self.on_tracks_changed)
def __set_tag__(self, tag):
self.tag = tag
@ -62,3 +64,9 @@ class TagModel(GObject.GObject, Gio.ListModel):
def track_removed(self, tag, track, pos):
self.bus.board(self.do_track_removed, tag, track, pos)
def on_tracks_changed(self, prev, new):
if prev in self.items:
self.items_changed(self.items.index(prev), 1, 1)
if new in self.items:
self.items_changed(self.items.index(new), 1, 1)