From 24fdde08940afc5144b0c625bedbc520ead15d5a Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Thu, 27 Jun 2002 09:12:29 +0000 Subject: Added mp3/m3u filter git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1230 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 2 ++ apps/tree.c | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'apps') 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 ) { settings->poweroff = DEFAULT_POWEROFF_SETTING; settings->backlight = DEFAULT_BACKLIGHT_SETTING; settings->wps_display = DEFAULT_WPS_DISPLAY; + settings->mp3filter = true; + settings->playlist_shuffle = false; } 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 @@ #include "playlist.h" #include "menu.h" #include "wps.h" +#include "settings.h" #ifdef HAVE_LCD_BITMAP #include "icons.h" @@ -44,13 +45,14 @@ #define MAX_DIR_LEVELS 10 struct entry { - bool file; /* true if file, false if dir */ - char name[TREE_MAX_FILENAMELEN]; + bool file; /* true if file, false if dir */ + char name[TREE_MAX_FILENAMELEN]; }; static struct entry dircache[MAX_FILES_IN_DIR]; static struct entry* dircacheptr[MAX_FILES_IN_DIR]; static int filesindir; +static char lastdir[256] = {0}; void browse_root(void) { @@ -109,8 +111,6 @@ static int compare(const void* e1, const void* e2) static int showdir(char *path, int start) { - static char lastdir[256] = {0}; - #ifdef HAVE_LCD_BITMAP int icon_type = 0; #endif @@ -123,6 +123,7 @@ static int showdir(char *path, int start) return -1; /* not a directory */ memset(dircacheptr,0,sizeof(dircacheptr)); for ( i=0; iattribute & ATTR_DIRECTORY); + + /* show only dir/m3u/mp3 ? */ + len = strlen(entry->d_name); + if ( global_settings.mp3filter && + dircache[i].file && + (len > 4) && + (strcasecmp(&entry->d_name[len-4], ".m3u") && + strcasecmp(&entry->d_name[len-4], ".mp3"))) { + i--; + continue; + } + strncpy(dircache[i].name,entry->d_name,TREE_MAX_FILENAMELEN); dircache[i].name[TREE_MAX_FILENAMELEN-1]=0; dircacheptr[i] = &dircache[i]; @@ -362,11 +375,16 @@ bool dirbrowse(char *root) } break; - case TREE_MENU: + case TREE_MENU: { + bool lastfilter = global_settings.mp3filter; lcd_stop_scroll(); main_menu(); + /* do we need to rescan dir? */ + if ( lastfilter != global_settings.mp3filter ) + lastdir[0] = 0; restore = true; break; + } case BUTTON_ON: if ( play_mode ) { -- cgit v1.2.3