summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-27 09:12:29 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-27 09:12:29 +0000
commit24fdde08940afc5144b0c625bedbc520ead15d5a (patch)
treec01717ce095095c9e6da7f11c5a85ae787abfd2f /apps
parentb6d3bc2dd96705985675f8ad372a494470c6d932 (diff)
downloadrockbox-24fdde08940afc5144b0c625bedbc520ead15d5a.tar.gz
rockbox-24fdde08940afc5144b0c625bedbc520ead15d5a.zip
Added mp3/m3u filter
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1230 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/settings.c2
-rw-r--r--apps/tree.c28
2 files changed, 25 insertions, 5 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 61aaf40b66..ba29b894d5 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -75,6 +75,8 @@ void reset_settings( struct user_settings *settings ) {
75 settings->poweroff = DEFAULT_POWEROFF_SETTING; 75 settings->poweroff = DEFAULT_POWEROFF_SETTING;
76 settings->backlight = DEFAULT_BACKLIGHT_SETTING; 76 settings->backlight = DEFAULT_BACKLIGHT_SETTING;
77 settings->wps_display = DEFAULT_WPS_DISPLAY; 77 settings->wps_display = DEFAULT_WPS_DISPLAY;
78 settings->mp3filter = true;
79 settings->playlist_shuffle = false;
78} 80}
79 81
80 82
diff --git a/apps/tree.c b/apps/tree.c
index 253a8f1820..0ba622fca8 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -34,6 +34,7 @@
34#include "playlist.h" 34#include "playlist.h"
35#include "menu.h" 35#include "menu.h"
36#include "wps.h" 36#include "wps.h"
37#include "settings.h"
37 38
38#ifdef HAVE_LCD_BITMAP 39#ifdef HAVE_LCD_BITMAP
39#include "icons.h" 40#include "icons.h"
@@ -44,13 +45,14 @@
44#define MAX_DIR_LEVELS 10 45#define MAX_DIR_LEVELS 10
45 46
46struct entry { 47struct entry {
47 bool file; /* true if file, false if dir */ 48 bool file; /* true if file, false if dir */
48 char name[TREE_MAX_FILENAMELEN]; 49 char name[TREE_MAX_FILENAMELEN];
49}; 50};
50 51
51static struct entry dircache[MAX_FILES_IN_DIR]; 52static struct entry dircache[MAX_FILES_IN_DIR];
52static struct entry* dircacheptr[MAX_FILES_IN_DIR]; 53static struct entry* dircacheptr[MAX_FILES_IN_DIR];
53static int filesindir; 54static int filesindir;
55static char lastdir[256] = {0};
54 56
55void browse_root(void) 57void browse_root(void)
56{ 58{
@@ -109,8 +111,6 @@ static int compare(const void* e1, const void* e2)
109 111
110static int showdir(char *path, int start) 112static int showdir(char *path, int start)
111{ 113{
112 static char lastdir[256] = {0};
113
114#ifdef HAVE_LCD_BITMAP 114#ifdef HAVE_LCD_BITMAP
115 int icon_type = 0; 115 int icon_type = 0;
116#endif 116#endif
@@ -123,6 +123,7 @@ static int showdir(char *path, int start)
123 return -1; /* not a directory */ 123 return -1; /* not a directory */
124 memset(dircacheptr,0,sizeof(dircacheptr)); 124 memset(dircacheptr,0,sizeof(dircacheptr));
125 for ( i=0; i<MAX_FILES_IN_DIR; i++ ) { 125 for ( i=0; i<MAX_FILES_IN_DIR; i++ ) {
126 int len;
126 struct dirent *entry = readdir(dir); 127 struct dirent *entry = readdir(dir);
127 if (!entry) 128 if (!entry)
128 break; 129 break;
@@ -132,6 +133,18 @@ static int showdir(char *path, int start)
132 continue; 133 continue;
133 } 134 }
134 dircache[i].file = !(entry->attribute & ATTR_DIRECTORY); 135 dircache[i].file = !(entry->attribute & ATTR_DIRECTORY);
136
137 /* show only dir/m3u/mp3 ? */
138 len = strlen(entry->d_name);
139 if ( global_settings.mp3filter &&
140 dircache[i].file &&
141 (len > 4) &&
142 (strcasecmp(&entry->d_name[len-4], ".m3u") &&
143 strcasecmp(&entry->d_name[len-4], ".mp3"))) {
144 i--;
145 continue;
146 }
147
135 strncpy(dircache[i].name,entry->d_name,TREE_MAX_FILENAMELEN); 148 strncpy(dircache[i].name,entry->d_name,TREE_MAX_FILENAMELEN);
136 dircache[i].name[TREE_MAX_FILENAMELEN-1]=0; 149 dircache[i].name[TREE_MAX_FILENAMELEN-1]=0;
137 dircacheptr[i] = &dircache[i]; 150 dircacheptr[i] = &dircache[i];
@@ -362,11 +375,16 @@ bool dirbrowse(char *root)
362 } 375 }
363 break; 376 break;
364 377
365 case TREE_MENU: 378 case TREE_MENU: {
379 bool lastfilter = global_settings.mp3filter;
366 lcd_stop_scroll(); 380 lcd_stop_scroll();
367 main_menu(); 381 main_menu();
382 /* do we need to rescan dir? */
383 if ( lastfilter != global_settings.mp3filter )
384 lastdir[0] = 0;
368 restore = true; 385 restore = true;
369 break; 386 break;
387 }
370 388
371 case BUTTON_ON: 389 case BUTTON_ON:
372 if ( play_mode ) { 390 if ( play_mode ) {