Users may make typos in naming playlists, or they might think up better
names for playlists later. Let's be friendly and give users a way to
change playlist names if desired.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This way we don't need to keep including the same core libraries in
almost every file.
Implements #83: Include useful headers in core/core.h
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The core_init_data only held three items, most of which don't get set
during testing. Removing this struct means several tests no longer need
to define a "dummy" initdata object to pass around during init.
Implements #92: Remove core_init_data
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And make them optional, that way tests don't need to keep creating fake
callbacks if they don't need anything from the audio layer.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Rather than offering two init functions for testing. This lets the UI
select if they want async idle tasks (like Album Art fetching).
Implements #90: Give idle_init an async flag
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Users might not remember any sorting or random settings from the last
time they queued tracks, so saving these values could result in
selecting tracks in an unexpected order. Fix this by resetting the
queued tracks options whenever the playlist is emptied.
Fixes#108: Unset random and sorting when finishing queued tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
These fields were working fine for statically initialized playlists, but
they get set to garbage values when g_malloc()-ing a playlist. Let's
make sure they get initialized properly with the rest of the playlist.
Fixes#107: Initialize all values in playlist_generic_init()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Everything has been merged into the playlist layer to better match how
playlists are actually used. This means we can remove the queue files.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Artist and library playlists are allocated manually, so there should be
generic functions that both can use to get a playlist pointer and free
it when we're done.
I also add a callback for telling the UI when new playlists have been
allocated. This isn't needed for Library playlists, but this is the
only way the UI can know about new Artists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Sometimes we want to initialize the playlist with sort data, other times
we don't. This gives us functions we can call for both!
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And change its type to gchar **. This lets the playlist code manage
setting and freeing search strings. The UI is still responsible for
how this string is used.
This patch also lets me remove the now-unused queue_deinit() function
and associated callback.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The iterator only needs to point to the current position on the GQueue,
so we can do away with manual position tracking. This lets us use a
GList pointer as an iterator instead of something more complicated.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I keep using the queue_iter struct for now to reduce code churn in this
patch. I'll be replacing it in the next patch.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I also take this chance to add extra functions for directly manipulating
the current track, since this is something we do fairly often.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function adds a track directly to the front of the playlist,
without any existence checks. This lets us use it for the History
playlist, which allows multiple tracks.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I can reuse the "removed" callback to for this, rather than implementing
a new "cleared" callback directly.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
We can make use of g_queue_find() to find the track for us, and then
convert its return value into a boolean.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Rather than iterating over the entire playlist ourselves, we can instead
use the g_queue_remove_all() function to do most of the work for us and
then send an appropriate number of "removed" callbacks.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function simply triggers the "updated" callback for the given
playlist and track. I updated the gui model to handle taking tracks
instead of row indexes, since this lets me reuse the same for-each
function that we do for sorting. Additionally, this prevents UI updates
for playlists that aren't currently visible.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I move the random variable into the playlist code since it is no longer
used by the queue layer. This gives me the opportunity to change it
into a boolean rather than a bit flag.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Let's have the playlist generic functions pick the next track rather
than redirecting to the queue code.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
In most cases this function just triggers a UI update, but system
playlists have a little extra bookkeeping to do to remove the track from
the Queued Tracks playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function is called to force-sort the playlist. Additionally, we
trigger the "playlist-sorted" callback to to notify the gui that
playlist rows need to be updated.
Additionally, I implement the gui_model_update_all() function to loop
over the model and update all rows of the current playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This replaces the "reset" field that had been passed to sort. I think
this makes things a little more straightforward, and gives us a function
we can call when freeing playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function uses the playlist save flags enum to determine what
exactly to save, including support for backwards compatibility with
6.4.x playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function uses the playlist save flags enum to determine what
exactly to load, including support for backwards compatibility with
6.4.x playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This was only used by system playlists to keep the unplayed, most played,
and least played playlist up to date. We can handle this internally
through the playlist_played() handler.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is used to notify when tracks have been played so dynamic playlists
can be updated, and so the model can display the correct playcount.
The old system playlist tests are mostly unnecessary at this point, so I
remove them as part of this patch.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Allowing us to access the playlist directly, rather than going through
the playlist-type interface.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And stores it for future reference, so we don't have to keep looking up
current and previous playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is much more straightforward than converting an id to a name and
then looking up playlists from there. This patch removes the now-unused
playlist_get_name() function.
This patch also lets me simplify the system playlist unit test, since I
can now check several similar operations using a loop. Additionally, I
change calls to pl_system_lookup() into pl_system_get() for efficiency.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I think "lookup" is a better name for this function, since it's similar
to performing a dictionary lookup.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Additionally, it also uses a playlist-level function pointer to decide
what to do. In most cases this calls the generic sort function, but the
history playlist should never be sorted.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Additionally, playlist_set_random() uses a playlist-level function
pointer to decide what to do. In most cases this will simply toggle the
flag, but the history playlist does not support random playback.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>