summaryrefslogtreecommitdiff
path: root/apps/tagtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c83
1 files changed, 73 insertions, 10 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 7321e9df49..b92e4cb93c 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -81,6 +81,8 @@ static const char *strp;
81static int current_offset; 81static int current_offset;
82static int current_entry_count; 82static int current_entry_count;
83 83
84static struct tree_context *tc;
85
84static int get_token_str(char *buf, int size) 86static int get_token_str(char *buf, int size)
85{ 87{
86 /* Find the start. */ 88 /* Find the start. */
@@ -745,6 +747,7 @@ static int load_root(struct tree_context *c)
745 struct tagentry *dptr = (struct tagentry *)c->dircache; 747 struct tagentry *dptr = (struct tagentry *)c->dircache;
746 int i; 748 int i;
747 749
750 tc = c;
748 c->currtable = root; 751 c->currtable = root;
749 for (i = 0; i < si_count; i++) 752 for (i = 0; i < si_count; i++)
750 { 753 {
@@ -924,23 +927,17 @@ int tagtree_get_filename(struct tree_context* c, char *buf, int buflen)
924 927
925 return 0; 928 return 0;
926} 929}
927 930
928static int tagtree_play_folder(struct tree_context* c) 931bool insert_all_playlist(struct tree_context *c, int position, bool queue)
929{ 932{
930 int i; 933 int i;
931 char buf[MAX_PATH]; 934 char buf[MAX_PATH];
932 935
933 if (playlist_create(NULL, NULL) < 0)
934 {
935 logf("Failed creating playlist\n");
936 return -1;
937 }
938
939 cpu_boost(true); 936 cpu_boost(true);
940 if (!tagcache_search(&tcs, tag_filename)) 937 if (!tagcache_search(&tcs, tag_filename))
941 { 938 {
942 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY)); 939 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
943 return -1; 940 return false;
944 } 941 }
945 942
946 for (i=0; i < c->filesindir; i++) 943 for (i=0; i < c->filesindir; i++)
@@ -954,11 +951,77 @@ static int tagtree_play_folder(struct tree_context* c)
954 continue; 951 continue;
955 } 952 }
956 953
957 playlist_insert_track(NULL, buf, PLAYLIST_INSERT, false); 954 playlist_insert_track(NULL, buf, position, queue);
958 } 955 }
959 tagcache_search_finish(&tcs); 956 tagcache_search_finish(&tcs);
960 cpu_boost(false); 957 cpu_boost(false);
961 958
959 return true;
960}
961
962bool tagtree_insert_selection_playlist(int position, bool queue)
963{
964 struct tagentry *dptr;
965 int dirlevel = tc->dirlevel;
966
967 dptr = tagtree_get_entry(tc, tc->selected_item);
968
969 /* We need to set the table to allsubentries. */
970 if (dptr->newtable == navibrowse)
971 {
972 tagtree_enter(tc);
973 tagtree_load(tc);
974 dptr = tagtree_get_entry(tc, tc->selected_item);
975 }
976 else if (dptr->newtable != allsubentries)
977 {
978 logf("unsupported table: %d", dptr->newtable);
979 return false;
980 }
981
982 /* Now the current table should be allsubentries. */
983 if (dptr->newtable != playtrack)
984 {
985 tagtree_enter(tc);
986 tagtree_load(tc);
987 dptr = tagtree_get_entry(tc, tc->selected_item);
988
989 /* And now the newtable should be playtrack. */
990 if (dptr->newtable != playtrack)
991 {
992 logf("newtable: %d !!", dptr->newtable);
993 tc->dirlevel = dirlevel;
994 return false;
995 }
996 }
997
998 if (tc->filesindir <= 0)
999 gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER));
1000 else
1001 {
1002 logf("insert_all_playlist");
1003 insert_all_playlist(tc, position, queue);
1004 }
1005
1006 /* Finally return the dirlevel to its original value. */
1007 while (tc->dirlevel > dirlevel)
1008 tagtree_exit(tc);
1009 tagtree_load(tc);
1010
1011 return true;
1012}
1013
1014static int tagtree_play_folder(struct tree_context* c)
1015{
1016 if (playlist_create(NULL, NULL) < 0)
1017 {
1018 logf("Failed creating playlist\n");
1019 return -1;
1020 }
1021
1022 if (!insert_all_playlist(c, PLAYLIST_INSERT, false))
1023 return -2;
1024
962 if (global_settings.playlist_shuffle) 1025 if (global_settings.playlist_shuffle)
963 c->selected_item = playlist_shuffle(current_tick, c->selected_item); 1026 c->selected_item = playlist_shuffle(current_tick, c->selected_item);
964 if (!global_settings.play_selected) 1027 if (!global_settings.play_selected)