28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# Copyright 2023 (c) Anna Schumaker.
|
|
"""An object for managing the visible and active playlists."""
|
|
from gi.repository import GObject
|
|
from .. import db
|
|
|
|
|
|
class Factory(GObject.GObject):
|
|
"""Our playlist model factory."""
|
|
|
|
sql = GObject.Property(type=db.Connection)
|
|
|
|
db_active = GObject.Property(type=db.playlist.Playlist)
|
|
db_previous = GObject.Property(type=db.playlist.Playlist)
|
|
db_visible = GObject.Property(type=db.playlist.Playlist)
|
|
|
|
def __init__(self, sql: db.Connection):
|
|
"""Initialize the Playlist Factory."""
|
|
super().__init__(sql=sql)
|
|
self.sql.bind_property("active-playlist", self, "db-active")
|
|
self.connect("notify", self.__notify_db_playlists)
|
|
|
|
def __notify_db_playlists(self, factory: GObject.GObject, param) -> None:
|
|
match param.name:
|
|
case "db-active" | "db-previous" | "db-visible":
|
|
plist = self.get_property(param.name)
|
|
name = "<None>" if plist is None else plist.name
|
|
print(f"factory: {param.name[3:]} playlist is:", name)
|