diff options
author | Kjell Ericson <kjell@haxx.se> | 2003-01-29 08:26:11 +0000 |
---|---|---|
committer | Kjell Ericson <kjell@haxx.se> | 2003-01-29 08:26:11 +0000 |
commit | 5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6 (patch) | |
tree | ce2387d895c12fc84dcf4fe9f9373742ab3edd74 /apps/tree.c | |
parent | 2ba4fedd6400cb74c604ba4c9e3c56c6e2f79e78 (diff) | |
download | rockbox-5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6.tar.gz rockbox-5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6.zip |
New onplay-menu for the Player.
The menu_run() function is split into two functions, where the new menu_run() works like before, and the new function menu_show() returns the menu item number you selected.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3180 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/apps/tree.c b/apps/tree.c index a918ecd8fa..43bd5e6f5c 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -642,6 +642,7 @@ void set_current_file(char *path) | |||
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | #ifdef HAVE_LCD_BITMAP | ||
645 | static int onplay_screen(char* dir, char* file) | 646 | static int onplay_screen(char* dir, char* file) |
646 | { | 647 | { |
647 | bool exit = false; | 648 | bool exit = false; |
@@ -789,6 +790,115 @@ static int onplay_screen(char* dir, char* file) | |||
789 | return false; | 790 | return false; |
790 | } | 791 | } |
791 | 792 | ||
793 | #else | ||
794 | |||
795 | static int onplay_screen(char* dir, char* file) | ||
796 | { | ||
797 | bool exit = false; | ||
798 | bool playing = mpeg_status() & MPEG_STATUS_PLAY; | ||
799 | char buf[MAX_PATH]; | ||
800 | struct entry* f = &dircache[dirstart + dircursor]; | ||
801 | bool isdir = f->attr & ATTR_DIRECTORY; | ||
802 | struct menu_items items[3]; | ||
803 | int ids[3]; | ||
804 | int lastitem=0; | ||
805 | int m_handle; | ||
806 | int selected; | ||
807 | |||
808 | if ((dir[0]=='/') && (dir[1]==0)) | ||
809 | snprintf(buf, sizeof buf, "%s%s", dir, file); | ||
810 | else | ||
811 | snprintf(buf, sizeof buf, "%s/%s", dir, file); | ||
812 | |||
813 | if (playing) { | ||
814 | items[lastitem].desc=str(LANG_QUEUE); | ||
815 | ids[lastitem]=1; | ||
816 | lastitem++; | ||
817 | } | ||
818 | |||
819 | items[lastitem].desc=str(LANG_RENAME); | ||
820 | ids[lastitem]=2; | ||
821 | lastitem++; | ||
822 | |||
823 | /* don't delete directories */ | ||
824 | if (!isdir) { | ||
825 | items[lastitem].desc=str(LANG_DELETE); | ||
826 | ids[lastitem]=3; | ||
827 | lastitem++; | ||
828 | } | ||
829 | m_handle=menu_init(items, lastitem); | ||
830 | |||
831 | selected=menu_show(m_handle); | ||
832 | if (selected>=0) { | ||
833 | switch(ids[selected]) { | ||
834 | case 1: | ||
835 | if (playing) | ||
836 | queue_add(buf); | ||
837 | break; | ||
838 | case 2: | ||
839 | { | ||
840 | char newname[MAX_PATH]; | ||
841 | char* ptr = strrchr(buf, '/') + 1; | ||
842 | int pathlen = (ptr - buf); | ||
843 | strncpy(newname, buf, sizeof newname); | ||
844 | if (!kbd_input(newname + pathlen, (sizeof newname)-pathlen)) { | ||
845 | if (rename(buf, newname) < 0) { | ||
846 | lcd_clear_display(); | ||
847 | lcd_puts(0,0,str(LANG_RENAME)); | ||
848 | lcd_puts(0,1,str(LANG_FAILED)); | ||
849 | lcd_update(); | ||
850 | sleep(HZ*2); | ||
851 | } | ||
852 | else | ||
853 | reload_dir = true; | ||
854 | } | ||
855 | } | ||
856 | break; | ||
857 | case 3: | ||
858 | lcd_clear_display(); | ||
859 | #ifdef HAVE_LCD_CHARCELLS | ||
860 | lcd_puts(0,0,file); | ||
861 | lcd_puts(0,1,str(LANG_REALLY_DELETE)); | ||
862 | #else | ||
863 | lcd_puts(0,0,str(LANG_REALLY_DELETE)); | ||
864 | lcd_puts(0,1,file); | ||
865 | lcd_puts(0,3,str(LANG_RESUME_CONFIRM_RECORDER)); | ||
866 | lcd_puts(0,4,str(LANG_RESUME_CANCEL_RECORDER)); | ||
867 | #endif | ||
868 | lcd_update(); | ||
869 | { | ||
870 | while (!exit) { | ||
871 | int btn = button_get(true); | ||
872 | switch (btn) { | ||
873 | case BUTTON_PLAY: | ||
874 | case BUTTON_PLAY | BUTTON_REL: | ||
875 | if (!remove(buf)) { | ||
876 | reload_dir = true; | ||
877 | lcd_clear_display(); | ||
878 | lcd_puts(0,0,file); | ||
879 | lcd_puts(0,1,str(LANG_DELETED)); | ||
880 | lcd_update(); | ||
881 | sleep(HZ); | ||
882 | exit = true; | ||
883 | break; | ||
884 | } | ||
885 | |||
886 | default: | ||
887 | /* ignore button releases */ | ||
888 | if (!(btn & BUTTON_REL)) | ||
889 | exit = true; | ||
890 | break; | ||
891 | } | ||
892 | } | ||
893 | } | ||
894 | break; | ||
895 | } | ||
896 | } | ||
897 | menu_exit(m_handle); | ||
898 | return false; | ||
899 | } | ||
900 | #endif | ||
901 | |||
792 | 902 | ||
793 | 903 | ||
794 | static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) | 904 | static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) |