Commit Graph

75 Commits

Author SHA1 Message Date
Bryan Schumaker 29718ceb12 libsaria: Remove operator[] for int values
Public access to these variables is easier.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 83f8b1e543 libsaria: Don't use random if playlist size == 1
This could cause a floating point exception when I mod-by-zero...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-11 14:03:53 -05:00
Bryan Schumaker 5e456ad64c libsaria: Tune random next()
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-08 08:10:17 -05:00
Bryan Schumaker 33c80788b8 libsaria: Rewrite playlist filtering
I used to use my own inverted index implementation, which makes sense if
I'm searching all songs for a specific match.  Instead, GTK was visiting
each track and asking "does this song match?" and this requires a
different implementation.  So rather than make an index, instead I have
each track generate substrings for its tags and then I compare filter
text against the substring set.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-04 09:17:22 -05:00
Bryan Schumaker e1930b0c88 libsaria: Create functions for checking and setting flags
I also replace a few PLAYLIST_* notifications with a generic
PLAYLIST_CHANGED notification for when small changes occur.  I think
that using set_flag() and check_flag() will make code cleaner and easier
to maintain.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 22:58:26 -04:00
Bryan Schumaker a6fa805a53 libsaria: Move next() into playlist.cpp
I don't want to keep one function in a file by itself.  Instead, let's
just move it into the main playlist file.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 21:48:29 -04:00
Bryan Schumaker d345d3211f libsaria: Remove the old remove_track_it() function
I can make this simplier by simply passing the index into the vector,
rather than needing to calculate the iterator and pass the index.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 17:03:16 -04:00
Bryan Schumaker 52c09ddb12 libsaria: Don't track playlist length
There is no reason to track this on my own, iterating over all tracks
and calculating it on the fly is easier and basically unnoticable.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 15:59:54 -04:00
Bryan Schumaker d9e343895c libsaria: Clean up picking the next song from a playlist
I don't need to iterate through a linked list to find the track anymore.
Instead, I can access tracks directly using an index.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 15:36:09 -04:00
Bryan Schumaker cf8ded7d5d libsaria: Remove name field from playlists
I know what playlists are library, recent and banned.  All others are
just named "Playlist" so there is no need to set up a name variable.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 15:34:13 -04:00
Bryan Schumaker b98373c0fa libsaria: Convert Playlist class to use a vector
Vectors are more straightforward than linked lists and they should allow
me to clean up the code a lot.  For now I just put in the straight
conversion, I'll clean things up in future patches.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-02 23:00:20 -04:00
Bryan Schumaker c67222ab95 libsaria: Remove remaining PlaylistRenderer code
I didn't realize this was still around.  It should be removed since I
switched to a notification system instead of using the renderer.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-02 21:43:32 -04:00
Bryan Schumaker 9933b31353 libsaria: Sort the playlist when setting PL_SORT
Otherwise the flag seems to have no effect until new songs are added.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-17 08:16:59 -04:00
Bryan Schumaker bf5b8a3bdd libsaria: Remove PlaylistType in favor of flags
Flags let me manually set properties after the playlist has been
created, rather than needing to decide upfront with no way of converting
to something else.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-14 20:25:09 -04:00
Bryan Schumaker 258875bdb8 libsaria: Move header files out of include/libsaria/
Ocarina no longer has a header file subdirectory so there is no reason
to have a libsaria subdirectory anymore.  Putting header files directly
in the include/ directory is a bit simpler.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-12 08:15:31 -04:00
Bryan Schumaker 5be817167b ocarina: Return index of searched track
And not the index of the current iterator.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-06 12:02:15 -04:00
Bryan Schumaker 11b685aeb0 libsaria: Remove playlist renderer
I have notifications to handle everything the renderer used to do, and
I've removed it from the UI side.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-05 09:22:43 -04:00
Bryan Schumaker 50b4198001 Add a PLAYLIST_DISABLE notification
Disabled playlists are ignored when picking the next song.  I grey-out
the widgets on the UI when this notification is received.  I keep
filtering enabled this time (the entry was disabled too in Ocarina 5.9)

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-04 09:21:02 -04:00
Bryan Schumaker c46671b1fb Create a PLAYLIST_GOTO notification
To move the cursor to the current song.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-03 12:14:54 -04:00
Bryan Schumaker 9fb1d05376 Remove PLAYLIST_FILTER notification
It's easier to refilter automatically after setting the filter text,
rather than going through a bunch of function pointers to change the filter.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-03 11:02:46 -04:00
Bryan Schumaker 5bce295251 Add a PLAYLIST_DELETE notification
Triggered when a playlist is garbage collected so the UI can remove the
tab.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-02 13:35:48 -04:00
Bryan Schumaker 26e818cc21 Send a PLAYLIST_RENUMBER notification
I do this when playlists are renumbered, I also move tabs around to
match their new numbers.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-02 13:06:18 -04:00
Bryan Schumaker a985ff70a9 Create a PLAYLIST_UPDATE notification
This notification is sent when a track in the playlist is updated, such
as when the play count is incremented.  I also remove the
track_updated() functions from the library renderer and ocarina::Playlist.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-08-30 10:44:48 -04:00
Bryan Schumaker 69687ac6c6 libsaria: Remove obsolete renderer functions
Dynamic playlists are disabled right now, so I'm making use of this time
to clear out old code.  This patch removes library renderer functions
that have already been reimplemented.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-08-30 09:28:07 -04:00
Bryan Schumaker b8f2ffdf48 Add a LIBRARY_FILTER notification
I also enable filtering on the new library tab.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-08-26 10:27:40 -04:00
Bryan Schumaker 9b6665030a Create a new Library playlist tab
This tab is appended at the end of the notebook, so it looks as if there
are two Library tabs.  I'm going to use notifications and GtkBuilder on
the new tab to remove the PlaylistRenderer and to hopefully make adding
new features easier.  Right now only inserting tracks into the
LibraryPlist works, and I eventually want to remove the LibraryPlist
liststore in favor of a custom treemodel.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-08-24 08:35:25 -04:00
Bryan Schumaker ce6782558d libsaria: Bugfix Track playlist list
I was sometimes trying to remove a playlist from an invalid pointer.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-05-19 20:32:08 -04:00
Bryan Schumaker ca9f3e6cf9 Show the play count in the playlist renderer
I created a new renderer function for updating tracks when they change.
Using this, I can show the new playcount of tracks as it is incremented.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-05-19 19:47:11 -04:00
Bryan Schumaker 973b5d3d31 Save playlist disabled status to file
This allows me to restore it when restarting ocarina.  I also need to
notify the renderer that the playlist status has changed so I can change
the button state.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-05-18 11:51:52 -04:00
Bryan Schumaker 35d71efe58 Disable temporary playlists
When a playlist is disabled I won't pick songs from it until the user
re-enables it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-05-18 11:25:51 -04:00
Bryan Schumaker 60d2e4fcd8 libsaria: Save temporary playlists
I do this whenever the playlist changes (tracks added, removed or
playlist renumbered).  When playlists are deleted I remove the file.  I
also remove the file when new_number < cur_number.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:20 -04:00
Bryan Schumaker 235ac70033 libsaria: Move filter code
From index.cpp to filter.cpp.  I also added in an "is_visible()"
function for testing visibility of tracks.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:20 -04:00
Bryan Schumaker 7820b28534 libsaria: Search the index
And notify the renderer to update

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:20 -04:00
Bryan Schumaker bc800057e0 libsaria: Expand on numbered playlists
- Renumber when new playlists are either added or removed
- Finding nth playlist is much easier now
- Insert new playlists right before the library

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:19 -04:00
Bryan Schumaker 4e046beb20 libsaria: Introduce playlist numbers
To track where in the deck they are.  Displaying and modifying them
comes next...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:19 -04:00
Bryan Schumaker e0ebe4c97f libsaria: Track the length of playlists
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker 691f74ee10 libsaria: Return nth renderer
Useful for switching to a specific list in the UI

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker 5a272ef62e libsaria: Playlists know their own type
Useful for dynamically renaming them (see next patch).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker ee2191fc4f libsaria: Scroll playlist when iterator is reset
This allows me to scroll the recent tracks list back to the beginning.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker acef058afa libsaria: Tell playlist renderers to goto a specific index
I want to use this to scroll the library list when a new song is picked.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker 3b3beb4625 libsaria: Track recent songs using a playlist
This way people can see what has played recently and directly select
from a list.  Generic playlist classes are awesome!

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker e5b91a5de9 libsaria: Remove commented out playlist code
I don't think I need any of it anymore.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker 3f665712a1 Remove empty playlists when picking next song
Hopefully with fewer problems than 5.7 had...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:18 -04:00
Bryan Schumaker c5a84807be libsaria: Remove InFile and OutFile classes
I do this all through either appdir or Read / Write tasks

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker ac3964de01 libsaria: Randomly pick next song from library
I'll eventually allow more playlists to be stacked, but for now picking
from the library is easy.  I may eventually add in a way to pick
sequentially from a set.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker 6bb3cd38a4 libsaria: Notify playlist renderers when new tracks are added
For sets, I keep a sorted list and merge-sort the new songs.  I also
created insert_prepare() and insert_done() functions to tell the UI that
we are about to insert (this gives me a chance to call the
freeze_child_notify() and thaw_child_notify() in GTK).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker abac8883c3 libsaria: Give playlists a name
Right now this must be set when a new playlist is constructed.  I can
eventually change this to use a default name based on what type of
playlist has been created.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker b1eb47006d libsaria: Move the renderer into the playlist namespace
This makes more sense to me conceptually than having a class called
PlaylistRenderer.  I also commented out a lot of code, so the renderer
doesn't do anything right now.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker 29cb7f7a47 libsaria: Create a static playlist for the library
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker dfb5c09260 libsaria: Remove most of the playlist class
I'm going to clean it up too, so I've removed everything for now to
slowly re-add later.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00