summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-01-15 14:52:53 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-01-15 14:52:53 +0000
commitcaebdd4f00a953fcaed76e6fa55ffb105e3093e2 (patch)
tree8d686a9ee06244f88151a1d2e188bbddd8c1790f /apps
parent43d6d28e20f7f21717df3745c408c91efe00e796 (diff)
downloadrockbox-caebdd4f00a953fcaed76e6fa55ffb105e3093e2.tar.gz
rockbox-caebdd4f00a953fcaed76e6fa55ffb105e3093e2.zip
Added ON+PLAY in dir browser for file actions: Rename, Delete and Queue.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3096 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang39
-rw-r--r--apps/tree.c255
2 files changed, 213 insertions, 81 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 3e303bc85a..aa47808805 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1247,3 +1247,42 @@ desc: Visual confirmation of changing a setting
1247eng: "OK" 1247eng: "OK"
1248new: 1248new:
1249 1249
1250id: LANG_PLAYER_ONPLAY_1
1251desc: Line #1 of player ON+PLAY screen
1252eng: "\x81 Queue"
1253new:
1254
1255id: LANG_PLAYER_ONPLAY_2
1256desc: Line #2 of player ON+PLAY screen
1257eng: "- Ren + Del"
1258new:
1259
1260id: LANG_QUEUE
1261desc: The verb/action Queue
1262eng: "Queue"
1263new:
1264
1265id: LANG_DELETE
1266desc: The verb/action Delete
1267eng: "Delete"
1268new:
1269
1270id: LANG_REALLY_DELETE
1271desc: Really Delete?
1272eng: "Delete?"
1273new:
1274
1275id: LANG_DELETED
1276desc: A file has beed deleted
1277eng: "Deleted"
1278new:
1279
1280id: LANG_RENAME
1281desc: The verb/action Rename
1282eng: "Rename"
1283new:
1284
1285id: LANG_FAILED
1286desc: Something failed. To be appended after above actions
1287eng: "failed"
1288new:
diff --git a/apps/tree.c b/apps/tree.c
index dcaa9558bd..24ac1f5555 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -49,6 +49,7 @@
49#include "viewer.h" 49#include "viewer.h"
50#include "language.h" 50#include "language.h"
51#include "screens.h" 51#include "screens.h"
52#include "keyboard.h"
52 53
53#ifdef HAVE_LCD_BITMAP 54#ifdef HAVE_LCD_BITMAP
54#include "widgets.h" 55#include "widgets.h"
@@ -73,6 +74,7 @@ static int cursorpos[MAX_DIR_LEVELS];
73static char lastdir[MAX_PATH]; 74static char lastdir[MAX_PATH];
74static char lastfile[MAX_PATH]; 75static char lastfile[MAX_PATH];
75static char currdir[MAX_PATH]; 76static char currdir[MAX_PATH];
77static bool reload_dir = false;
76 78
77void browse_root(void) 79void browse_root(void)
78{ 80{
@@ -203,7 +205,7 @@ static int showdir(char *path, int start)
203#endif 205#endif
204 206
205 /* new dir? cache it */ 207 /* new dir? cache it */
206 if (strncmp(path,lastdir,sizeof(lastdir))) { 208 if (strncmp(path,lastdir,sizeof(lastdir)) || reload_dir) {
207 DIR *dir = opendir(path); 209 DIR *dir = opendir(path);
208 if(!dir) 210 if(!dir)
209 return -1; /* not a directory */ 211 return -1; /* not a directory */
@@ -455,36 +457,6 @@ static int showdir(char *path, int start)
455 return filesindir; 457 return filesindir;
456} 458}
457 459
458static void show_queue_display(int queue_count, char *filename)
459{
460#ifdef HAVE_LCD_CHARCELLS
461 lcd_double_height(false);
462#endif
463
464#ifdef HAVE_LCD_BITMAP
465 lcd_setmargins(0,0);
466#endif
467
468 lcd_clear_display();
469 if (queue_count > 0)
470 {
471 char s[32];
472
473 snprintf(s, sizeof(s), str(LANG_QUEUE_QUEUED), filename);
474 lcd_puts(0,0,s);
475
476 snprintf(s, sizeof(s), str(LANG_QUEUE_TOTAL), queue_count);
477 lcd_puts(0,1,s);
478 }
479 else
480 {
481 lcd_puts(0,0,str(LANG_QUEUE_FULL));
482 }
483 lcd_update();
484 sleep(HZ);
485 lcd_clear_display();
486}
487
488bool ask_resume(void) 460bool ask_resume(void)
489{ 461{
490#ifdef HAVE_LCD_CHARCELLS 462#ifdef HAVE_LCD_CHARCELLS
@@ -649,20 +621,156 @@ void set_current_file(char *path)
649 } 621 }
650} 622}
651 623
652#ifdef HAVE_RECORDER_KEYPAD 624static int onplay_screen(char* dir, char* file)
653bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen )
654{ 625{
655 bool exit = false; 626 bool exit = false;
656 bool used = false; 627 bool used = false;
628 bool playing = mpeg_status() & MPEG_STATUS_PLAY;
629 char buf[MAX_PATH];
630
631 if ((dir[0]=='/') && (dir[1]==0))
632 snprintf(buf, sizeof buf, "%s%s", dir, file);
633 else
634 snprintf(buf, sizeof buf, "%s/%s", dir, file);
635
636 lcd_stop_scroll();
637 lcd_clear_display();
638#ifdef HAVE_LCD_BITMAP
639 {
640 int w,h;
641 char* ptr;
642
643 lcd_setfont(FONT_SYSFIXED);
644
645 if (playing) {
646 ptr = str(LANG_QUEUE);
647 lcd_getstringsize(ptr,&w,&h);
648 lcd_putsxy((LCD_WIDTH-w)/2, h*2, ptr);
649 lcd_bitmap(bitmap_icons_7x8[Icon_Play],
650 LCD_WIDTH/2 - 3, LCD_HEIGHT/2 - 4, 7, 8, true);
651 }
652
653 ptr = str(LANG_DELETE);
654 lcd_getstringsize(ptr,&w,&h);
655 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h/2, ptr);
656 lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
657 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
658
659 lcd_putsxy(0, LCD_HEIGHT/2 - h/2, str(LANG_RENAME));
660 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
661 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
662 }
663#else
664 lcd_puts(0,0,str(LANG_PLAYER_ONPLAY_1));
665 lcd_puts(0,1,str(LANG_PLAYER_ONPLAY_2));
666#endif
667 lcd_update();
668
657 669
670 while (!exit) {
671 switch (button_get(true)) {
672 case BUTTON_LEFT:
673 case BUTTON_ON | BUTTON_LEFT: {
674 char newname[MAX_PATH];
675 char* ptr = strrchr(buf, '/') + 1;
676 int pathlen = (ptr - buf);
677 strncpy(newname, buf, sizeof newname);
678 if (!kbd_input(newname + pathlen, (sizeof newname)-pathlen)) {
679 if (rename(buf, newname) < 0) {
680 lcd_clear_display();
681 lcd_puts(0,0,str(LANG_RENAME));
682 lcd_puts(0,1,str(LANG_FAILED));
683 lcd_update();
684 sleep(HZ*2);
685 }
686 else
687 reload_dir = true;
688 }
689 exit = true;
690 break;
691 }
692
693 case BUTTON_RIGHT:
694 case BUTTON_ON | BUTTON_RIGHT:
695 lcd_clear_display();
696#ifdef HAVE_LCD_CHARCELLS
697 lcd_puts(0,0,file);
698 lcd_puts(0,1,str(LANG_REALLY_DELETE));
699#else
700 lcd_puts(0,0,str(LANG_REALLY_DELETE));
701 lcd_puts(0,1,file);
702 lcd_puts(0,3,str(LANG_RESUME_CONFIRM_RECORDER));
703 lcd_puts(0,4,str(LANG_RESUME_CANCEL_RECORDER));
704#endif
705 lcd_update();
706 while (!exit) {
707 int btn = button_get(true);
708 switch (btn) {
709 case BUTTON_PLAY:
710 case BUTTON_PLAY | BUTTON_REL:
711 if (!remove(buf)) {
712 reload_dir = true;
713 lcd_clear_display();
714 lcd_puts(0,0,file);
715 lcd_puts(0,1,str(LANG_DELETED));
716 lcd_update();
717 sleep(HZ);
718 exit = true;
719 break;
720 }
721
722 default:
723 /* ignore button releases */
724 if (!(btn & BUTTON_REL))
725 exit = true;
726 break;
727 }
728 }
729 break;
730
731 case BUTTON_PLAY:
732 case BUTTON_ON | BUTTON_PLAY: {
733 if (playing)
734 queue_add(buf);
735 exit = true;
736 break;
737 }
738
739 case BUTTON_ON | BUTTON_REL:
740 used = true;
741 break;
742
743 case BUTTON_ON:
744 if (used)
745 exit = true;
746 break;
747
748 case BUTTON_OFF:
749 exit = true;
750 break;
751 }
752 }
753
754#ifdef HAVE_LCD_BITMAP
755 lcd_setfont(FONT_UI);
756#endif
757
758 return false;
759}
760
761static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
762{
763 bool exit = false;
764 bool used = false;
765
658 int dirstart = *ds; 766 int dirstart = *ds;
659 int dircursor = *dc; 767 int dircursor = *dc;
660 768
661 while (!exit) { 769 while (!exit) {
662 switch (button_get(true)) { 770 switch (button_get(true)) {
663 case BUTTON_UP: 771 case TREE_PREV:
664 case BUTTON_ON | BUTTON_UP: 772 case BUTTON_ON | TREE_PREV:
665 case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT: 773 case BUTTON_ON | TREE_PREV | BUTTON_REPEAT:
666 used = true; 774 used = true;
667 if ( dirstart ) { 775 if ( dirstart ) {
668 dirstart -= tree_max_on_screen; 776 dirstart -= tree_max_on_screen;
@@ -673,9 +781,9 @@ bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen )
673 dircursor = 0; 781 dircursor = 0;
674 break; 782 break;
675 783
676 case BUTTON_DOWN: 784 case TREE_NEXT:
677 case BUTTON_ON | BUTTON_DOWN: 785 case BUTTON_ON | TREE_NEXT:
678 case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT: 786 case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT:
679 used = true; 787 used = true;
680 if ( dirstart < numentries - tree_max_on_screen ) { 788 if ( dirstart < numentries - tree_max_on_screen ) {
681 dirstart += tree_max_on_screen; 789 dirstart += tree_max_on_screen;
@@ -686,18 +794,22 @@ bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen )
686 else 794 else
687 dircursor = numentries - dirstart - 1; 795 dircursor = numentries - dirstart - 1;
688 break; 796 break;
797
798
799 case BUTTON_PLAY:
800 case BUTTON_ON | BUTTON_PLAY:
801 onplay_screen(currdir, dircache[dircursor+dirstart].name);
802 exit = true;
803 used = true;
804 break;
689 805
690#ifdef SIMULATOR
691 case BUTTON_ON:
692#else
693 case BUTTON_ON | BUTTON_REL: 806 case BUTTON_ON | BUTTON_REL:
694 case BUTTON_ON | BUTTON_UP | BUTTON_REL: 807 case BUTTON_ON | TREE_PREV | BUTTON_REL:
695 case BUTTON_ON | BUTTON_DOWN | BUTTON_REL: 808 case BUTTON_ON | TREE_NEXT | BUTTON_REL:
696#endif
697 exit = true; 809 exit = true;
698 break; 810 break;
699 } 811 }
700 if ( used ) { 812 if ( used && !exit ) {
701 showdir(currdir, dirstart); 813 showdir(currdir, dirstart);
702 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 814 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
703 lcd_update(); 815 lcd_update();
@@ -708,7 +820,6 @@ bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen )
708 820
709 return used; 821 return used;
710} 822}
711#endif
712 823
713static void storefile(char* filename, char* setting, int maxlen) 824static void storefile(char* filename, char* setting, int maxlen)
714{ 825{
@@ -814,10 +925,10 @@ bool dirbrowse(char *root)
814 break; 925 break;
815 926
816 927
817 case TREE_ENTER | BUTTON_REL: 928 case TREE_ENTER:
818 case TREE_ENTER | BUTTON_REPEAT: 929 case TREE_ENTER | BUTTON_REPEAT:
819#ifdef HAVE_RECORDER_KEYPAD 930#ifdef HAVE_RECORDER_KEYPAD
820 case BUTTON_PLAY | BUTTON_REL: 931 case BUTTON_PLAY:
821 case BUTTON_PLAY | BUTTON_REPEAT: 932 case BUTTON_PLAY | BUTTON_REPEAT:
822#endif 933#endif
823 if ( !numentries ) 934 if ( !numentries )
@@ -838,7 +949,6 @@ bool dirbrowse(char *root)
838 dircursor=0; 949 dircursor=0;
839 dirstart=0; 950 dirstart=0;
840 } else { 951 } else {
841 static int repeat_count = 0;
842 int seed = current_tick; 952 int seed = current_tick;
843 bool play = false; 953 bool play = false;
844 int start_index=0; 954 int start_index=0;
@@ -857,34 +967,18 @@ bool dirbrowse(char *root)
857 break; 967 break;
858 968
859 case TREE_ATTR_MPA: 969 case TREE_ATTR_MPA:
860 if (button & BUTTON_REPEAT && 970 if ( global_settings.resume )
861 mpeg_status() & MPEG_STATUS_PLAY) 971 strncpy(global_settings.resume_file,
862 { 972 currdir, MAX_PATH);
863 int queue_count = queue_add(buf); 973 start_index =
864 show_queue_display(queue_count, 974 build_playlist(dircursor+dirstart);
865 file->name); 975
866
867 while( !(button_get(true) & BUTTON_REL) ) ;
868
869 repeat_count = 0;
870 restore = true;
871 }
872 else
873 {
874 repeat_count = 0;
875 if ( global_settings.resume )
876 strncpy(global_settings.resume_file,
877 currdir, MAX_PATH);
878 start_index =
879 build_playlist(dircursor+dirstart);
880
881 /* it is important that we get back the index 976 /* it is important that we get back the index
882 in the (shuffled) list and store that */ 977 in the (shuffled) list and store that */
883 start_index = play_list(currdir, NULL, 978 start_index = play_list(currdir, NULL,
884 start_index, false, 979 start_index, false,
885 0, seed, 0, 0, -1); 980 0, seed, 0, 0, -1);
886 play = true; 981 play = true;
887 }
888 break; 982 break;
889 983
890 /* wps config file */ 984 /* wps config file */
@@ -1073,15 +1167,13 @@ bool dirbrowse(char *root)
1073 break; 1167 break;
1074 1168
1075 case BUTTON_ON: 1169 case BUTTON_ON:
1076#ifdef HAVE_RECORDER_KEYPAD 1170 if (handle_on(&dirstart, &dircursor, numentries,
1077 if (pageupdown(&dirstart, &dircursor, numentries, 1171 tree_max_on_screen))
1078 tree_max_on_screen))
1079 { 1172 {
1080 /* start scroll */ 1173 /* start scroll */
1081 restore = true; 1174 restore = true;
1082 } 1175 }
1083 else 1176 else
1084#endif
1085 { 1177 {
1086 if (mpeg_status() & MPEG_STATUS_PLAY) 1178 if (mpeg_status() & MPEG_STATUS_PLAY)
1087 { 1179 {
@@ -1146,7 +1238,7 @@ bool dirbrowse(char *root)
1146 restore = true; 1238 restore = true;
1147 } 1239 }
1148 1240
1149 if ( restore ) { 1241 if (restore || reload_dir) {
1150 /* restore display */ 1242 /* restore display */
1151 /* We need to adjust if the number of lines on screen have 1243 /* We need to adjust if the number of lines on screen have
1152 changed because of a status bar change */ 1244 changed because of a status bar change */
@@ -1163,6 +1255,7 @@ bool dirbrowse(char *root)
1163 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1255 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1164 1256
1165 need_update = true; 1257 need_update = true;
1258 reload_dir = false;
1166 } 1259 }
1167 1260
1168 if ( numentries ) { 1261 if ( numentries ) {