ocarina: Check if 0 songs were added to a playlist

If nothing was selected then we should tell the window to change tabs
instead.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-09-04 10:49:36 -04:00
parent 7d4977aab8
commit ef55c2f44a
1 changed files with 12 additions and 5 deletions

View File

@ -144,7 +144,7 @@ static void track_selected(GtkWidget *treeview, GtkTreePath *path,
track->load(true);
}
static void move_cursor(GtkTreeView *treeview, string &key)
static void move_cursor(GtkTreeView *treeview, const string &key)
{
GtkTreePath *path;
@ -205,18 +205,19 @@ static void new_playlist(string &key, GtkTreeView *treeview, bool front)
libsaria::deck::new_playlist(tracks, PLIST_QUEUE, front);
}
static void add_to_playlist(GtkTreeView *treeview, int n)
static bool add_to_playlist(GtkTreeView *treeview, int n)
{
list<libsaria::Track *> tracks;
libsaria::Playlist *playlist;
list_selected_tracks(treeview, &tracks);
if (tracks.size() == 0)
return;
return false;
playlist = libsaria::deck::get_playlist(n);
if (playlist)
playlist->add_tracks(tracks);
return true;
}
static void ban_selected(GtkTreeView *treeview, bool state)
@ -241,6 +242,12 @@ static void delete_from_playlist(GtkTreeView *treeview)
}
list_selected_indices(treeview, &indices);
if (indices.back() == (playlist->get_size() - 1))
move_cursor(treeview, "k");
else
move_cursor(treeview, "j");
playlist->remove_indices(indices);
libsaria::deck::garbage_collect();
}
@ -274,8 +281,8 @@ bool playlist_key_pressed(GtkTreeView *treeview, string &key)
else if (key == "S" || key == "Q")
new_playlist(key, treeview, true);
else if (key >= "0" && key <= "9")
add_to_playlist(treeview, atoi(key.c_str()));
else if (key == "Delete")
return add_to_playlist(treeview, atoi(key.c_str()));
else if (key == "Delete" || key == "d")
delete_from_playlist(treeview);
else if (key == "Return")
on_return_key(treeview);