Create a PLAYLIST_RM notification
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
7483aa3c4f
commit
e9f8c34e5a
|
@ -12,6 +12,7 @@ enum notify_t {
|
|||
PAUSE_TYPE, // AutoPauseType *
|
||||
PAUSE_COUNT, // unsigned int *
|
||||
PLAYLIST_ADD, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_RM, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_SIZE, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_FILTER,// libsaria::PlaylistNotification *
|
||||
NOTIFY_SIZE,
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace libsaria
|
|||
(*it)->rm_playlist(this);
|
||||
it = plist.erase(it);
|
||||
RENDER( remove_index(rm_index) );
|
||||
notify_ui(PLAYLIST_RM, (*it), rm_index);
|
||||
notify_ui(PLAYLIST_SIZE, NULL, 0);
|
||||
if (rm_index != 0) {
|
||||
rm_index--;
|
||||
|
|
|
@ -24,6 +24,7 @@ void on_notify(notify_t event, void *data)
|
|||
update_autopause_count((unsigned int *)data);
|
||||
break;
|
||||
case PLAYLIST_ADD:
|
||||
case PLAYLIST_RM:
|
||||
case PLAYLIST_SIZE:
|
||||
case PLAYLIST_FILTER:
|
||||
update_playlist(event, (libsaria::PlaylistNotification *)data);
|
||||
|
|
|
@ -96,6 +96,18 @@ static struct PlaylistWidgets *find_widgets(libsaria::Playlist *plist)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void set_playlist_length(libsaria::Playlist *playlist)
|
||||
{
|
||||
stringstream stream;
|
||||
unsigned int size = playlist->get_size();
|
||||
stream << size << " song";
|
||||
if (size != 1)
|
||||
stream << "s";
|
||||
if (size != 0)
|
||||
stream << ": " << libsaria::length_string(playlist->get_length());
|
||||
update_length_label(stream.str());
|
||||
}
|
||||
|
||||
static void playlist_add(libsaria::Playlist *plist, libsaria::Track *track,
|
||||
unsigned int index)
|
||||
{
|
||||
|
@ -117,16 +129,14 @@ static void playlist_add(libsaria::Playlist *plist, libsaria::Track *track,
|
|||
-1);
|
||||
}
|
||||
|
||||
static void set_playlist_length(libsaria::Playlist *playlist)
|
||||
static void playlist_rm(libsaria::Playlist *plist, unsigned int index)
|
||||
{
|
||||
stringstream stream;
|
||||
unsigned int size = playlist->get_size();
|
||||
stream << size << " song";
|
||||
if (size != 1)
|
||||
stream << "s";
|
||||
if (size != 0)
|
||||
stream << ": " << libsaria::length_string(playlist->get_length());
|
||||
update_length_label(stream.str());
|
||||
GtkTreeIter iter;
|
||||
PlaylistWidgets *widgets = find_widgets(plist);
|
||||
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(widgets->liststore), &iter, NULL, index);
|
||||
gtk_list_store_remove(widgets->liststore, &iter);
|
||||
if (plist == current_playlist())
|
||||
set_playlist_length(plist);
|
||||
}
|
||||
|
||||
static void set_playlist_size(libsaria::Playlist *plist)
|
||||
|
@ -153,6 +163,8 @@ void update_playlist(notify_t event, libsaria::PlaylistNotification *data)
|
|||
{
|
||||
if (event == PLAYLIST_ADD)
|
||||
playlist_add(data->plist, data->track, data->index);
|
||||
else if (event == PLAYLIST_RM)
|
||||
playlist_rm(data->plist, data->index);
|
||||
else if (event == PLAYLIST_SIZE)
|
||||
set_playlist_size(data->plist);
|
||||
else if (event == PLAYLIST_FILTER)
|
||||
|
|
Loading…
Reference in New Issue