summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-09 19:53:35 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-09 19:53:35 +0100
commit0a46e3d57e5eee8c592f3132a29b09e10d502336 (patch)
treed75b7ba405ce930cfa181f811f8288d28e9b3ce6 /playlist.c
parentc49d78cbab0801dff0ab4bffff29b899a4ba0fff (diff)
adding/removing tabs using context menu
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/playlist.c b/playlist.c
index b276c75f..665e4864 100644
--- a/playlist.c
+++ b/playlist.c
@@ -121,19 +121,30 @@ plt_add (int before, const char *title) {
plt->next = p_after;
playlists_count++;
+ plt_gen_conf ();
+
if (!playlist) {
playlist = plt;
- if (!plt_loading) {
- plug_trigger_event (DB_EV_PLAYLISTSWITCH, 0);
- }
}
-
- plt_gen_conf ();
+ if (!plt_loading) {
+ plug_trigger_event (DB_EV_PLAYLISTSWITCH, 0);
+ }
}
void
plt_remove (int plt) {
int i;
+ if (playlists_head && !playlists_head->next) {
+ trace ("warning: deleting last playlist\n");
+ pl_free ();
+ free (playlist->title);
+ playlist->title = strdup ("Default");
+ plt_gen_conf ();
+ if (!plt_loading) {
+ plug_trigger_event (DB_EV_PLAYLISTSWITCH, 0);
+ }
+ return;
+ }
playlist_t *prev = NULL;
playlist_t *p = playlists_head;
for (i = 0; p && i < plt; i++) {
@@ -152,13 +163,16 @@ plt_remove (int plt) {
}
}
if (p == playlist) {
- playlist = NULL;
+ playlist = prev ? prev : playlists_head;
}
free (p->title);
free (p);
playlists_count--;
plt_gen_conf ();
+ if (!plt_loading) {
+ plug_trigger_event (DB_EV_PLAYLISTSWITCH, 0);
+ }
}
void