Commit Graph

292 Commits

Author SHA1 Message Date
7aad72cd8a curds: Lookup playlist nodes using bisects
The root node isn't sorted, so we still have to visit every node while
doing the lookup.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-10 09:08:09 -04:00
e610a7a078 curds: Remove node.insert_child() function
This function is now unused, since we're using bisection insertion
instead. We switch remaining callers over to using node.append_child()
while we're at it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-10 08:55:12 -04:00
fe181b72a4 curds: Use bisect to find playlist nodes
This lets us find nodes and insertion points all in the same step, so
it's way more efficient

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-03 11:54:08 -04:00
adca6f3813 curds: Return inserted playlist node from __insert_node__()
This is way more useful than returning the index of the node

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-03 11:08:50 -04:00
7991ec44b2 curds: Remove old playlist node less-than operator
We're comparing sort keys directly now, and not nodes

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-03 10:22:47 -04:00
ea64bad17d curds: Remove old __normalize__() function from playlist nodes
It's purpose has been replaced with sort keys

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-03 10:22:37 -04:00
42322e1a40 curds: Have playlists use the new sort.bisect() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-03 10:22:30 -04:00
f4748e63f6 curds: Implement a bisect function in the sorting code
And give it the option to pass extra arguments to sort_key() functions

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 21:22:32 -04:00
ce7b7a4f67 curds: Allow passing values to node.sort_key()
So we can compare keys that have undergone the same transformation

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 20:51:27 -04:00
53ae9ccb6c curds: Use sort keys for inserting playlist nodes
This is slower, but puts things in their right place. Implementing a
bisect search should help speed this up.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 20:36:41 -04:00
48edd46446 curds: Give library playlists a custom sort_key() function
We should have special handling for filesystem paths for sorting

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 20:28:17 -04:00
7455681202 curds: Switch library node to use the find / lookup allocate interface
And rescan paths when they're looked up again.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 20:17:59 -04:00
84c77a25bc curds: Switch decade playlists to the new find / alloc interface
And clean up the unit test while we're at it

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-02 09:00:28 -04:00
78fb399ed6 curds: Switch artist playlists to the new find / alloc interface
And clean up the unit test while we're at it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-01 22:34:06 -04:00
7998a734e4 curds: Switch genre node over to the find_node() / alloc_node() interface
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-01 21:38:05 -04:00
aef622d39b curds: Implement functions for finding and allocating nodes
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-06-01 21:18:07 -04:00
27196c7069 curds: Replace playlist sort_key() with track_key()
Now we don't have to do an extra check for what key we're looking for.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-31 16:35:10 -04:00
93098884b4 curds: Move common sort key functions into a new module
And add a convenience function for normalizing unicode text while we're
at it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-31 15:01:40 -04:00
5292a69a20 curds: Give playlist nodes a sort_key() function
And use it for doing less-than checks

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-31 13:34:01 -04:00
054b9d05c2 curds: Give tracks their own sort_key() function
I'm about to give playlists a sort_key(), so clean up the existing
function first

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-31 11:23:48 -04:00
4d5a347cc0 curds: Add check for adding a track multiple times to a playlist
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-29 14:50:50 -04:00
d5f03710e5 curds: Clean up genre node test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-29 14:09:40 -04:00
6ff1d34d0c curds: Clean up collection playlist test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-29 09:53:33 -04:00
3097e425a4 curds: Clean up previous playlist test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-29 09:31:21 -04:00
5920fa4d8a curds: Clean up user playlist test
Split this up into more focused tests

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-29 09:13:05 -04:00
c569e7baf9 curds: Create a playlist.contains() function
And clean up related code to use this rather than an index == None check

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-27 09:00:15 -04:00
8acd119630 curds: Add a function for moving tracks in a playlist
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 11:08:21 -04:00
214ffab2b7 curds: Add a playlist.remove() function
For removing tracks from playlists

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 11:08:21 -04:00
1e422a1711 curds: Clean up playlist sorting test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 10:02:35 -04:00
213854f3fa curds: Remove playlist.show() function
Let's just set the visible state directly. Additionally, I add a test
for setting visibility back to false when showing a different playlist

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 09:04:50 -04:00
ce269d496d curds: Rewrite playlist loop and random tests
Split these up to make them simpler

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 08:54:20 -04:00
c42d73a902 curds: Rearrange playlist next and peek tests
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-24 08:44:43 -04:00
3e8b69d605 curds: Clean up bisect() and add index() function
This lets us clean up add() so we only need to loop over the list once
and we can remove the buggy built-in iterator code.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-23 16:12:54 -04:00
419e80d983 rind: Clean up playlist track add tests
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-23 15:52:41 -04:00
dc4803eb46 curds: Add playlist tests for __func__() overrides
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-23 10:23:29 -04:00
e7ed3a2777 curds: Do bounds checking in the playlist __getitem__() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-23 10:11:00 -04:00
1060fca929 curds: Improvements to the playlist test
- Create a test_album variable instead of making each test build the
  same path
