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>
Rather than going through playlist-type operations. Additionally, I
take this opportunity to change playlist_remove() to take a playlist
struct directly.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Rather than going through playlist-type operations. Additionally, I
take this opportunity to change playlist_add() to take a playlist struct
directly.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Rather than going through the playlist-type operations. Additionally, I
take this opportunity to change playlist_delete() to take a playlist
struct directly.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is much more useful than a boolean status, since we can use the
playlist pointer right away.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
It's frequently useful to get the playlist directly, rather than looking
up type and name first. Let's add a function to do just that!
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This pointer can be used immediately by testing code instead of simply
looking at the return status.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is useful for user playlists so they can store their playlist-id
directly, letting us remove the entire playlist_get_id() function.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This flag was only used by the History playlist, but we have a noop
function to handle this instead.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This patch also adds a unit test checking that the image is initialized
properly. In addition, I simplify things by changing the image widget
to be a direct child of the GtkButton.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This code is obsolete now that gui/playlist.c handles keypress and
right-click events on the main treeview.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function isn't easy to test without knowledge of screen
coordinates, so I didn't include a unit test this time.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Putting this code in a new file helps make gui/playlist.c less complex,
and better matches the organization of files in core/
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Finding the header first makes a lot of sense, and avoids iterating
through every playlist while trying to find the library playlist to
update.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This functionality needs to be tested better. I can't really test the
dialog, since it runs in the main thread, but I can test adding library
paths with the selected directory.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This code is obsolete now that the sidebar handles setting the random
button when playlists are changed.
Implements #76: Remove struct gui_queue
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function scans through the treestore at the current level, without
descending into children. This is because we frequently know what
category playlists are under when searching for a child, so it makes
sense to find that first.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Called to access the GtkPaned widget. I also rename the widget
"sidebar" to match the new convention.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Otherwise we may try to use the gstreamer playbin after destroying it,
leading to various error messages showing up in the console.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I decided to manually connect signals this time so I can pass sort
information instead of needing to look up the column index.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And rename the widget from "o_treeview" to just "treeview".
I wanted to rename gui/view.c to gui/treeview.c at some point. I
decided to gradually rework things into a new file to make it easier to
track progress.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This keeps the treepath conversions contained to the filter code when
finding paths to scroll to.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Right now filtering is split between queue.c and view.c, which can make
things somewhat complicated. I think this is a sign that we need a new
file to manage filtering.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Ocarina is moving in a playlist oriented direction, so move away from
using the queue directly in favor of using the playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This only needs to happen once, so let's do it when we initialize the
model rather than waiting for the first allocation.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is going to represent a playlist soon enough, so let's just name it
something more generic in case it ever has to change again.
Implements #87: Rename GuiQueueModel -> GuiModel
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is cleaner and easier than calling into the gtk builder directly.
I bumped up the window layer so other gui components can use it.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is called to get the requested playlist. I also reworked
playlist_get_queue() to call this function.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Valgrind told me that all calls to g_assert_cmpstr_free() weren't
actually freeing the string. A closer look shows that if we pass a
function as "lhs" then the function will be called twice, allocating
twice as much memory.
Fix this by storing the result of lhs in a temporary variable so
functions are only ever called once.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This lets up update track keys to prevent duplicates showing up during a
library path update.
Fixes#93: Library sometimes has duplicated tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Sometimes database entry keys change, so this gives us a way to update
them in the database keys hash table.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This was added so tracks could bump the libary tag size. Now that the
size field has been removed, we can remove this function.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This makes file versioning way easier, since every file will have the
same version. I'll still need to manage minimum-supported versions, but
that shouldn't be too difficult going forward.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
These can be used for version number comparisons as integers, which will
be useful once file version numbers are based off of minor versions.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Databases can change either as part of an upgrade or through adding and
removing entries. We can save a bit of memory by removing unallocated
entries during startup.
Implements #47: Automatic database defragment
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This was used to display the number of tracks in each library path. We
can use playlist functions to get this information now.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This was used to enable and disable library paths in previous Ocarina
versions. This isn't used anymore now that we have library-based
playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The track tag doesn't need these tags now that they can be found in the
album tag.
Implements #64: Remove Artist and Genre pointers from Tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Artist and genre information are already saved by the album tag. In
addition, we can save a single date stamp instead of (year, day, month)
triplets.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And perform an upgrade when reading back in. After track tags are read,
we can save the database in the new format and remove the old tags.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And propegate these through the alloc steps to create an album with the
correct artist and genre tags set.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The date stamp is a single value that represents year, month, and day.
This should be slightly easier than working with three separate values.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Removing items from the database leaves a NULL pointer "hole" that is
never filled in. This doesn't affect correctness, but it could be
wasteful as items are added and removed. This patch adds a function to
defragment the database without changing the order of items.
Implements #66: Add support for rebalancing databases
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I plan to change the file format of some tags, so add versioning so we
can change things at different times.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is needed to handle track database defragmentation, but could also
be expanded on later to save playlists from a generic place.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This function loads playlist information from a single file, falling
back to multi-file loading if playlist.system doesn't exist yet.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I query the underlying playlist to see if it is selectable, and then
update the settings file if it is.
Implements #10: Select default playlist
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I need to have integer playlist ids to store into the settings database
once I allow changing the default playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Right now tracks are picked from this playlist whenever possible. A
system for selecting the default playlist will be added shortly.
Implements #20: Only one queue for "Up Next"
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The view is now responsible for allocating the filter, but the gui_queue
still needs to set the filter function during an init step.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Now that we can switch between different queues we no longer need to
allocate multiple models.
Implements #72: Only allocate a single GuiQueueModel for all playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The dbe_index of a given database item might change in the future, so we
can't rely on it everywhere. Let's just use it for saving and loading
files, with the expectation that changes will happen sometime after
startup.
Implements #69: Reduce use of dbe_index in Ocarina code
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Three unsigned integers is overkill for handling dates.
Implements #65: Date structure can be represented with a single 32bit
value
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Albums tend to have a single genre for all tracks, so it makes more
sense for an album to point to genre information.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
- Define __queue_filter_how_changed() for tests that need queue
callback functions
- Increase column sizes in the view test to make test more reliable
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Library playlists call this when deleting tracks, otherwise we could end
up dereferencing invalid pointers the next time we use the artist
playlist.
Fixes#81: Remove deleted tracks from artist playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This patch also adds the genre field to the list of fields that can be
searched.
Implements #62: Replace filter layer with token matching
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This is called to check if any string in an artist's token list is
prefixed by the given string.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>