Create new playlists in front

The "S" or "Q" shortcut will create a new playlist on the front of the
deck, "s" or "q" creates a shortcut on the back of the deck.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-04-10 08:04:29 -04:00
parent 898865293d
commit 97427af922
4 changed files with 25 additions and 12 deletions

View File

@ -17,10 +17,12 @@ namespace libsaria
namespace deck
{
void push_front(Playlist *);
void push_back(Playlist *);
void next();
void prev();
void init();
void new_playlist(list<Track *> &, PlaylistType, bool);
Playlist *get_playlist(unsigned int);
Playlist *get_recent_plist();
void tracks_removed(list<Track> &);
@ -33,7 +35,6 @@ namespace libsaria
Playlist *new_playlist(string, unsigned int);
void set_on_new_playlist(void (*)(Playlist *));
void create_new_playlist(list<Track *> &, PlaylistType);
}; /* Namespace: libsaria */

View File

@ -66,6 +66,11 @@ static void check_pause()
namespace libsaria
{
void deck::push_front(Playlist *plist)
{
playlist_deck.push_front(plist);
}
void deck::push_back(Playlist *plist)
{
list<libsaria::Playlist *>::iterator it;
@ -111,7 +116,7 @@ namespace libsaria
on_new_playlist = func;
}
void create_new_playlist(list<Track *> &tracks, PlaylistType type)
void deck::new_playlist(list<Track *> &tracks, PlaylistType type, bool front)
{
Playlist *plist;
@ -129,7 +134,10 @@ namespace libsaria
plist = new List(PL_NONE);
};
deck::push_back(plist);
if (front)
deck::push_front(plist);
else
deck::push_back(plist);
renumber_playlists();
if (on_new_playlist)

View File

@ -43,7 +43,7 @@ void read_plist(ifstream &stream)
}
if (tracks.size() > 0)
libsaria::create_new_playlist(tracks, (PlaylistType)type);
libsaria::deck::new_playlist(tracks, (PlaylistType)type, false);
}
namespace libsaria

View File

@ -11,7 +11,7 @@ using namespace std;
#define BUTTON_RIGHT 3
static void new_playlist(ocarina::Playlist *plist, PlaylistType type)
static void new_playlist(ocarina::Playlist *plist, PlaylistType type, bool front)
{
list<libsaria::Track *> tracks;
@ -20,7 +20,7 @@ static void new_playlist(ocarina::Playlist *plist, PlaylistType type)
return;
plist->select_none();
libsaria::create_new_playlist(tracks, type);
libsaria::deck::new_playlist(tracks, type, front);
/*
* The new playlist will set the length string text,
* so reset it again here
@ -30,12 +30,12 @@ static void new_playlist(ocarina::Playlist *plist, PlaylistType type)
static void new_queue(GtkMenuItem *menu, gpointer data)
{
new_playlist((ocarina::Playlist *)data, PLIST_QUEUE);
new_playlist((ocarina::Playlist *)data, PLIST_QUEUE, false);
}
static void new_set(GtkMenuItem *menu, gpointer data)
{
new_playlist((ocarina::Playlist *)data, PLIST_SET);
new_playlist((ocarina::Playlist *)data, PLIST_SET, false);
}
static GtkWidget *menu_item(const char *text, void (*func)(GtkMenuItem *, gpointer),
@ -66,10 +66,14 @@ gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
if (key.substr(0, 3) == "KP_")
key = key.substr(3);
if (key == "s" || key == "S")
new_playlist(plist, PLIST_SET);
else if (key == "q" || key == "Q")
new_playlist(plist, PLIST_QUEUE);
if (key == "s")
new_playlist(plist, PLIST_SET, false);
else if (key == "S")
new_playlist(plist, PLIST_SET, true);
else if (key == "q")
new_playlist(plist, PLIST_QUEUE, false);
else if (key == "Q")
new_playlist(plist, PLIST_QUEUE, true);
else if (key >= "0" && key <= "9") {
unsigned int k;
stringstream s(key);