- Create a single self.plist for test playlists
- Create a helper function for adding tracks

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-23 09:24:41 -04:00
0e74303b13 rind: Clean up playlist view test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-19 21:35:18 -04:00
ac7001c3bf curds: Add helpful playlist shortcuts
- curds.playlist.current() for the currently selected playlist
- curds.playlist.lookup() for lookups

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-17 09:49:52 -04:00
ec86ec7910 curds: Two small playlist improvements
- Make a shortcut to the Starred playlist for the UI
- Always sort playlists, rather than sorting as soon as they become
visible

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-16 21:29:18 -04:00
c42bb04349 curds: Remove unused on_new_playback() callback
This callback no longer exists, so there is no point in testing it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-03 10:32:08 -04:00
ca984ef82a curds: Add a playlist for starred tracks
We need to re-add this playlist to the node after doing a reset since it
is a default playlist.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-02 18:40:57 -04:00
5c2f1c14df curds: Create a node for User playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-02 18:10:14 -04:00
32e2469efb curds: Track playlist visibility
This lets us delay sorting playlists until the first time they are shown
to make adding tracks faster. Additionally, we don't need to send
add-track notifications for playlists that aren't visible.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-02 07:36:32 -04:00
c2484c43ad curds: Pass sort order through Playlist init
This is cleaner than calling the sort function several times, or
overriding the sort_order array after construction.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-02 07:36:32 -04:00
07f5b9b78d curds: Use a bisect for insertion sorts
This drastically cuts down the number of comparisons needed to make an
insertion.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-05-02 07:36:30 -04:00
b6830dc337 curds: Add default sorting orders to each playlist
And disable sorting on the Previous playlist, since doing so would
basically be changing history.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-27 15:28:09 -04:00
d2ae3e3d18 curds: Normalize track fields for sorting
I want to strip out special characters an lowercase the strings for
sorting.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-27 08:40:16 -04:00
10a8eef1fb curds: Add sorting support to playlists
We only support sorting in ascending order, but we take into account
multiple track fields.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-26 17:50:34 -04:00
82cf07ff36 curds: Have the playlist track if loop and random values can change
This way, we control it all from one place instead of needing to derive
a new playlist to set these values. Additionally, the UI can use these
values to enable or disable the corresponding buttons

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-25 14:33:17 -04:00
2d6d4444bf curds: Send next-track notification when changing tracks
This lets the UI know that something changed so scrolling can happen in
the UI.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-25 13:39:38 -04:00
c7d45754a0 curds: Add Album playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-24 09:30:12 -04:00
9ef6c865c6 curds: Add playlists for individual years
They show up nested under the corresponding decade playlist

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-24 09:09:09 -04:00
fb5477da57 curds: Don't hide exceptions during the new-track signal
We need to be able to see what's going on in order to fix the code, so
let's not fail silently and pretend that nothing went wrong.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-24 08:42:52 -04:00
718d44a8d8 curds: Add a way to walk the node tree
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-23 14:11:06 -04:00
e4d96755e9 curds: Make sure PlaylistNode ids are still mapped after a reset
This is mostly in case the node map gets cleared at some point during
testing.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-23 10:44:22 -04:00
8f6be9b6f5 curds: Rename PlaylistManager -> PlaylistRoot
This is the root node of the Playlist Tree, so give it a name reflecting
that.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-22 17:06:16 -04:00
b9ad790abf curds: Reorganize the imports
And instantiate the PlaylistManager instance a little earlier

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-22 17:06:16 -04:00
c834359cdb curds: Keep a map of PlaylistNode ids
Making it easy to look up a PlaylistNode by the python object id means
we can use the object id in the GtkTreeIter rather than storing the
entire path

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-22 17:06:15 -04:00
cfee39ce17 curds: Add a function for finding the root node of the PlaylistNode tree
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-22 08:56:02 -04:00
33e2af2c2d curds: Make sure we're properly setting prev / next pointers
I noticed that the toplevel playlist siblings were always set to None,
so make sure we're properly setting these so they can be used.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-21 10:16:03 -04:00
de9c7b0745 curds: Add the DecadeNode to the PlaylistManager
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-20 13:04:33 -04:00
a8a9dada49 curds: Add a DecadeNode and DecadePlaylist
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-20 12:49:59 -04:00
0eca51eae1 curds: Change genre and artist node icons
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-19 17:00:39 -04:00
68953c273d curds: Add the ArtistNode to the PlaylistManager
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-19 14:46:13 -04:00
42a26832eb curds: Implement an artist playlist node
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-19 14:45:39 -04:00
b2dc1b8c5e curds: Remove GenrePlaylist
It is now unused

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-19 12:17:06 -04:00
14851e0c59 curds: Remove newline from PlaylistNode
I'm going to take a different approach with setting the row heights
directly, so start by removing the newline here.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-19 10:14:58 -04:00
a767cc08b8 curds: Rename PlaylistManager current_changed()
Simply drop the underscores to make the code a little easier to read.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-18 11:55:01 -04:00
dbc7683ccd curds: Move playlist peeking into the Playlist class
It makes more sense to do it here than in the PlaylistManager

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-18 11:48:23 -04:00
277aabb7bd curds: Change the PlaylistManager into a PlaylistNode
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-18 11:00:12 -04:00
cd208134ec curds: Remove direct indexing from the PlaylistManager
The PlaylistNode class doesn't support this, so remove it now.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-18 10:45:07 -04:00
8434446dcd curds: PlaylistManager shouldn't inherit from list
This is just the next step in changing this into a PlaylistNode

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-18 10:38:38 -04:00
8ab2d97cf5 curds: Clean up how nodes are inserted and linked
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 16:57:22 -04:00
91a606e054 curds: Add .parent variable to the PlaylistManager
And then clean up the ManagerModel with the node functions that we can
now use.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 16:14:33 -04:00
8aff4d7f8a curds: Remove the PlaylistManager parent() function
I'm transitioning this class to be a PlaylistNode, and nodes can easily
access their parent through a .parent pointer

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 14:38:36 -04:00
af54734726 curds: Merge the PlaylistManager with the PlaylistManagerBase
Nothing else inherits from this class anymore, so let's merge it into
one to make it easier to deal with going forward.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 13:43:12 -04:00
2c779b475d curds: Remove the PlaylistPlaceholder
It is no longer needed

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 11:08:15 -04:00
b37a36369f curds: Swap out the GenreManager for the GenreNode
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 11:05:38 -04:00
8769423fe8 curds: Remove the placeholder before the Library node
We're putting a newline before the heading, so we don't need an empty
tree row for this.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
eee4e134b0 curds: Swap out the LibraryManager for the LibraryNode
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
c29313dde8 curds: Add a node.has_sibling() function
The UI can use this to determine if this is the first node added to the
parent.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
4fc44832ec curds: Send a notification when a node has been inserted
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
f777a86da9 curds: Make the PlaylistNode easier to access by the UI
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
52f787e483 curds: Create a LibraryNode
For managing library playlists

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
751ad812f3 curds: Implement a GenreNode
This will eventually replace the GenreManager instance, and makes use of
the new playlist node code

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:23 -04:00
0ea715a6d5 curds: Make it possible to cast nodes into a string
We'll use this do display the node in the UI. I add a newline so we
don't have to implement some kind of spacer class.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-17 10:10:20 -04:00
261b08f3f4 curds: Convert the Playlist class into a PlaylistNode
We just make it inherit from the base class

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 13:51:37 -04:00
3a89ff8885 curds: Rename node next and prev
This avoids a conflict with the Playlist class next() function

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 13:51:06 -04:00
3f7a68a37a curds: Add a reset function to the playlist node
This is mostly just used for testing

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 13:37:26 -04:00
3c699dddab curds: Add a lookup function to the playlist node
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 13:31:46 -04:00
d266218b7c curds: Normalize node names before setting
This makes them easier to look up

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 12:13:30 -04:00
0994e8986e curds: Add a way to get a node from its path
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 11:33:11 -04:00
79ab9d3a40 curds: Add a way to find a node's path
A path is a list of indices in the tree, which can easily be translated
into a GtkTreePath

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 11:33:05 -04:00
7aa2244f97 curds: Add a way to get a nodes nth child
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 11:19:50 -04:00
35e02b5732 curds: Add a way to get the node's index
This will be useful for finding the node's path

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 11:19:27 -04:00
80e09d0378 curds: Store the node's parent in the node
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 10:41:40 -04:00
1a01dd9047 curds: Implement a node.append_child() function
Sometimes we just want to append a node instead of inserting it in a
sorted position.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 09:52:50 -04:00
6efc456f0d curds: Implement a node.insert_child() function
This inserts the node in sorted order

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 09:46:22 -04:00
ec6744755d curds: Begin implementing a PlaylistNode
My intention is to try to match the GtkTreeModel interface in terms of
functionality. This way, each node can act as its own iterator.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-16 07:39:49 -04:00
2ae7ac1aa1 curds: Check if the current playlist has changed from a single spot
This helps reduce code duplication, since we can just call a single
function to handle sending the changed() signal.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-15 21:09:28 -04:00
b0d124a0e5 curds: Previous playlist should send playlist-changed
Otherwise we won't update the row in the sidebar with the number of
tracks played.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 20:34:04 -04:00
390f7c4a28 curds: Forbid selecting the Previous playlist
I guess this could be lifted later if anybody asks for it, but I don't
think this really makes sense as a playlist source.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 19:35:19 -04:00
6255e22cf0 curds: Send the playlist-changed notification when changin current
This tells the UI that it needs to update how playlists are displayed.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 19:24:25 -04:00
8a04d63c52 curds: Make it easier to send the playlist-changed notification
We're going to use this to notify that the current playlist has been
changed

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 17:36:37 -04:00
6c0d269b2d curds: Clear the current list when selecting the Collection playlist
The collection playlist always has loop=True, so we'll never pop it from
the stack under normal conditions. Let's clear the list when selecting
this playlist so we don't keep a list of unreachable playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 17:32:41 -04:00
b1521c3d35 curds: Push playlists to the front of the current list
And when we've played all the tracks, remove it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 17:29:00 -04:00
b22ffbf5aa curds: Change PlaylistManager.current into a list
I'm going to keep a list of playlists that have been selected so we can
switch playlists automatically when one ends.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-14 16:37:27 -04:00
d025727f1f curds: Add a function for peeking at the next few tracks
I'm planning to use this for the automatic pausing code to tell the user
how much longer until we pause.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-11 17:16:30 -04:00
a94996b3fa curds: Move the os.remove() onto the same line as the existence check
If everything goes well and the test passes, then this line will never
be reached. Let's move it so it doesn't skew the code coverage report.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-08 14:12:22 -04:00
36ff8414fb curds: Test finding the index of playlists not in the manager
We should make sure this returns None just like we expect.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-08 13:41:44 -04:00
c2d876b545 curds: Also clear queued tasks when resetting
Otherwise we could end up sending notifications that don't make any
sense after their corresponding test ends.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-06 21:17:43 -04:00
0e6b788af1 curds: Improve queueing notifications
The UI might take a while to process queued notifications, so to keep
from overwhelming the UI we want to only queue notification that haven't
been added already.

