diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-02-09 19:53:35 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-02-09 19:53:35 +0100 |
commit | 0a46e3d57e5eee8c592f3132a29b09e10d502336 (patch) | |
tree | d75b7ba405ce930cfa181f811f8288d28e9b3ce6 /playlist.c | |
parent | c49d78cbab0801dff0ab4bffff29b899a4ba0fff (diff) |
adding/removing tabs using context menu
Diffstat (limited to 'playlist.c')
-rw-r--r-- | playlist.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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 |