emmental/sidebar/__init__.py
Anna Schumaker 3a50235c38 audio: Rework the Artwork widget
It now sets artwork based on the signals sent by the player, allowing us
to move it out of the Player class and create instances based on the
global Player instead.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-09-08 10:07:45 -04:00

67 lines
2.0 KiB
Python

# Copyright 2021 (c) Anna Schumaker.
from . import library
from . import pulser
from . import tagbox
from . import user
from lib import settings
from gi.repository import Gtk
import audio
import tagdb
Switcher = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
Stack = Gtk.Stack()
Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
#
# Add pages to the Stack and set up the switcher toggles
#
Toggles = [ ]
Switcher.add_css_class("osd")
Switcher.add_css_class("linked")
Switcher.add_css_class("large-icons")
Stack.set_transition_type(Gtk.StackTransitionType.OVER_UP_DOWN)
def initialize():
settings.initialize("sidebar.page", "Libraries")
initialize()
def switch_page(toggle):
if toggle.get_active():
Stack.set_visible_child_name(toggle.get_name())
settings.set("sidebar.page", toggle.get_name())
def on_tag_push_pop(old, new):
old.widgets.set_label()
new.widgets.set_label()
tagdb.Stack.PushPop.register(on_tag_push_pop)
def add_stack_page(name, page):
toggle = Gtk.ToggleButton()
toggle.set_icon_name(page.icon)
toggle.set_vexpand(True)
toggle.set_name(name)
toggle.connect("toggled", switch_page)
if len(Toggles) > 0:
toggle.set_group(Toggles[0])
Toggles.append(toggle)
Switcher.append(toggle)
Stack.add_named(page, name)
toggle.set_active(settings.get("sidebar.page") == name)
add_stack_page("Playlists", user.TagBox)
add_stack_page("Artists", tagbox.ParentTagBox(tagdb.tags.Artist, "avatar-default-symbolic",
tagdb.tags.Album, "media-optical", header=True))
add_stack_page("Genres", tagbox.TagBox(tagdb.tags.Genre, "emblem-generic", header=True))
add_stack_page("Decades", tagbox.ParentTagBox(tagdb.tags.Decade, "x-office-calendar",
tagdb.tags.Year, "x-office-calendar-symbolic"))
add_stack_page("Libraries", library.Box)
Box.append(audio.Artwork())
Box.append(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL))
Box.append(Stack)
Box.append(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL))
Box.append(pulser.Box)