I also add in a lock around the notification queue since the main thread
processes notifications added by other threads.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-05 13:35:57 -04:00
6c7e063eac curds: Send a notification when a notification is queued
This lets the UI know that it has something to process when it gets the
chance. Additionally, I change the return value of run_queued() to
return false when there are no tasks remaining on the queue.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 13:50:01 -04:00
ad9828c494 curds: Send the "new-playlist" notification after playlists are alloc-ed
Rather than doing this as part of the playlist constructor. This ensures
that the UI is notified AFTER the playlist has been appended to the
PlaylistManager to prevent race conditions.

Additionally, I send the sorted index of the playlist and an indicator
if this is the first playlist added as part of the notification to help
 make the UI's job easier.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 13:30:58 -04:00
b5c15598bc curds: Send a "playlist-changed" notification
The playlist manager doesn't need all the information about what changed
in the playlist, since it's mostly just updating the track count. Let's
just send the playlist so it won't get queued multiple times.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 09:22:35 -04:00
cfbb6cfcd9 curds: Add a Placeholder() instance to the playlist manager
This isn't intended to hold playlists. Instead, it represents extra
spacing between playlists for the UI.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:58:41 -04:00
2cf0ad8df9 curds: Replace the Library.add() function with a lookup
This makes the user's intentions a little more explicit, and saves us a
couple of lines of code.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:55:07 -04:00
084567e3b8 curds: Create the PlaylistManagerBase class
This replaces the PlaylistAllocator, and provides a true base class that
can be used by each type of playlist manager.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:55:05 -04:00
ebabf1a479 curds: Replace string indexing with a lookup function
This matches how we handle playlist lookups for the other playlist
managers.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:02:37 -04:00
6a0d793fa7 curds: Convert PlaylistManager into a list
This lines up with how we handle the Library and Genre managers, and it
seems best to keep things consistent. For now, I keep string-indexing
implemented but I plan to switch over to numeric indexing soon.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:02:37 -04:00
5a88fac10a curds: Add a way to get parent playlists from the playlist manager
We can figure this out a little easier on the backend side, so let's
handle this there rather than on the UI side

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 16:02:29 -04:00
a3fa8f1526 curds: Create a GenrePlaylist class
This should make the UI side easier, since we can check against the
playlist type when searching for the playlist.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-01 20:26:39 -04:00
2aa530119a curds: Title case Genre playlist names
This way we group together tracks that have the same genres but with
different casing.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 15:36:32 -04:00
5c0e468c71 curds: Create a generic PlaylistAllocator class
This class contains code shared by the GenerManager and LibraryManager
classes.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 09:12:53 -04:00
f4032aaf07 curds: Add a genre playlist
This uses the genre field in each track to make automatic playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 09:12:09 -04:00
d95809c233 curds: Use folder-music for the toplevel library heading
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-28 14:14:40 -04:00
071c356dbc 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>
2019-03-27 16:16:08 -04:00
685b78cbf9 curds: Add stop() and reset() functions
Reset is used to make testing a little easier, since we won't have to
manually set set everything up again during each setUp function.

