summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-09-29 21:26:53 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-09-29 21:26:53 +0000
commitde5477cc002ea2a3173f80fc63b8beecc32f602e (patch)
tree4f4c5f2ee007d800bf3fea53ed0b3361418b6eaf
parentd527849e668e9657bfad191edca04fb85d193ac9 (diff)
downloadrockbox-de5477cc002ea2a3173f80fc63b8beecc32f602e.tar.gz
rockbox-de5477cc002ea2a3173f80fc63b8beecc32f602e.zip
Brian King's .rockbox browsing patch
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3964 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang30
-rw-r--r--apps/main_menu.c20
-rw-r--r--apps/playlist.c5
-rw-r--r--apps/settings.h8
-rw-r--r--apps/settings_menu.c29
-rw-r--r--apps/tree.c119
-rw-r--r--apps/tree.h3
7 files changed, 156 insertions, 58 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index e91ce050d6..5d767ebabd 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1727,3 +1727,33 @@ id: LANG_RECURSE_DIRECTORY_QUESTION
1727desc: Asked from onplay screen 1727desc: Asked from onplay screen
1728eng: "Recursively?" 1728eng: "Recursively?"
1729new: 1729new:
1730
1731id: LANG_CUSTOM_FONT
1732desc: in setting_menu()
1733eng: "Fonts"
1734new:
1735
1736id: LANG_FIRMWARE
1737desc: in the main menu
1738eng: "Firmware"
1739new:
1740
1741id: LANG_LANGUAGE
1742desc: in settings_menu
1743eng: "Language"
1744new:
1745
1746id: LANG_WHILE_PLAYING
1747desc: in settings_menu()
1748eng: "While Playing Screen"
1749new:
1750
1751id: LANG_CUSTOM_CFG
1752desc: in setting_menu()
1753eng: "Profiles"
1754new:
1755
1756id: LANG_PLUGINS
1757desc: in main_menu()
1758eng: "Plugins"
1759new:
diff --git a/apps/main_menu.c b/apps/main_menu.c
index e356603653..eb68eb64b6 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -251,6 +251,16 @@ bool show_info(void)
251 return false; 251 return false;
252} 252}
253 253
254static bool firmware_browse(void)
255{
256 return rockbox_browse(ROCKBOX_DIR, SHOW_MOD);
257}
258
259static bool plugin_browse(void)
260{
261 return rockbox_browse(PLUGIN_DIR, SHOW_PLUGINS);
262}
263
254bool main_menu(void) 264bool main_menu(void)
255{ 265{
256 int m; 266 int m;
@@ -273,14 +283,8 @@ bool main_menu(void)
273#ifdef HAVE_ALARM_MOD 283#ifdef HAVE_ALARM_MOD
274 { str(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, 284 { str(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
275#endif 285#endif
276#ifdef HAVE_LCD_BITMAP 286 { str(LANG_PLUGINS), plugin_browse },
277#ifdef USE_GAMES 287 { str(LANG_FIRMWARE), firmware_browse },
278 { str(LANG_GAMES), games_menu },
279#endif
280#ifdef USE_DEMOS
281 { str(LANG_DEMOS), demo_menu },
282#endif /* end USE_DEMOS */
283#endif
284 { str(LANG_INFO), show_info }, 288 { str(LANG_INFO), show_info },
285 { str(LANG_VERSION), show_credits }, 289 { str(LANG_VERSION), show_credits },
286#ifndef SIMULATOR 290#ifndef SIMULATOR
diff --git a/apps/playlist.c b/apps/playlist.c
index ceb38a4555..0843e937c4 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -410,10 +410,11 @@ static int add_directory_to_playlist(char *dirname, int *position, bool queue,
410 int num_files = 0; 410 int num_files = 0;
411 bool buffer_full = false; 411 bool buffer_full = false;
412 int i; 412 int i;
413 int dirfilter = SHOW_ALL;
413 struct entry *files; 414 struct entry *files;
414 415
415 /* use the tree browser dircache to load files */ 416 /* use the tree browser dircache to load files */
416 files = load_and_sort_directory(dirname, SHOW_ALL, &num_files, 417 files = load_and_sort_directory(dirname, &dirfilter, &num_files,
417 &buffer_full); 418 &buffer_full);
418 419
419 if(!files) 420 if(!files)
@@ -456,7 +457,7 @@ static int add_directory_to_playlist(char *dirname, int *position, bool queue,
456 break; 457 break;
457 458
458 /* we now need to reload our current directory */ 459 /* we now need to reload our current directory */
459 files = load_and_sort_directory(dirname, SHOW_ALL, &num_files, 460 files = load_and_sort_directory(dirname, &dirfilter, &num_files,
460 &buffer_full); 461 &buffer_full);
461 if (!files) 462 if (!files)
462 { 463 {
diff --git a/apps/settings.h b/apps/settings.h
index 5d251000b6..9f857e7f5d 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -25,6 +25,7 @@
25#include "file.h" 25#include "file.h"
26 26
27#define ROCKBOX_DIR "/.rockbox" 27#define ROCKBOX_DIR "/.rockbox"
28#define PLUGIN_DIR ROCKBOX_DIR"/rocks"
28 29
29#define MAX_FILENAME 20 30#define MAX_FILENAME 20
30 31
@@ -50,6 +51,7 @@
50#define FF_REWIND_45000 12 51#define FF_REWIND_45000 12
51#define FF_REWIND_60000 13 52#define FF_REWIND_60000 13
52 53
54
53struct user_settings 55struct user_settings
54{ 56{
55 /* audio settings */ 57 /* audio settings */
@@ -222,7 +224,11 @@ extern char rockboxdir[];
222enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES }; 224enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
223 225
224/* dir filter options */ 226/* dir filter options */
225enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES }; 227/* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
228 * Any new rockbox browse filter modes (accessible through the menu)
229 * must be added after NUM_FILTER_MODES. */
230enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES,
231SHOW_WPS, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
226 232
227/* recursive dir insert options */ 233/* recursive dir insert options */
228enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK }; 234enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index f593e2c65d..f12000c1ef 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -37,6 +37,7 @@
37#include "powermgmt.h" 37#include "powermgmt.h"
38#include "rtc.h" 38#include "rtc.h"
39#include "ata.h" 39#include "ata.h"
40#include "tree.h"
40#include "screens.h" 41#include "screens.h"
41#ifdef HAVE_LCD_BITMAP 42#ifdef HAVE_LCD_BITMAP
42#include "peakmeter.h" 43#include "peakmeter.h"
@@ -683,6 +684,28 @@ static bool browse_current(void)
683 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current ); 684 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
684} 685}
685 686
687static bool custom_wps_browse(void)
688{
689 return rockbox_browse(ROCKBOX_DIR, SHOW_WPS);
690}
691
692static bool custom_cfg_browse(void)
693{
694 return rockbox_browse(ROCKBOX_DIR, SHOW_CFG);
695}
696
697static bool language_browse(void)
698{
699 return rockbox_browse(ROCKBOX_DIR, SHOW_LNG);
700}
701
702#ifdef HAVE_RECORDER_KEYPAD
703static bool font_browse(void)
704{
705 return rockbox_browse(ROCKBOX_DIR, SHOW_FONT);
706}
707#endif
708
686#ifdef HAVE_LCD_BITMAP 709#ifdef HAVE_LCD_BITMAP
687static bool scroll_bar(void) 710static bool scroll_bar(void)
688{ 711{
@@ -894,8 +917,14 @@ bool settings_menu(void)
894 917
895 struct menu_items items[] = { 918 struct menu_items items[] = {
896 { str(LANG_PLAYBACK), playback_settings_menu }, 919 { str(LANG_PLAYBACK), playback_settings_menu },
920 { str(LANG_CUSTOM_CFG), custom_cfg_browse },
921 { str(LANG_WHILE_PLAYING), custom_wps_browse },
922 { str(LANG_LANGUAGE), language_browse },
897 { str(LANG_FILE), fileview_settings_menu }, 923 { str(LANG_FILE), fileview_settings_menu },
898 { str(LANG_DISPLAY), display_settings_menu }, 924 { str(LANG_DISPLAY), display_settings_menu },
925#ifdef HAVE_RECORDER_KEYPAD
926 { str(LANG_CUSTOM_FONT), font_browse },
927#endif
899 { str(LANG_SYSTEM), system_settings_menu }, 928 { str(LANG_SYSTEM), system_settings_menu },
900 { str(LANG_SAVE_SETTINGS), settings_save_config }, 929 { str(LANG_SAVE_SETTINGS), settings_save_config },
901 }; 930 };
diff --git a/apps/tree.c b/apps/tree.c
index c755c9550a..4deb2890a0 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -78,19 +78,20 @@ static int cursorpos[MAX_DIR_LEVELS];
78static char lastdir[MAX_PATH]; 78static char lastdir[MAX_PATH];
79static char lastfile[MAX_PATH]; 79static char lastfile[MAX_PATH];
80static char currdir[MAX_PATH]; 80static char currdir[MAX_PATH];
81static char currdir_save[MAX_PATH];
81static bool reload_dir = false; 82static bool reload_dir = false;
82static int boot_size = 0; 83static int boot_size = 0;
83static int boot_cluster; 84static int boot_cluster;
84static bool boot_changed = false; 85static bool boot_changed = false;
85 86
86static bool dirbrowse(char *root); 87static bool dirbrowse(char *root, int *dirfilter);
87 88
88void browse_root(void) 89void browse_root(void)
89{ 90{
90#ifndef SIMULATOR 91#ifndef SIMULATOR
91 dirbrowse("/"); 92 dirbrowse("/", &global_settings.dirfilter);
92#else 93#else
93 if (!dirbrowse("/")) { 94 if (!dirbrowse("/", &global_settings.dirfilter)) {
94 DEBUGF("No filesystem found. Have you forgotten to create it?\n"); 95 DEBUGF("No filesystem found. Have you forgotten to create it?\n");
95 } 96 }
96#endif 97#endif
@@ -189,7 +190,7 @@ static int compare(const void* p1, const void* p2)
189 return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY ); 190 return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY );
190} 191}
191 192
192static void showfileline(int line, int direntry, bool scroll) 193static void showfileline(int line, int direntry, bool scroll, int *dirfilter)
193{ 194{
194 char* name = dircache[direntry].name; 195 char* name = dircache[direntry].name;
195 int xpos = LINE_X; 196 int xpos = LINE_X;
@@ -200,7 +201,7 @@ static void showfileline(int line, int direntry, bool scroll)
200#endif 201#endif
201 202
202 /* if any file filter is on, strip the extension */ 203 /* if any file filter is on, strip the extension */
203 if (global_settings.dirfilter != SHOW_ALL && 204 if (*dirfilter != SHOW_ALL &&
204 !(dircache[direntry].attr & ATTR_DIRECTORY)) 205 !(dircache[direntry].attr & ATTR_DIRECTORY))
205 { 206 {
206 char* dotpos = strrchr(name, '.'); 207 char* dotpos = strrchr(name, '.');
@@ -235,7 +236,7 @@ static void showfileline(int line, int direntry, bool scroll)
235} 236}
236 237
237/* load sorted directory into dircache. returns NULL on failure. */ 238/* load sorted directory into dircache. returns NULL on failure. */
238struct entry* load_and_sort_directory(char *dirname, int dirfilter, 239struct entry* load_and_sort_directory(char *dirname, int *dirfilter,
239 int *num_files, bool *buffer_full) 240 int *num_files, bool *buffer_full)
240{ 241{
241 int i; 242 int i;
@@ -273,7 +274,7 @@ struct entry* load_and_sort_directory(char *dirname, int dirfilter,
273 } 274 }
274 275
275 /* filter out dotfiles and hidden files */ 276 /* filter out dotfiles and hidden files */
276 if (dirfilter != SHOW_ALL && 277 if (*dirfilter != SHOW_ALL &&
277 ((entry->d_name[0]=='.') || 278 ((entry->d_name[0]=='.') ||
278 (entry->attribute & ATTR_HIDDEN))) { 279 (entry->attribute & ATTR_HIDDEN))) {
279 i--; 280 i--;
@@ -322,25 +323,19 @@ struct entry* load_and_sort_directory(char *dirname, int dirfilter,
322 boot_cluster = entry->startcluster; 323 boot_cluster = entry->startcluster;
323 } 324 }
324 325
325 /* filter out all non-playlist files */ 326 /* filter out non-visible files */
326 if ( dirfilter == SHOW_PLAYLIST && 327 if ((*dirfilter == SHOW_PLAYLIST &&
327 (!(dptr->attr & 328 !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_M3U))) ||
328 (ATTR_DIRECTORY|TREE_ATTR_M3U))) ) { 329 (*dirfilter == SHOW_MUSIC &&
329 i--; 330 !(dptr->attr & (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ||
330 continue; 331 (*dirfilter == SHOW_SUPPORTED && !(dptr->attr & TREE_ATTR_MASK)) ||
331 } 332 (*dirfilter == SHOW_WPS && !(dptr->attr & TREE_ATTR_WPS)) ||
332 333 (*dirfilter == SHOW_CFG && !(dptr->attr & TREE_ATTR_CFG)) ||
333 /* filter out non-music files */ 334 (*dirfilter == SHOW_LNG && !(dptr->attr & TREE_ATTR_LNG)) ||
334 if ( dirfilter == SHOW_MUSIC && 335 (*dirfilter == SHOW_MOD && !(dptr->attr & TREE_ATTR_MOD)) ||
335 (!(dptr->attr & 336 (*dirfilter == SHOW_FONT && !(dptr->attr & TREE_ATTR_FONT)) ||
336 (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) { 337 (*dirfilter == SHOW_PLUGINS && !(dptr->attr & TREE_ATTR_ROCK)))
337 i--; 338 {
338 continue;
339 }
340
341 /* filter out non-supported files */
342 if ( dirfilter == SHOW_SUPPORTED &&
343 (!(dptr->attr & TREE_ATTR_MASK)) ) {
344 i--; 339 i--;
345 continue; 340 continue;
346 } 341 }
@@ -363,7 +358,7 @@ struct entry* load_and_sort_directory(char *dirname, int dirfilter,
363 return dircache; 358 return dircache;
364} 359}
365 360
366static int showdir(char *path, int start) 361static int showdir(char *path, int start, int *dirfilter)
367{ 362{
368 int icon_type = 0; 363 int icon_type = 0;
369 int i; 364 int i;
@@ -383,7 +378,7 @@ static int showdir(char *path, int start)
383 378
384 /* new dir? cache it */ 379 /* new dir? cache it */
385 if (strncmp(path,lastdir,sizeof(lastdir)) || reload_dir) { 380 if (strncmp(path,lastdir,sizeof(lastdir)) || reload_dir) {
386 if (!load_and_sort_directory(path, global_settings.dirfilter, 381 if (!load_and_sort_directory(path, dirfilter,
387 &filesindir, &dir_buffer_full)) 382 &filesindir, &dir_buffer_full))
388 return -1; 383 return -1;
389 384
@@ -534,7 +529,7 @@ static int showdir(char *path, int start)
534#endif 529#endif
535 } 530 }
536 531
537 showfileline(i-start, i, false); /* no scroll */ 532 showfileline(i-start, i, false, dirfilter); /* no scroll */
538 } 533 }
539 534
540#ifdef HAVE_LCD_BITMAP 535#ifdef HAVE_LCD_BITMAP
@@ -606,7 +601,7 @@ void resume_directory(char *dir)
606{ 601{
607 bool buffer_full; 602 bool buffer_full;
608 603
609 if (!load_and_sort_directory(dir, global_settings.dirfilter, &filesindir, 604 if (!load_and_sort_directory(dir, &global_settings.dirfilter, &filesindir,
610 &buffer_full)) 605 &buffer_full))
611 return; 606 return;
612 lastdir[0] = 0; 607 lastdir[0] = 0;
@@ -704,7 +699,7 @@ void set_current_file(char *path)
704 } 699 }
705} 700}
706 701
707static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) 702static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, int *dirfilter)
708{ 703{
709 bool exit = false; 704 bool exit = false;
710 bool used = false; 705 bool used = false;
@@ -789,7 +784,7 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
789#ifdef HAVE_LCD_BITMAP 784#ifdef HAVE_LCD_BITMAP
790 int xpos,ypos; 785 int xpos,ypos;
791#endif 786#endif
792 showdir(currdir, dirstart); 787 showdir(currdir, dirstart, dirfilter);
793#ifdef HAVE_LCD_BITMAP 788#ifdef HAVE_LCD_BITMAP
794 if (global_settings.invert_cursor) { 789 if (global_settings.invert_cursor) {
795 xpos = lcd_getxmargin(); 790 xpos = lcd_getxmargin();
@@ -808,7 +803,7 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)
808 return used; 803 return used;
809} 804}
810 805
811static bool dirbrowse(char *root) 806static bool dirbrowse(char *root, int *dirfilter)
812{ 807{
813 int numentries=0; 808 int numentries=0;
814 char buf[MAX_PATH]; 809 char buf[MAX_PATH];
@@ -817,11 +812,11 @@ static bool dirbrowse(char *root)
817 int button; 812 int button;
818 int tree_max_on_screen; 813 int tree_max_on_screen;
819 bool reload_root = false; 814 bool reload_root = false;
820 int lastfilter = global_settings.dirfilter; 815 int lastfilter = *dirfilter;
821 bool lastsortcase = global_settings.sort_case; 816 bool lastsortcase = global_settings.sort_case;
822 int lastdircursor=-1; 817 int lastdircursor=-1;
823 bool need_update = true; 818 bool need_update = true;
824 819 bool exit_func = false;
825 bool update_all = false; /* set this to true when the whole file list 820 bool update_all = false; /* set this to true when the whole file list
826 has been refreshed on screen */ 821 has been refreshed on screen */
827 822
@@ -839,9 +834,10 @@ static bool dirbrowse(char *root)
839 834
840 memcpy(currdir,root,sizeof(currdir)); 835 memcpy(currdir,root,sizeof(currdir));
841 836
837 if (*dirfilter < NUM_FILTER_MODES)
842 start_resume(true); 838 start_resume(true);
843 839
844 numentries = showdir(currdir, dirstart); 840 numentries = showdir(currdir, dirstart, dirfilter);
845 if (numentries == -1) 841 if (numentries == -1)
846 return false; /* currdir is not a directory */ 842 return false; /* currdir is not a directory */
847 update_all = true; 843 update_all = true;
@@ -899,6 +895,8 @@ static bool dirbrowse(char *root)
899 895
900 restore = true; 896 restore = true;
901 } 897 }
898 if (*dirfilter > NUM_FILTER_MODES)
899 exit_func = true;
902 break; 900 break;
903 901
904#ifdef HAVE_RECORDER_KEYPAD 902#ifdef HAVE_RECORDER_KEYPAD
@@ -1083,6 +1081,8 @@ static bool dirbrowse(char *root)
1083 tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; 1081 tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
1084#endif 1082#endif
1085 } 1083 }
1084 else if (*dirfilter > NUM_FILTER_MODES)
1085 exit_func = true;
1086 } 1086 }
1087 restore = true; 1087 restore = true;
1088 break; 1088 break;
@@ -1099,7 +1099,7 @@ static bool dirbrowse(char *root)
1099 else { 1099 else {
1100 if (dirstart) { 1100 if (dirstart) {
1101 dirstart--; 1101 dirstart--;
1102 numentries = showdir(currdir, dirstart); 1102 numentries = showdir(currdir, dirstart, dirfilter);
1103 update_all=true; 1103 update_all=true;
1104 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1104 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1105 } 1105 }
@@ -1114,7 +1114,7 @@ static bool dirbrowse(char *root)
1114 else { 1114 else {
1115 dirstart = numentries - tree_max_on_screen; 1115 dirstart = numentries - tree_max_on_screen;
1116 dircursor = tree_max_on_screen - 1; 1116 dircursor = tree_max_on_screen - 1;
1117 numentries = showdir(currdir, dirstart); 1117 numentries = showdir(currdir, dirstart, dirfilter);
1118 update_all = true; 1118 update_all = true;
1119 put_cursorxy(CURSOR_X, CURSOR_Y + 1119 put_cursorxy(CURSOR_X, CURSOR_Y +
1120 tree_max_on_screen - 1, true); 1120 tree_max_on_screen - 1, true);
@@ -1138,7 +1138,7 @@ static bool dirbrowse(char *root)
1138 } 1138 }
1139 else { 1139 else {
1140 dirstart++; 1140 dirstart++;
1141 numentries = showdir(currdir, dirstart); 1141 numentries = showdir(currdir, dirstart, dirfilter);
1142 update_all = true; 1142 update_all = true;
1143 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1143 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1144 } 1144 }
@@ -1151,7 +1151,7 @@ static bool dirbrowse(char *root)
1151 } 1151 }
1152 else { 1152 else {
1153 dirstart = dircursor = 0; 1153 dirstart = dircursor = 0;
1154 numentries = showdir(currdir, dirstart); 1154 numentries = showdir(currdir, dirstart, dirfilter);
1155 update_all=true; 1155 update_all=true;
1156 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1156 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1157 } 1157 }
@@ -1169,7 +1169,7 @@ static bool dirbrowse(char *root)
1169 1169
1170 case BUTTON_ON: 1170 case BUTTON_ON:
1171 if (handle_on(&dirstart, &dircursor, numentries, 1171 if (handle_on(&dirstart, &dircursor, numentries,
1172 tree_max_on_screen)) 1172 tree_max_on_screen, dirfilter))
1173 { 1173 {
1174 /* start scroll */ 1174 /* start scroll */
1175 restore = true; 1175 restore = true;
@@ -1228,7 +1228,7 @@ static bool dirbrowse(char *root)
1228 1228
1229 /* do we need to rescan dir? */ 1229 /* do we need to rescan dir? */
1230 if (reload_dir || reload_root || 1230 if (reload_dir || reload_root ||
1231 lastfilter != global_settings.dirfilter || 1231 lastfilter != *dirfilter ||
1232 lastsortcase != global_settings.sort_case) 1232 lastsortcase != global_settings.sort_case)
1233 { 1233 {
1234 if ( reload_root ) { 1234 if ( reload_root ) {
@@ -1242,11 +1242,15 @@ static bool dirbrowse(char *root)
1242 dirstart = 0; 1242 dirstart = 0;
1243 lastdir[0] = 0; 1243 lastdir[0] = 0;
1244 } 1244 }
1245 lastfilter = global_settings.dirfilter; 1245
1246 lastfilter = *dirfilter;
1246 lastsortcase = global_settings.sort_case; 1247 lastsortcase = global_settings.sort_case;
1247 restore = true; 1248 restore = true;
1248 } 1249 }
1249 1250
1251 if (exit_func)
1252 break;
1253
1250 if (restore || reload_dir) { 1254 if (restore || reload_dir) {
1251 /* restore display */ 1255 /* restore display */
1252 1256
@@ -1262,7 +1266,7 @@ static bool dirbrowse(char *root)
1262 icon */ 1266 icon */
1263 lcd_setfont(FONT_UI); 1267 lcd_setfont(FONT_UI);
1264#endif 1268#endif
1265 numentries = showdir(currdir, dirstart); 1269 numentries = showdir(currdir, dirstart, dirfilter);
1266 update_all = true; 1270 update_all = true;
1267 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1271 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1268 1272
@@ -1280,12 +1284,12 @@ static bool dirbrowse(char *root)
1280 /* So if lastdircursor and dircursor differ, and then full 1284 /* So if lastdircursor and dircursor differ, and then full
1281 screen was not refreshed, restore the previous line */ 1285 screen was not refreshed, restore the previous line */
1282 if ((lastdircursor != dircursor) && !update_all ) { 1286 if ((lastdircursor != dircursor) && !update_all ) {
1283 showfileline(lastdircursor, lasti, false); /* no scroll */ 1287 showfileline(lastdircursor, lasti, false, dirfilter); /* no scroll */
1284 } 1288 }
1285 lasti=i; 1289 lasti=i;
1286 lastdircursor=dircursor; 1290 lastdircursor=dircursor;
1287 1291
1288 showfileline(dircursor, i, true); /* scroll please */ 1292 showfileline(dircursor, i, true, dirfilter); /* scroll please */
1289 need_update = true; 1293 need_update = true;
1290 } 1294 }
1291 } 1295 }
@@ -1402,6 +1406,29 @@ bool create_playlist(void)
1402 return true; 1406 return true;
1403} 1407}
1404 1408
1409bool rockbox_browse(char *root, int dirfilter)
1410{
1411 bool rc;
1412 int dircursor_save = dircursor;
1413 int dirstart_save = dirstart;
1414 int dirlevel_save = dirlevel;
1415 int dirpos_save = dirpos[0];
1416 int cursorpos_save = cursorpos[0];
1417
1418 memcpy(currdir_save, currdir, sizeof(currdir));
1419 rc = dirbrowse(root, &dirfilter);
1420 memcpy(currdir, currdir_save, sizeof(currdir));
1421
1422 reload_dir = true;
1423 dirstart = dirstart_save;
1424 cursorpos[0] = cursorpos_save;
1425 dirlevel = dirlevel_save;
1426 dircursor = dircursor_save;
1427 dirpos[0] = dirpos_save;
1428
1429 return false;
1430}
1431
1405void tree_init(void) 1432void tree_init(void)
1406{ 1433{
1407 /* We copy the settings value in case it is changed by the user. We can't 1434 /* We copy the settings value in case it is changed by the user. We can't
diff --git a/apps/tree.h b/apps/tree.h
index 397fb3940d..dea0496508 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -42,11 +42,12 @@ struct entry {
42void tree_init(void); 42void tree_init(void);
43void browse_root(void); 43void browse_root(void);
44void set_current_file(char *path); 44void set_current_file(char *path);
45bool rockbox_browse(char *root, int dirfilter);
45bool create_playlist(void); 46bool create_playlist(void);
46void resume_directory(char *dir); 47void resume_directory(char *dir);
47char *getcwd(char *buf, int size); 48char *getcwd(char *buf, int size);
48void reload_directory(void); 49void reload_directory(void);
49struct entry* load_and_sort_directory(char *dirname, int dirfilter, 50struct entry* load_and_sort_directory(char *dirname, int *dirfilter,
50 int *num_files, bool *buffer_full); 51 int *num_files, bool *buffer_full);
51 52
52#endif 53#endif