emmental/emmental/sidebar/genre.py
Anna Schumaker 0f2a5aee9d sidebar: Create a Section for Genres
This section uses the default Row for displaying genre playlists. I use
the theater icon from the gnome icon-library as the section header.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2023-04-12 15:06:49 -04:00

29 lines
879 B
Python

# Copyright 2022 (c) Anna Schumaker.
"""Displays our genre playlists."""
from .. import db
from . import row
from . import section
class GenreRow(row.TreeRow):
"""A TreeRow for displaying Genre playlists."""
def __init__(self, *args, **kwargs):
"""Initialize a GenreRow."""
super().__init__(*args, indented=False, **kwargs)
self.child = row.Row()
class Section(section.Section):
"""A sidebar Section for the genre list."""
def __init__(self, table: db.genres.Table):
"""Initialize our Genre section."""
super().__init__(table, GenreRow, icon_name="theater",
title="Genres", subtitle="0 genres")
def do_get_subtitle(self, n_genres: int) -> str:
"""Return a subtitle for this section."""
s_genres = "s" if n_genres != 1 else ""
return f"{n_genres} genre{s_genres}"