Stop is used to stop the library thread before shutdown.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 11:18:15 -04:00
918f76663c curds: Declassify notifications
Keeping this as a class that can never be instantiated seems like
overkill when we could just use plain functions.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 09:49:40 -04:00
89a4daedf3 curds: Rename Notify.notify_me() -> Notify.register()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 09:27:29 -04:00
93206b95b2 curds: Rename Notify.notify_cancel() -> Notify.cancel()
It's a little less wordy and redundant this way

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 09:21:52 -04:00
92817e1e7a curds: Remove Notify.clear()
And switch callers over to using notify_cancel()

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 09:17:01 -04:00
35e5cd1095 curds: Pass track index to the add-track notification
This eases up some of the work on the UI side, since we don't need to
spend time trying to figure out where the track is in the playlist.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-26 15:33:58 -04:00
e38e6ae1b4 curds: Push some notifications onto a queue
Gtk really doesn't like updates coming from outside of the main thread,
so let's add a way to register callbacks that can be queued up and run
later.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-26 14:26:22 -04:00
5c267c8a9d curds: Add helpful library functions
This adds some convenience around controlling the library thread.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-26 11:20:01 -04:00
f715945536 curds: Add a tags.clear() function
This makes it a little easier to reset the tags before running a new
test.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-26 10:55:01 -04:00
3afffc54d4 curds: Add the Previous playlist to the playlist manager
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-23 13:43:54 -04:00
c794faf95c curds: Add a Previous playlist
This playlist is designed to hold all the tracks that have been selected
for playback, and iterate through them backwards if needed.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-23 10:15:17 -04:00
a5535a5daa curds: Set collection random value through the Playlist class
We still fix the value, but if we ever add extra handling in the base
class then we'll be able to catch it.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-23 10:13:59 -04:00
f765536c86 curds: Don't loop len(1) playlists
We need to check if looping is true, even if length is one, before
setting the current index.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-23 10:12:14 -04:00
754a8beadd curds: Add exception handling for invalid tracks
Users might have images or ripping logs mixed in with their tracks, so
let's make sure we don't crash if we try to scan one of these.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-20 10:12:02 -04:00
c636b3fd5e rind: More icon and spacing changes
I switch around the sidebar icons again, and also make the header bar
icons larger to make them easier to press with touchscreens

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-20 09:58:06 -04:00
eb5b32893d curds: Change collection icon to audio-x-generic
This is a little larger than the emblem, so I think it'll look better

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-19 12:12:26 -04:00
9341a56f11 curds: Change Library Playlist icons folder-music
Library paths are directories on disk, so it makes sense to use the
folder-music icon to represent them.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-19 11:22:20 -04:00
b642e762f7 curds: Add a next() function to the PlaylistManager
I'll eventually make this more complex when I add in more playlists, but
for now it just calls next on the Collection playlist

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-18 17:15:16 -04:00
9f690ae204 curds: Make it easier for the UI to access the LibraryPlaylist class
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-17 10:59:09 -04:00
524af59ec1 curds: Improve the LibraryManager
I change it to a sorted list for easier indexing by the UI iterators.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-17 10:58:44 -04:00
0873f0458c curds: Add a less than operator for playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-17 10:58:14 -04:00
4c256f7656 curds: Add playlist to string formatting
We could do this in the UI, but it's almost easier to implement in the
backend.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-16 09:17:22 -04:00