curds: Rename Notify.notify_me() -> Notify.register()

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-03-27 09:27:29 -04:00
parent 93206b95b2
commit 89a4daedf3
12 changed files with 19 additions and 19 deletions

View File

@ -21,7 +21,7 @@ class Notify:
if len(cb) == 0:
Notify.notifications.pop(name)
def notify_me(name, func, queue=False):
def register(name, func, queue=False):
cb = Notify.notifications.setdefault(name, [])
if func in [ n[0] for n in cb ]:
return

View File

@ -5,7 +5,7 @@ from .. import notify
class CollectionPlaylist(playlist.Playlist):
def __init__(self):
playlist.Playlist.__init__(self, "Collection", "media-playback-start")
notify.Notify.notify_me("new-track", self.add)
notify.Notify.register("new-track", self.add)
self.loop = True
def set_loop(self, loop):

View File

@ -17,7 +17,7 @@ class TestPlaylistManager(unittest.TestCase):
def setUp(self):
tags.clear()
library.reset()
notify.Notify.notify_me("new-library-playlist", self.on_new_library)
notify.Notify.register("new-library-playlist", self.on_new_library)
self.playman = manager.PlaylistManager()
self.cb_plist = None

View File

@ -11,7 +11,7 @@ test_library = os.path.abspath("./trier/Test Library")
class TestPlaylist(unittest.TestCase):
def setUp(self):
tags.clear()
notify.Notify.notify_me("add-track", self.on_add)
notify.Notify.register("add-track", self.on_add)
self.cb_plist = None
self.cb_track = None
self.cb_index = None

View File

@ -10,7 +10,7 @@ test_album = os.path.abspath("./trier/Test Library/Test Artist 01/Test Album 1")
class TestPreviousPlaylist(unittest.TestCase):
def setUp(self):
notify.Notify.notify_me("add-track", self.on_add_track)
notify.Notify.register("add-track", self.on_add_track)
self.cb_plist = None
self.cb_track = None
self.cb_index = 0

View File

@ -22,11 +22,11 @@ class TestNotify(unittest.TestCase):
self.assertEqual(notify.Notify.notifications, {})
self.assertEqual(notify.Notify.queue, [])
notify.Notify.notify_me("on-test", self.on_test1)
notify.Notify.register("on-test", self.on_test1)
self.assertEqual(notify.Notify.notifications, {"on-test" : [ (self.on_test1, False) ]})
notify.Notify.notify_me("on-test", self.on_test1, True)
notify.Notify.notify_me("on-test", self.on_test2)
notify.Notify.notify_me("on-test", self.on_test3, True)
notify.Notify.register("on-test", self.on_test1, True)
notify.Notify.register("on-test", self.on_test2)
notify.Notify.register("on-test", self.on_test3, True)
self.assertEqual(notify.Notify.notifications, {"on-test" : [ (self.on_test1, False),
(self.on_test2, False),
(self.on_test3, True ) ]})

View File

@ -9,7 +9,7 @@ album_info = {"album" : [ "Test Album" ], "albumartist" : [ "Test Artist" ],
class TestAlbumTag(unittest.TestCase):
def setUp(self):
tags.clear()
notify.Notify.notify_me("new-album", self.on_new_album)
notify.Notify.register("new-album", self.on_new_album)
self.cb_album = None
def tearDown(self):

View File

@ -9,7 +9,7 @@ test_tracks = os.path.abspath("./trier/Test Album")
class TestTrackTag(unittest.TestCase):
def setUp(self):
tags.clear()
notify.Notify.notify_me("new-track", self.on_new_track)
notify.Notify.register("new-track", self.on_new_track)
self.cb_track = None
def tearDown(self):

View File

@ -9,8 +9,8 @@ toplevel = [ "Collection", "Previous", None, "Library" ]
class ManagerModel(GObject.GObject, Gtk.TreeModel):
def __init__(self, *args, **kwargs):
GObject.GObject.__init__(self)
curds.Notify.notify_me("add-track", self.on_add_track, queue=True)
curds.Notify.notify_me("new-library-playlist", self.on_new_library, queue=True)
curds.Notify.register("add-track", self.on_add_track, queue=True)
curds.Notify.register("new-library-playlist", self.on_new_library, queue=True)
def can_select_path(self, selection, model, path, current):
plist = self.iter_playlist(self.get_iter(path))

View File

@ -10,7 +10,7 @@ class PlaylistModel(GObject.GObject, Gtk.TreeModel):
def __init__(self, *args, **kwargs):
GObject.GObject.__init__(self)
self.playlist = curds.PlaylistManager["Collection"]
curds.Notify.notify_me("add-track", self.on_add_track, queue=True)
curds.Notify.register("add-track", self.on_add_track, queue=True)
RandomButton.connect("toggled", self.on_random_toggled)
def do_get_column_type(self, col):

View File

@ -13,11 +13,11 @@ class TestGst(unittest.TestCase):
def setUp(self):
curds.PlaylistManager["Collection"].list.clear()
curds.PlaylistManager["Library"].clear()
curds.Notify.notify_me("new-track", curds.PlaylistManager["Collection"].add)
curds.Notify.register("new-track", curds.PlaylistManager["Collection"].add)
self.audio = gst.EmmentalAudio()
self.state = None
curds.Notify.notify_me("state-changed", self.on_state_changed)
curds.Notify.register("state-changed", self.on_state_changed)
def setUpClass():
gst.Audio.disconnect()

View File

@ -19,9 +19,9 @@ class TestManager(unittest.TestCase):
curds.PlaylistManager["Collection"].list.clear()
curds.PlaylistManager["Previous"].list.clear()
curds.PlaylistManager["Library"].clear()
curds.Notify.notify_me("new-track", curds.PlaylistManager["Collection"].add)
curds.Notify.notify_me("add-track", manager.MgrModel.on_add_track)
curds.Notify.notify_me("new-library-playlist", manager.MgrModel.on_new_library)
curds.Notify.register("new-track", curds.PlaylistManager["Collection"].add)
curds.Notify.register("add-track", manager.MgrModel.on_add_track)
curds.Notify.register("new-library-playlist", manager.MgrModel.on_new_library)
curds.playlist.library.reset()
def tearDown(self):