Commit Graph

1334 Commits

Author SHA1 Message Date
Anna Schumaker 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
Anna Schumaker 56f7930032 rind: Don't spawn multiple idle sources when tasks are queued
We don't want to overload the application with multiple idle sources
running in parallel.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-05 10:27:54 -04:00
Anna Schumaker 07d1e1e113 rind: Clean up playlist manager selection test
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 15:19:18 -04:00
Anna Schumaker 9af3d251c1 rind: Start idle processing when a task has been queued
And stop the idle source when all tasks have been processed.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 13:50:27 -04:00
Anna Schumaker 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
Anna Schumaker 8781ab1b3a rind: Make use of the new information in "new-playlist"
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 13:31:02 -04:00
Anna Schumaker 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
Anna Schumaker 791e126ace rind: Listen for the "playlist-changed" notification
We ask for the notification to be placed on the queue so multiple
changes to the same playlist will get batched together.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-04 09:28:04 -04:00
Anna Schumaker 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
Anna Schumaker 4b1ef863b8 rind: Make sure we test manger get_iter(), get_path(), and get_value()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-03 20:54:35 -04:00
Anna Schumaker b65a6d9929 rind: Rewrite playlist manager unittest
I was having some trouble when adding in a GtkTreeModelFilter, so I
figured a good first step is to make sure we're testing the TreeModel
properly

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-03 17:53:44 -04:00
Anna Schumaker 8c755300be rind: Clean up find_playlist() and iter_playlist() functions
Now that we can use direct indexing on the PlaylistManager, let's
simplify these functions. Additionally, I implemented an iter_valid()
function to help determin if we have a valid Gtk.TreeIter.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-03 17:50:32 -04:00
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 71c77d0d09 rind: Fix up add library button test
I was having some problems with this test, so hopefully it's more
reliable this way.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-04-02 08:21:24 -04:00
Anna Schumaker 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
Anna Schumaker fe3863a977 rind: Show and hide the GtkSeparator with the search entry
The separator is only one pixel wide, but it was still noticable when
the search entry was hidden. Hiding it too just makes things look nicer.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-31 20:12:13 -04:00
Anna Schumaker f6a016f74d rind: Add an entry for searching playlists
The actual search function isn't implemented yet. We show or hide this
widget based on the up / down button state.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-31 14:37:45 -04:00
Anna Schumaker c6f8a48b0d rind: add an up / down toggle button
I'm going to use this to show and hide the text entries for playlist
filtering and autopause controls.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-31 14:18:14 -04:00
Anna Schumaker ace07b74eb rind: More UI refinements
- Change top left controls into a buttonbox
- Change new library button to list-add-symbolic
- Remove "can focus" from buttons
- Make play / pause / next / previous buttons pill-shaped and
homogeneous

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-31 11:07:53 -04:00
Anna Schumaker d69661ef3b rind: Give the new library button the "osd" style class
This style class is for on-screen-display widgets, which lines up with
how we're using this button.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-31 09:36:19 -04:00
Anna Schumaker 215ebb8653 rind: Add volume button
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-30 17:26:02 -04:00
Anna Schumaker ff3b9c4b5a rind: Add a New Libray button
Clicking the button shows a popover with a file chooser widget, which
can be used to select a library path.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-30 17:25:25 -04:00
Anna Schumaker b03877129d rind: Make play / pause / next / previous buttons circular
I think this looks a little nicer. While I'm at it, I also shove all the
headerbar widgets into two boxes packed on either side.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-30 09:25:06 -04:00
Anna Schumaker d77b1a9c09 rind: Only expand library playlist paths when added
Otherwise genres fill the list and make everything look cluttered.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 15:39:47 -04:00
Anna Schumaker 85f07fea36 rind: Escape playlist names
Otherwise gtk will complain about unescaped markup.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 15:37:12 -04:00
Anna Schumaker 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
Anna Schumaker 277edca3e5 rind: Don't change playlist selection if no rows are selected
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 15:10:01 -04:00
Anna Schumaker d89ffd3910 rind: Combine Genre and Library playlist manager tests
They were almost identical, so this saves quite a bit of duplication
effort.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 14:59:07 -04:00
Anna Schumaker 82dca84a9e rind: Add Genre playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 14:29:13 -04:00
Anna Schumaker faaf640bea rind: Clean up playlist manager tests
I simplify most of the code and make it easier to add more playlists in
the future.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 14:00:53 -04:00
Anna Schumaker 2c078a3d21 rind: Fixes for playlists that aren't in the toplevel
- do_iter_parent() needs to return None if there is no parent playlist
- do_iter_next() needs to increment user_data2 for lower level playlists
  instead of user_data1

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-29 09:50:02 -04:00
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker ce4011c069 rind: Fix up automatically picking the next track
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-28 14:14:16 -04:00
Anna Schumaker 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
Anna Schumaker 9633e20de5 rind: Set fixed-height-mode on the playlist treeview
Now that we push row_added notifications into the main thread, we can
enable this optimization that makes the treeview more efficient.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 11:20:13 -04:00
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 89a4daedf3 curds: Rename Notify.notify_me() -> Notify.register()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-27 09:27:29 -04:00
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 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
Anna Schumaker 332cd89fee rind: Check notifications from the main thread
Gtk really doesn't like notifications coming from other threads, so we
need to handle notifications from the main thread through an idle task.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-26 14:56:57 -04:00
Anna Schumaker 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