curds: Replace new-library-playlist with new-playlist notification
We have a find_playlist() function, so let's stick with a more generic notification name so we don't have to repeat a lot of code. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
9633e20de5
commit
071c356dbc
|
@ -21,7 +21,6 @@ class LibraryManager(list):
|
|||
plist = library.LibraryPlaylist(path)
|
||||
self.append(plist)
|
||||
self.sort()
|
||||
notify.notify("new-library-playlist", plist)
|
||||
return plist
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ class Playlist():
|
|||
self.loop = False
|
||||
self.random = False
|
||||
|
||||
notify.notify("new-playlist", self)
|
||||
|
||||
def __getitem__(self, i):
|
||||
return self.list[i]
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
def setUp(self):
|
||||
tags.clear()
|
||||
library.reset()
|
||||
notify.register("new-library-playlist", self.on_new_library)
|
||||
notify.register("new-playlist", self.on_new_playlist)
|
||||
|
||||
try:
|
||||
self.playman.reset()
|
||||
|
@ -27,10 +27,10 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
notify.cancel("new-track", self.playman["Collection"].add)
|
||||
notify.cancel("new-library-playlist", self.on_new_library)
|
||||
notify.cancel("new-playlist", self.on_new_playlist)
|
||||
library.stop()
|
||||
|
||||
def on_new_library(self, plist):
|
||||
def on_new_playlist(self, plist):
|
||||
self.cb_plist = plist
|
||||
|
||||
def test_manager_init(self):
|
||||
|
|
|
@ -10,7 +10,7 @@ class ManagerModel(GObject.GObject, Gtk.TreeModel):
|
|||
def __init__(self, *args, **kwargs):
|
||||
GObject.GObject.__init__(self)
|
||||
curds.notify.register("add-track", self.on_add_track, queue=True)
|
||||
curds.notify.register("new-library-playlist", self.on_new_library, queue=True)
|
||||
curds.notify.register("new-playlist", self.on_new_playlist, queue=True)
|
||||
|
||||
def can_select_path(self, selection, model, path, current):
|
||||
plist = self.iter_playlist(self.get_iter(path))
|
||||
|
@ -84,6 +84,8 @@ class ManagerModel(GObject.GObject, Gtk.TreeModel):
|
|||
def find_playlist(self, plist):
|
||||
if plist != None:
|
||||
if isinstance(plist, curds.LibraryPlaylist):
|
||||
if not plist in curds.PlaylistManager["Library"]:
|
||||
return None
|
||||
iter = self.iter_nth_child(None, toplevel.index("Library"))
|
||||
index = curds.PlaylistManager["Library"].index(plist)
|
||||
return self.iter_nth_child(iter, index)
|
||||
|
@ -105,12 +107,12 @@ class ManagerModel(GObject.GObject, Gtk.TreeModel):
|
|||
if iter:
|
||||
self.row_changed(self.get_path(iter), iter)
|
||||
|
||||
def on_new_library(self, plist):
|
||||
def on_new_playlist(self, plist):
|
||||
iter = self.find_playlist(plist)
|
||||
if iter != None:
|
||||
self.row_inserted(self.get_path(iter), iter)
|
||||
if len(curds.PlaylistManager["Library"]) == 1:
|
||||
parent = self.iter_parent(iter)
|
||||
parent = self.iter_parent(iter)
|
||||
if self.iter_n_children(parent) == 1:
|
||||
self.row_has_child_toggled(self.get_path(parent), parent)
|
||||
Treeview.expand_to_path(self.get_path(parent))
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ toplevel_plist = [ plist_mgr["Collection"], plist_mgr["Previous"], None, plist_m
|
|||
class TestManager(unittest.TestCase):
|
||||
def setUp(self):
|
||||
curds.reset()
|
||||
curds.notify.register("add-track", manager.MgrModel.on_add_track)
|
||||
curds.notify.register("new-library-playlist", manager.MgrModel.on_new_library)
|
||||
curds.notify.register("add-track", manager.MgrModel.on_add_track, queue=True)
|
||||
curds.notify.register("new-playlist", manager.MgrModel.on_new_playlist, queue=True)
|
||||
|
||||
def tearDownClass():
|
||||
curds.stop()
|
||||
|
@ -127,6 +127,8 @@ class TestManager(unittest.TestCase):
|
|||
|
||||
plist = plist_mgr["Library"].add(test_album)
|
||||
curds.playlist.library.join()
|
||||
while curds.notify.run_queued():
|
||||
continue
|
||||
|
||||
self.assertIsInstance(selection, Gtk.TreeSelection)
|
||||
selection.select_path(path)
|
||||
|
|
Loading…
Reference in New Issue