diff options
-rw-r--r-- | deadbeef.h | 2 | ||||
-rw-r--r-- | main.c | 5 | ||||
-rw-r--r-- | playlist.c | 36 | ||||
-rw-r--r-- | playlist.h | 5 | ||||
-rw-r--r-- | plugins/gtkui/fileman.c | 19 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 6 |
6 files changed, 44 insertions, 29 deletions
@@ -376,7 +376,7 @@ typedef struct { void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in); int (*pl_add_file) (const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data); int (*pl_add_dir) (const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data); - void (*pl_add_files_begin) (void); + void (*pl_add_files_begin) (int playlist); void (*pl_add_files_end) (void); DB_playItem_t *(*pl_insert_item) (DB_playItem_t *after, DB_playItem_t *it); DB_playItem_t *(*pl_insert_dir) (DB_playItem_t *after, const char *dirname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data); @@ -231,12 +231,13 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi } } // add files - if (!queue && plt_get_curr () != -1) { + int curr_plt = plt_get_curr (); + if (!queue) { pl_clear (); pl_reset_cursor (); } if (parg < pend) { - deadbeef->pl_add_files_begin (); + deadbeef->pl_add_files_begin (curr_plt); } while (parg < pend) { char resolved[PATH_MAX]; @@ -96,6 +96,8 @@ static int pl_order; // mirrors "playback.order" config variable static int no_remove_notify; +static playlist_t *addfiles_playlist; // current playlist for adding files/folders; set in pl_add_files_begin + void pl_set_order (int order) { if (pl_order != order && (pl_order == PLAYBACK_ORDER_SHUFFLE_TRACKS || PLAYBACK_ORDER_SHUFFLE_ALBUMS)) { @@ -706,16 +708,21 @@ plt_move (int from, int to) { } void -pl_clear (void) { +plt_clear (playlist_t *plt) { LOCK; - while (playlist->head[PL_MAIN]) { - pl_remove_item (playlist->head[PL_MAIN]); + while (plt->head[PL_MAIN]) { + pl_remove_item (plt->head[PL_MAIN]); } - playlist->current_row[PL_MAIN] = -1; - playlist->current_row[PL_SEARCH] = -1; + plt->current_row[PL_MAIN] = -1; + plt->current_row[PL_SEARCH] = -1; UNLOCK; } +void +pl_clear (void) { + plt_clear (playlist); +} + static const uint8_t * pl_str_skipspaces (const uint8_t *p, const uint8_t *end) { while (p < end && *p <= ' ') { @@ -1429,7 +1436,7 @@ pl_insert_file (playItem_t *after, const char *fname, int *pabort, int (*cb)(pla it->filetype = "content"; it->_duration = -1; pl_add_meta (it, "title", NULL); - after = pl_insert_item (after, it); + after = plt_insert_item (addfiles_playlist, after, it); pl_item_unref (it); return after; } @@ -1551,7 +1558,7 @@ pl_insert_dir (playItem_t *after, const char *dirname, int *pabort, int (*cb)(pl int pl_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data) { int abort = 0; - playItem_t *it = pl_insert_file (playlist->tail[PL_MAIN], fname, &abort, cb, user_data); + playItem_t *it = pl_insert_file (addfiles_playlist->tail[PL_MAIN], fname, &abort, cb, user_data); if (it) { // pl_insert_file doesn't hold reference, don't unref here return 0; @@ -1562,7 +1569,7 @@ pl_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *use int pl_add_dir (const char *dirname, int (*cb)(playItem_t *it, void *data), void *user_data) { int abort = 0; - playItem_t *it = pl_insert_dir (playlist->tail[PL_MAIN], dirname, &abort, cb, user_data); + playItem_t *it = pl_insert_dir (addfiles_playlist->tail[PL_MAIN], dirname, &abort, cb, user_data); if (it) { // pl_insert_file doesn't hold reference, don't unref here return 0; @@ -1571,11 +1578,14 @@ pl_add_dir (const char *dirname, int (*cb)(playItem_t *it, void *data), void *us } void -pl_add_files_begin (void) { +pl_add_files_begin (int plt) { + addfiles_playlist = plt_get (plt); + printf ("adding to playlist %d (%s)\n", plt, addfiles_playlist->title); } void pl_add_files_end (void) { + addfiles_playlist = NULL; } int @@ -1744,7 +1754,7 @@ plt_insert_item (playlist_t *playlist, playItem_t *after, playItem_t *it) { playItem_t * pl_insert_item (playItem_t *after, playItem_t *it) { - return plt_insert_item (playlist, after, it); + return plt_insert_item (addfiles_playlist ? addfiles_playlist : playlist, after, it); } void @@ -2219,7 +2229,9 @@ pl_load (const char *fname) { return -1; } GLOBAL_LOCK; - pl_clear (); + playlist_t *plt = playlist; + + plt_clear (plt); // try plugins 1st const char *ext = strrchr (fname, '.'); @@ -2412,7 +2424,7 @@ pl_load (const char *fname) { pl_add_meta (it, key, value); } } - pl_insert_item (playlist->tail[PL_MAIN], it); + plt_insert_item (plt, plt->tail[PL_MAIN], it); pl_item_unref (it); it = NULL; } @@ -148,7 +148,7 @@ int pl_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data); void -pl_add_files_begin (void); +pl_add_files_begin (int plt); void pl_add_files_end (void); @@ -162,6 +162,9 @@ pl_insert_file (playItem_t *after, const char *fname, int *pabort, int (*cb)(pla playItem_t * pl_insert_item (playItem_t *after, playItem_t *it); +playItem_t * +plt_insert_item (playlist_t *playlist, playItem_t *after, playItem_t *it); + int pl_remove_item (playItem_t *i); diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index 874ffb2c..d4ffb518 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -10,10 +10,8 @@ void gtkpl_add_dir (DdbListview *ps, char *folder) { - g_idle_add (gtkui_progress_show_idle, NULL); gtkui_original_pl_add_dir (folder, gtkui_add_file_info_cb, NULL); g_free (folder); - g_idle_add (gtkui_progress_hide_idle, NULL); } static void @@ -24,9 +22,10 @@ gtkpl_adddir_cb (gpointer data, gpointer userdata) { void gtkpl_add_dirs (GSList *lst) { + deadbeef->plt_lock (); + deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ()); if (g_slist_length (lst) == 1 && deadbeef->conf_get_int ("gtkui.name_playlist_from_folder", 0)) { - deadbeef->plt_lock (); int plt = deadbeef->plt_get_curr (); if (plt != -1) { char t[1000]; @@ -41,12 +40,11 @@ gtkpl_add_dirs (GSList *lst) { } } } - deadbeef->plt_unlock (); } - g_idle_add (gtkui_progress_show_idle, NULL); + deadbeef->plt_unlock (); g_slist_foreach(lst, gtkpl_adddir_cb, NULL); g_slist_free (lst); - g_idle_add (gtkui_progress_hide_idle, NULL); + deadbeef->pl_add_files_end (); } static void @@ -57,10 +55,10 @@ gtkpl_addfile_cb (gpointer data, gpointer userdata) { void gtkpl_add_files (GSList *lst) { - g_idle_add (gtkui_progress_show_idle, NULL); + deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ()); g_slist_foreach(lst, gtkpl_addfile_cb, NULL); g_slist_free (lst); - g_idle_add (gtkui_progress_hide_idle, NULL); + deadbeef->pl_add_files_end (); } static void @@ -83,6 +81,7 @@ add_files_worker (void *data) { void gtkui_add_files (struct _GSList *lst) { + deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ()); intptr_t tid = deadbeef->thread_start (add_files_worker, lst); deadbeef->thread_detach (tid); } @@ -164,7 +163,7 @@ set_dnd_cursor_idle (gpointer data) { void gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist")); - g_idle_add (gtkui_progress_show_idle, NULL); + deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ()); DdbListviewIter first = NULL; DdbListviewIter after = NULL; @@ -212,7 +211,7 @@ gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) { } free (ptr); - g_idle_add (gtkui_progress_hide_idle, NULL); + deadbeef->pl_add_files_end (); g_idle_add (set_dnd_cursor_idle, first); } diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 22f8a1be..d95592cf 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -1085,7 +1085,7 @@ gtkui_add_file_info_cb (DB_playItem_t *it, void *data) { int (*gtkui_original_pl_add_dir) (const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data); int (*gtkui_original_pl_add_file) (const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data); -void (*gtkui_original_pl_add_files_begin) (void); +void (*gtkui_original_pl_add_files_begin) (int plt); void (*gtkui_original_pl_add_files_end) (void); int @@ -1101,9 +1101,9 @@ gtkui_pl_add_file (const char *filename, int (*cb)(DB_playItem_t *it, void *data } void -gtkui_pl_add_files_begin (void) { +gtkui_pl_add_files_begin (int plt) { g_idle_add (gtkui_progress_show_idle, NULL); - gtkui_original_pl_add_files_begin (); + gtkui_original_pl_add_files_begin (plt); } void |