Merged 'mp3 filter' and 'show hidden files' into a single filter option.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2405 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
cae1d3b115
commit
a7dcf912e1
|
@ -173,17 +173,17 @@ new:
|
|||
|
||||
id: LANG_HIDDEN
|
||||
desc: in settings_menu
|
||||
eng: "Hidden Files"
|
||||
eng: ""
|
||||
new:
|
||||
|
||||
id: LANG_HIDDEN_SHOW
|
||||
desc: in settings_menu
|
||||
eng: "Show"
|
||||
eng: ""
|
||||
new:
|
||||
|
||||
id: LANG_HIDDEN_HIDE
|
||||
desc: in settings_menu
|
||||
eng: "Hide"
|
||||
eng: ""
|
||||
new:
|
||||
|
||||
id: LANG_CONTRAST
|
||||
|
@ -203,7 +203,7 @@ new:
|
|||
|
||||
id: LANG_MP3FILTER
|
||||
desc: in settings_menu
|
||||
eng: "Music Filter"
|
||||
eng: ""
|
||||
new:
|
||||
|
||||
id: LANG_SORT_CASE
|
||||
|
@ -586,7 +586,7 @@ new:
|
|||
|
||||
id: LANG_DIR_FILTER
|
||||
desc: in wps F2 pressed
|
||||
eng: "Dir filter: %s"
|
||||
eng: ""
|
||||
new:
|
||||
|
||||
id: LANG_F3_STATUS
|
||||
|
@ -804,3 +804,23 @@ id: LANG_LANGUAGE_LOADED
|
|||
desc: shown when a language has been loaded from the dir browser
|
||||
eng: "new language"
|
||||
new:
|
||||
|
||||
id: LANG_FILTER
|
||||
desc: setting name for dir filter
|
||||
eng: "Show files"
|
||||
new:
|
||||
|
||||
id: LANG_FILTER_MUSIC
|
||||
desc: show only music-related files
|
||||
eng: "Music"
|
||||
new:
|
||||
|
||||
id: LANG_FILTER_SUPPORTED
|
||||
desc: show all file types supported by Rockbox
|
||||
eng: "Supported"
|
||||
new:
|
||||
|
||||
id: LANG_FILTER_ALL
|
||||
desc: show all files
|
||||
eng: "All"
|
||||
new:
|
||||
|
|
|
@ -167,6 +167,8 @@ bool f2_screen(void)
|
|||
lcd_stop_scroll();
|
||||
|
||||
while (!exit) {
|
||||
char* ptr=NULL;
|
||||
|
||||
lcd_clear_display();
|
||||
|
||||
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
|
||||
|
@ -177,12 +179,25 @@ bool f2_screen(void)
|
|||
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
||||
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
|
||||
|
||||
snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
|
||||
global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
|
||||
switch ( global_settings.dirfilter ) {
|
||||
case SHOW_ALL:
|
||||
ptr = str(LANG_FILTER_ALL);
|
||||
break;
|
||||
|
||||
/* Get the string width and height */
|
||||
case SHOW_SUPPORTED:
|
||||
ptr = str(LANG_FILTER_SUPPORTED);
|
||||
break;
|
||||
|
||||
case SHOW_MUSIC:
|
||||
ptr = str(LANG_FILTER_MUSIC);
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof buf, "%s:", str(LANG_FILTER));
|
||||
lcd_getstringsize(buf,&w,&h);
|
||||
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf);
|
||||
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
|
||||
lcd_getstringsize(ptr,&w,&h);
|
||||
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
|
||||
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
||||
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
|
||||
|
||||
|
@ -203,7 +218,9 @@ bool f2_screen(void)
|
|||
|
||||
case BUTTON_DOWN:
|
||||
case BUTTON_F2 | BUTTON_DOWN:
|
||||
global_settings.mp3filter = !global_settings.mp3filter;
|
||||
global_settings.dirfilter++;
|
||||
if ( global_settings.dirfilter >= NUM_FILTER_MODES )
|
||||
global_settings.dirfilter = 0;
|
||||
used = true;
|
||||
break;
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ offset abs
|
|||
0x0b 0x1f <backlight byte>
|
||||
0x0c 0x20 <poweroff timer byte>
|
||||
0x0d 0x21 <resume settings byte>
|
||||
0x0e 0x22 <shuffle,mp3filter,sort_case,discharge,statusbar,show_hidden,
|
||||
0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden,
|
||||
scroll bar>
|
||||
0x0f 0x23 <scroll speed>
|
||||
0x10 0x24 <ff/rewind min step, acceleration rate>
|
||||
|
@ -267,11 +267,11 @@ int settings_save( void )
|
|||
|
||||
config_block[0xe] = (unsigned char)
|
||||
((global_settings.playlist_shuffle & 1) |
|
||||
((global_settings.mp3filter & 1) << 1) |
|
||||
((global_settings.dirfilter & 1) << 1) |
|
||||
((global_settings.sort_case & 1) << 2) |
|
||||
((global_settings.discharge & 1) << 3) |
|
||||
((global_settings.statusbar & 1) << 4) |
|
||||
((global_settings.show_hidden_files & 1) << 5) |
|
||||
((global_settings.dirfilter & 2) << 4) |
|
||||
((global_settings.scrollbar & 1) << 6));
|
||||
|
||||
config_block[0xf] = (unsigned char)(global_settings.scroll_speed << 3);
|
||||
|
@ -361,11 +361,11 @@ void settings_load(void)
|
|||
global_settings.resume = config_block[0xd];
|
||||
if (config_block[0xe] != 0xFF) {
|
||||
global_settings.playlist_shuffle = config_block[0xe] & 1;
|
||||
global_settings.mp3filter = (config_block[0xe] >> 1) & 1;
|
||||
global_settings.dirfilter = (config_block[0xe] >> 1) & 1;
|
||||
global_settings.sort_case = (config_block[0xe] >> 2) & 1;
|
||||
global_settings.discharge = (config_block[0xe] >> 3) & 1;
|
||||
global_settings.statusbar = (config_block[0xe] >> 4) & 1;
|
||||
global_settings.show_hidden_files = (config_block[0xe] >> 5) & 1;
|
||||
global_settings.dirfilter |= ((config_block[0xe] >> 5) & 1) << 1;
|
||||
global_settings.scrollbar = (config_block[0xe] >> 6) & 1;
|
||||
/* Don't use the last bit, it must be unused to detect
|
||||
an uninitialized entry */
|
||||
|
@ -594,7 +594,7 @@ void settings_reset(void) {
|
|||
global_settings.contrast = DEFAULT_CONTRAST_SETTING;
|
||||
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
|
||||
global_settings.backlight = DEFAULT_BACKLIGHT_SETTING;
|
||||
global_settings.mp3filter = true;
|
||||
global_settings.dirfilter = SHOW_MUSIC;
|
||||
global_settings.sort_case = false;
|
||||
global_settings.statusbar = true;
|
||||
global_settings.scrollbar = true;
|
||||
|
@ -603,7 +603,6 @@ void settings_reset(void) {
|
|||
global_settings.discharge = 0;
|
||||
global_settings.total_uptime = 0;
|
||||
global_settings.scroll_speed = 8;
|
||||
global_settings.show_hidden_files = false;
|
||||
global_settings.ff_rewind_min_step = DEFAULT_FF_REWIND_MIN_STEP;
|
||||
global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING;
|
||||
global_settings.resume_index = -1;
|
||||
|
|
|
@ -77,7 +77,7 @@ struct user_settings
|
|||
/* misc options */
|
||||
|
||||
int loop_playlist; /* do we return to top of playlist at end? */
|
||||
bool mp3filter; /* only display mp3/m3u files and dirs in directory? */
|
||||
int dirfilter; /* 0=display all, 1=only supported, 2=only music */
|
||||
bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
|
||||
int scroll_speed; /* long texts scrolling speed: 1-30 */
|
||||
bool playlist_shuffle;
|
||||
|
@ -92,10 +92,6 @@ struct user_settings
|
|||
/* show scroll bar */
|
||||
bool scrollbar; /* 0=hide, 1=show */
|
||||
|
||||
/* Hidden and dotfile settings */
|
||||
bool show_hidden_files; /* 1=show dotfiles/hidden,
|
||||
0=hide dotfiles/hidden */
|
||||
|
||||
/* goto current song when exiting WPS */
|
||||
bool browse_current; /* 1=goto current song,
|
||||
0=goto previous location */
|
||||
|
@ -148,4 +144,7 @@ extern char rockboxdir[];
|
|||
#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000
|
||||
#define DEFAULT_FF_REWIND_ACCEL_SETTING 3
|
||||
|
||||
/* dir filter options */
|
||||
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, NUM_FILTER_MODES };
|
||||
|
||||
#endif /* __SETTINGS_H__ */
|
||||
|
|
|
@ -38,14 +38,6 @@
|
|||
#include "ata.h"
|
||||
#include "lang.h"
|
||||
|
||||
static bool show_hidden_files(void)
|
||||
{
|
||||
return set_bool_options( str(LANG_HIDDEN),
|
||||
&global_settings.show_hidden_files,
|
||||
str(LANG_HIDDEN_SHOW),
|
||||
str(LANG_HIDDEN_HIDE) );
|
||||
}
|
||||
|
||||
static bool contrast(void)
|
||||
{
|
||||
return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
|
||||
|
@ -64,9 +56,13 @@ static bool play_selected(void)
|
|||
return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
|
||||
}
|
||||
|
||||
static bool mp3_filter(void)
|
||||
static bool dir_filter(void)
|
||||
{
|
||||
return set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter );
|
||||
char* names[] = { str(LANG_FILTER_ALL),
|
||||
str(LANG_FILTER_SUPPORTED),
|
||||
str(LANG_FILTER_MUSIC) };
|
||||
return set_option( str(LANG_FILTER), &global_settings.dirfilter,
|
||||
names, 3, NULL );
|
||||
}
|
||||
|
||||
static bool sort_case(void)
|
||||
|
@ -298,8 +294,7 @@ static bool fileview_settings_menu(void)
|
|||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_CASE_MENU), sort_case },
|
||||
{ str(LANG_MP3FILTER), mp3_filter },
|
||||
{ str(LANG_HIDDEN), show_hidden_files },
|
||||
{ str(LANG_FILTER), dir_filter },
|
||||
{ str(LANG_FOLLOW), browse_current },
|
||||
};
|
||||
|
||||
|
|
44
apps/tree.c
44
apps/tree.c
|
@ -235,8 +235,8 @@ static int showdir(char *path, int start)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Skip dotfiles if set to skip them */
|
||||
if (!global_settings.show_hidden_files &&
|
||||
/* filter out dotfiles and hidden files */
|
||||
if (global_settings.dirfilter != SHOW_ALL &&
|
||||
((entry->d_name[0]=='.') ||
|
||||
(entry->attribute & ATTR_HIDDEN))) {
|
||||
i--;
|
||||
|
@ -269,15 +269,22 @@ static int showdir(char *path, int start)
|
|||
dptr->attr |= TREE_ATTR_MOD;
|
||||
}
|
||||
|
||||
/* filter non-mp3 or m3u files */
|
||||
if ( global_settings.mp3filter &&
|
||||
/* filter out non-music files */
|
||||
if ( global_settings.dirfilter == SHOW_MUSIC &&
|
||||
(!(dptr->attr &
|
||||
(ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(len > NAME_BUFFER_SIZE - name_buffer_length - 1) {
|
||||
/* filter out non-supported files */
|
||||
if ( global_settings.dirfilter == SHOW_SUPPORTED &&
|
||||
(!(dptr->attr & TREE_ATTR_MASK)) ) {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) {
|
||||
/* Tell the world that we ran out of buffer space */
|
||||
dir_buffer_full = true;
|
||||
break;
|
||||
|
@ -407,8 +414,8 @@ static int showdir(char *path, int start)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* if MP3 filter is on, cut off the extension */
|
||||
if (global_settings.mp3filter &&
|
||||
/* if music filter is on, cut off the extension */
|
||||
if (global_settings.dirfilter == SHOW_MUSIC &&
|
||||
(dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
|
||||
{
|
||||
char temp = dircache[i].name[len-4];
|
||||
|
@ -587,9 +594,8 @@ bool dirbrowse(char *root)
|
|||
int button;
|
||||
int tree_max_on_screen;
|
||||
bool reload_root = false;
|
||||
bool lastfilter = global_settings.mp3filter;
|
||||
int lastfilter = global_settings.dirfilter;
|
||||
bool lastsortcase = global_settings.sort_case;
|
||||
bool lastshowhidden = global_settings.show_hidden_files;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
int fw, fh;
|
||||
lcd_getstringsize("A", &fw, &fh);
|
||||
|
@ -927,9 +933,8 @@ bool dirbrowse(char *root)
|
|||
|
||||
/* do we need to rescan dir? */
|
||||
if (reload_root ||
|
||||
lastfilter != global_settings.mp3filter ||
|
||||
lastsortcase != global_settings.sort_case ||
|
||||
lastshowhidden != global_settings.show_hidden_files)
|
||||
lastfilter != global_settings.dirfilter ||
|
||||
lastsortcase != global_settings.sort_case)
|
||||
{
|
||||
if ( reload_root ) {
|
||||
strcpy(currdir, "/");
|
||||
|
@ -939,9 +944,8 @@ bool dirbrowse(char *root)
|
|||
dircursor = 0;
|
||||
dirstart = 0;
|
||||
lastdir[0] = 0;
|
||||
lastfilter = global_settings.mp3filter;
|
||||
lastfilter = global_settings.dirfilter;
|
||||
lastsortcase = global_settings.sort_case;
|
||||
lastshowhidden = global_settings.show_hidden_files;
|
||||
restore = true;
|
||||
}
|
||||
|
||||
|
@ -964,25 +968,21 @@ bool dirbrowse(char *root)
|
|||
if(lasti!=i || restore) {
|
||||
lasti=i;
|
||||
lcd_stop_scroll();
|
||||
if (global_settings.mp3filter &&
|
||||
(dircache[i].attr &
|
||||
(TREE_ATTR_M3U|TREE_ATTR_MPA)))
|
||||
if (global_settings.dirfilter == SHOW_MUSIC &&
|
||||
(dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
|
||||
{
|
||||
int len = strlen(dircache[i].name);
|
||||
char temp = dircache[i].name[len-4];
|
||||
dircache[i].name[len-4] = 0;
|
||||
lcd_puts_scroll(LINE_X, dircursor,
|
||||
dircache[i].name);
|
||||
lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
|
||||
dircache[i].name[len-4] = temp;
|
||||
}
|
||||
else
|
||||
lcd_puts_scroll(LINE_X, dircursor,
|
||||
dircache[i].name);
|
||||
lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
|
||||
}
|
||||
}
|
||||
status_draw();
|
||||
lcd_update();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user