2021-06-16 09:47:07 -04:00
|
|
|
# Copyright 2021 (c) Anna Schumaker.
|
2021-12-09 17:49:40 -05:00
|
|
|
import audio
|
2021-12-05 12:05:33 -05:00
|
|
|
import db
|
2021-06-16 09:47:07 -04:00
|
|
|
from gi.repository import Gtk
|
2021-10-13 13:13:57 -04:00
|
|
|
from . import stack
|
2021-06-16 09:47:07 -04:00
|
|
|
|
2021-10-12 15:55:00 -04:00
|
|
|
class Sidebar(Gtk.Box):
|
2021-11-04 14:55:08 -04:00
|
|
|
def __init__(self, panel):
|
2021-10-12 15:55:00 -04:00
|
|
|
Gtk.Box.__init__(self)
|
2021-11-04 14:55:08 -04:00
|
|
|
self.panel = panel
|
2021-10-12 15:55:00 -04:00
|
|
|
switcher = stack.Switcher()
|
2021-12-05 12:05:33 -05:00
|
|
|
box = stack.Box(switcher.get_stack())
|
2021-11-04 14:55:08 -04:00
|
|
|
|
2021-10-12 15:55:00 -04:00
|
|
|
self.append(switcher)
|
2021-12-05 12:05:33 -05:00
|
|
|
self.append(box)
|
2021-11-04 14:55:08 -04:00
|
|
|
|
|
|
|
stak = switcher.get_stack()
|
|
|
|
stak.connect("playlist-changed", self.playlist_changed)
|
|
|
|
panel.set_playlist(stak.get_visible_child().get_selected_playlist())
|
2021-12-05 12:05:33 -05:00
|
|
|
box.get_add_update_button().connect("add-to-playlist", self.add_to_playlist)
|
2021-11-04 14:55:08 -04:00
|
|
|
|
|
|
|
def playlist_changed(self, stack, plist):
|
|
|
|
self.panel.set_playlist(plist)
|
2021-12-05 12:05:33 -05:00
|
|
|
|
|
|
|
def add_to_playlist(self, button, playlist):
|
|
|
|
if playlist.can_add_remove_tracks():
|
2021-12-09 19:25:16 -05:00
|
|
|
self.panel.add_selected_tracks(playlist)
|