summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang30
-rw-r--r--apps/screens.c27
-rw-r--r--apps/settings.c13
-rw-r--r--apps/settings.h9
-rw-r--r--apps/settings_menu.c19
-rw-r--r--apps/tree.c44
6 files changed, 86 insertions, 56 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 657e40e247..bc9328e154 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -173,17 +173,17 @@ new:
173 173
174id: LANG_HIDDEN 174id: LANG_HIDDEN
175desc: in settings_menu 175desc: in settings_menu
176eng: "Hidden Files" 176eng: ""
177new: 177new:
178 178
179id: LANG_HIDDEN_SHOW 179id: LANG_HIDDEN_SHOW
180desc: in settings_menu 180desc: in settings_menu
181eng: "Show" 181eng: ""
182new: 182new:
183 183
184id: LANG_HIDDEN_HIDE 184id: LANG_HIDDEN_HIDE
185desc: in settings_menu 185desc: in settings_menu
186eng: "Hide" 186eng: ""
187new: 187new:
188 188
189id: LANG_CONTRAST 189id: LANG_CONTRAST
@@ -203,7 +203,7 @@ new:
203 203
204id: LANG_MP3FILTER 204id: LANG_MP3FILTER
205desc: in settings_menu 205desc: in settings_menu
206eng: "Music Filter" 206eng: ""
207new: 207new:
208 208
209id: LANG_SORT_CASE 209id: LANG_SORT_CASE
@@ -586,7 +586,7 @@ new:
586 586
587id: LANG_DIR_FILTER 587id: LANG_DIR_FILTER
588desc: in wps F2 pressed 588desc: in wps F2 pressed
589eng: "Dir filter: %s" 589eng: ""
590new: 590new:
591 591
592id: LANG_F3_STATUS 592id: LANG_F3_STATUS
@@ -804,3 +804,23 @@ id: LANG_LANGUAGE_LOADED
804desc: shown when a language has been loaded from the dir browser 804desc: shown when a language has been loaded from the dir browser
805eng: "new language" 805eng: "new language"
806new: 806new:
807
808id: LANG_FILTER
809desc: setting name for dir filter
810eng: "Show files"
811new:
812
813id: LANG_FILTER_MUSIC
814desc: show only music-related files
815eng: "Music"
816new:
817
818id: LANG_FILTER_SUPPORTED
819desc: show all file types supported by Rockbox
820eng: "Supported"
821new:
822
823id: LANG_FILTER_ALL
824desc: show all files
825eng: "All"
826new:
diff --git a/apps/screens.c b/apps/screens.c
index 29888ff358..00106df8ba 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -167,6 +167,8 @@ bool f2_screen(void)
167 lcd_stop_scroll(); 167 lcd_stop_scroll();
168 168
169 while (!exit) { 169 while (!exit) {
170 char* ptr=NULL;
171
170 lcd_clear_display(); 172 lcd_clear_display();
171 173
172 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE)); 174 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
@@ -177,12 +179,25 @@ bool f2_screen(void)
177 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], 179 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
178 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); 180 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
179 181
180 snprintf(buf, sizeof buf, str(LANG_DIR_FILTER), 182 switch ( global_settings.dirfilter ) {
181 global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF)); 183 case SHOW_ALL:
184 ptr = str(LANG_FILTER_ALL);
185 break;
186
187 case SHOW_SUPPORTED:
188 ptr = str(LANG_FILTER_SUPPORTED);
189 break;
190
191 case SHOW_MUSIC:
192 ptr = str(LANG_FILTER_MUSIC);
193 break;
194 }
182 195
183 /* Get the string width and height */ 196 snprintf(buf, sizeof buf, "%s:", str(LANG_FILTER));
184 lcd_getstringsize(buf,&w,&h); 197 lcd_getstringsize(buf,&w,&h);
185 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf); 198 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
199 lcd_getstringsize(ptr,&w,&h);
200 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
186 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], 201 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
187 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); 202 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
188 203
@@ -203,7 +218,9 @@ bool f2_screen(void)
203 218
204 case BUTTON_DOWN: 219 case BUTTON_DOWN:
205 case BUTTON_F2 | BUTTON_DOWN: 220 case BUTTON_F2 | BUTTON_DOWN:
206 global_settings.mp3filter = !global_settings.mp3filter; 221 global_settings.dirfilter++;
222 if ( global_settings.dirfilter >= NUM_FILTER_MODES )
223 global_settings.dirfilter = 0;
207 used = true; 224 used = true;
208 break; 225 break;
209 226
diff --git a/apps/settings.c b/apps/settings.c
index 673bca70d1..e488be30da 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -71,7 +71,7 @@ offset abs
710x0b 0x1f <backlight byte> 710x0b 0x1f <backlight byte>
720x0c 0x20 <poweroff timer byte> 720x0c 0x20 <poweroff timer byte>
730x0d 0x21 <resume settings byte> 730x0d 0x21 <resume settings byte>
740x0e 0x22 <shuffle,mp3filter,sort_case,discharge,statusbar,show_hidden, 740x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden,
75 scroll bar> 75 scroll bar>
760x0f 0x23 <scroll speed> 760x0f 0x23 <scroll speed>
770x10 0x24 <ff/rewind min step, acceleration rate> 770x10 0x24 <ff/rewind min step, acceleration rate>
@@ -267,11 +267,11 @@ int settings_save( void )
267 267
268 config_block[0xe] = (unsigned char) 268 config_block[0xe] = (unsigned char)
269 ((global_settings.playlist_shuffle & 1) | 269 ((global_settings.playlist_shuffle & 1) |
270 ((global_settings.mp3filter & 1) << 1) | 270 ((global_settings.dirfilter & 1) << 1) |
271 ((global_settings.sort_case & 1) << 2) | 271 ((global_settings.sort_case & 1) << 2) |
272 ((global_settings.discharge & 1) << 3) | 272 ((global_settings.discharge & 1) << 3) |
273 ((global_settings.statusbar & 1) << 4) | 273 ((global_settings.statusbar & 1) << 4) |
274 ((global_settings.show_hidden_files & 1) << 5) | 274 ((global_settings.dirfilter & 2) << 4) |
275 ((global_settings.scrollbar & 1) << 6)); 275 ((global_settings.scrollbar & 1) << 6));
276 276
277 config_block[0xf] = (unsigned char)(global_settings.scroll_speed << 3); 277 config_block[0xf] = (unsigned char)(global_settings.scroll_speed << 3);
@@ -361,11 +361,11 @@ void settings_load(void)
361 global_settings.resume = config_block[0xd]; 361 global_settings.resume = config_block[0xd];
362 if (config_block[0xe] != 0xFF) { 362 if (config_block[0xe] != 0xFF) {
363 global_settings.playlist_shuffle = config_block[0xe] & 1; 363 global_settings.playlist_shuffle = config_block[0xe] & 1;
364 global_settings.mp3filter = (config_block[0xe] >> 1) & 1; 364 global_settings.dirfilter = (config_block[0xe] >> 1) & 1;
365 global_settings.sort_case = (config_block[0xe] >> 2) & 1; 365 global_settings.sort_case = (config_block[0xe] >> 2) & 1;
366 global_settings.discharge = (config_block[0xe] >> 3) & 1; 366 global_settings.discharge = (config_block[0xe] >> 3) & 1;
367 global_settings.statusbar = (config_block[0xe] >> 4) & 1; 367 global_settings.statusbar = (config_block[0xe] >> 4) & 1;
368 global_settings.show_hidden_files = (config_block[0xe] >> 5) & 1; 368 global_settings.dirfilter |= ((config_block[0xe] >> 5) & 1) << 1;
369 global_settings.scrollbar = (config_block[0xe] >> 6) & 1; 369 global_settings.scrollbar = (config_block[0xe] >> 6) & 1;
370 /* Don't use the last bit, it must be unused to detect 370 /* Don't use the last bit, it must be unused to detect
371 an uninitialized entry */ 371 an uninitialized entry */
@@ -594,7 +594,7 @@ void settings_reset(void) {
594 global_settings.contrast = DEFAULT_CONTRAST_SETTING; 594 global_settings.contrast = DEFAULT_CONTRAST_SETTING;
595 global_settings.poweroff = DEFAULT_POWEROFF_SETTING; 595 global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
596 global_settings.backlight = DEFAULT_BACKLIGHT_SETTING; 596 global_settings.backlight = DEFAULT_BACKLIGHT_SETTING;
597 global_settings.mp3filter = true; 597 global_settings.dirfilter = SHOW_MUSIC;
598 global_settings.sort_case = false; 598 global_settings.sort_case = false;
599 global_settings.statusbar = true; 599 global_settings.statusbar = true;
600 global_settings.scrollbar = true; 600 global_settings.scrollbar = true;
@@ -603,7 +603,6 @@ void settings_reset(void) {
603 global_settings.discharge = 0; 603 global_settings.discharge = 0;
604 global_settings.total_uptime = 0; 604 global_settings.total_uptime = 0;
605 global_settings.scroll_speed = 8; 605 global_settings.scroll_speed = 8;
606 global_settings.show_hidden_files = false;
607 global_settings.ff_rewind_min_step = DEFAULT_FF_REWIND_MIN_STEP; 606 global_settings.ff_rewind_min_step = DEFAULT_FF_REWIND_MIN_STEP;
608 global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING; 607 global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING;
609 global_settings.resume_index = -1; 608 global_settings.resume_index = -1;
diff --git a/apps/settings.h b/apps/settings.h
index 1539d6d2e3..048c673539 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -77,7 +77,7 @@ struct user_settings
77 /* misc options */ 77 /* misc options */
78 78
79 int loop_playlist; /* do we return to top of playlist at end? */ 79 int loop_playlist; /* do we return to top of playlist at end? */
80 bool mp3filter; /* only display mp3/m3u files and dirs in directory? */ 80 int dirfilter; /* 0=display all, 1=only supported, 2=only music */
81 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ 81 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
82 int scroll_speed; /* long texts scrolling speed: 1-30 */ 82 int scroll_speed; /* long texts scrolling speed: 1-30 */
83 bool playlist_shuffle; 83 bool playlist_shuffle;
@@ -92,10 +92,6 @@ struct user_settings
92 /* show scroll bar */ 92 /* show scroll bar */
93 bool scrollbar; /* 0=hide, 1=show */ 93 bool scrollbar; /* 0=hide, 1=show */
94 94
95 /* Hidden and dotfile settings */
96 bool show_hidden_files; /* 1=show dotfiles/hidden,
97 0=hide dotfiles/hidden */
98
99 /* goto current song when exiting WPS */ 95 /* goto current song when exiting WPS */
100 bool browse_current; /* 1=goto current song, 96 bool browse_current; /* 1=goto current song,
101 0=goto previous location */ 97 0=goto previous location */
@@ -148,4 +144,7 @@ extern char rockboxdir[];
148#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 144#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000
149#define DEFAULT_FF_REWIND_ACCEL_SETTING 3 145#define DEFAULT_FF_REWIND_ACCEL_SETTING 3
150 146
147/* dir filter options */
148enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, NUM_FILTER_MODES };
149
151#endif /* __SETTINGS_H__ */ 150#endif /* __SETTINGS_H__ */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 41afc72468..8aba4bc2f2 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -38,14 +38,6 @@
38#include "ata.h" 38#include "ata.h"
39#include "lang.h" 39#include "lang.h"
40 40
41static bool show_hidden_files(void)
42{
43 return set_bool_options( str(LANG_HIDDEN),
44 &global_settings.show_hidden_files,
45 str(LANG_HIDDEN_SHOW),
46 str(LANG_HIDDEN_HIDE) );
47}
48
49static bool contrast(void) 41static bool contrast(void)
50{ 42{
51 return set_int( str(LANG_CONTRAST), "", &global_settings.contrast, 43 return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
@@ -64,9 +56,13 @@ static bool play_selected(void)
64 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected ); 56 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
65} 57}
66 58
67static bool mp3_filter(void) 59static bool dir_filter(void)
68{ 60{
69 return set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter ); 61 char* names[] = { str(LANG_FILTER_ALL),
62 str(LANG_FILTER_SUPPORTED),
63 str(LANG_FILTER_MUSIC) };
64 return set_option( str(LANG_FILTER), &global_settings.dirfilter,
65 names, 3, NULL );
70} 66}
71 67
72static bool sort_case(void) 68static bool sort_case(void)
@@ -298,8 +294,7 @@ static bool fileview_settings_menu(void)
298 294
299 struct menu_items items[] = { 295 struct menu_items items[] = {
300 { str(LANG_CASE_MENU), sort_case }, 296 { str(LANG_CASE_MENU), sort_case },
301 { str(LANG_MP3FILTER), mp3_filter }, 297 { str(LANG_FILTER), dir_filter },
302 { str(LANG_HIDDEN), show_hidden_files },
303 { str(LANG_FOLLOW), browse_current }, 298 { str(LANG_FOLLOW), browse_current },
304 }; 299 };
305 300
diff --git a/apps/tree.c b/apps/tree.c
index 3aba7fa3b4..d433787e4b 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -235,8 +235,8 @@ static int showdir(char *path, int start)
235 continue; 235 continue;
236 } 236 }
237 237
238 /* Skip dotfiles if set to skip them */ 238 /* filter out dotfiles and hidden files */
239 if (!global_settings.show_hidden_files && 239 if (global_settings.dirfilter != SHOW_ALL &&
240 ((entry->d_name[0]=='.') || 240 ((entry->d_name[0]=='.') ||
241 (entry->attribute & ATTR_HIDDEN))) { 241 (entry->attribute & ATTR_HIDDEN))) {
242 i--; 242 i--;
@@ -269,15 +269,22 @@ static int showdir(char *path, int start)
269 dptr->attr |= TREE_ATTR_MOD; 269 dptr->attr |= TREE_ATTR_MOD;
270 } 270 }
271 271
272 /* filter non-mp3 or m3u files */ 272 /* filter out non-music files */
273 if ( global_settings.mp3filter && 273 if ( global_settings.dirfilter == SHOW_MUSIC &&
274 (!(dptr->attr & 274 (!(dptr->attr &
275 (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) { 275 (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) {
276 i--; 276 i--;
277 continue; 277 continue;
278 } 278 }
279 279
280 if(len > NAME_BUFFER_SIZE - name_buffer_length - 1) { 280 /* filter out non-supported files */
281 if ( global_settings.dirfilter == SHOW_SUPPORTED &&
282 (!(dptr->attr & TREE_ATTR_MASK)) ) {
283 i--;
284 continue;
285 }
286
287 if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) {
281 /* Tell the world that we ran out of buffer space */ 288 /* Tell the world that we ran out of buffer space */
282 dir_buffer_full = true; 289 dir_buffer_full = true;
283 break; 290 break;
@@ -407,8 +414,8 @@ static int showdir(char *path, int start)
407#endif 414#endif
408 } 415 }
409 416
410 /* if MP3 filter is on, cut off the extension */ 417 /* if music filter is on, cut off the extension */
411 if (global_settings.mp3filter && 418 if (global_settings.dirfilter == SHOW_MUSIC &&
412 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA))) 419 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
413 { 420 {
414 char temp = dircache[i].name[len-4]; 421 char temp = dircache[i].name[len-4];
@@ -587,9 +594,8 @@ bool dirbrowse(char *root)
587 int button; 594 int button;
588 int tree_max_on_screen; 595 int tree_max_on_screen;
589 bool reload_root = false; 596 bool reload_root = false;
590 bool lastfilter = global_settings.mp3filter; 597 int lastfilter = global_settings.dirfilter;
591 bool lastsortcase = global_settings.sort_case; 598 bool lastsortcase = global_settings.sort_case;
592 bool lastshowhidden = global_settings.show_hidden_files;
593#ifdef HAVE_LCD_BITMAP 599#ifdef HAVE_LCD_BITMAP
594 int fw, fh; 600 int fw, fh;
595 lcd_getstringsize("A", &fw, &fh); 601 lcd_getstringsize("A", &fw, &fh);
@@ -927,9 +933,8 @@ bool dirbrowse(char *root)
927 933
928 /* do we need to rescan dir? */ 934 /* do we need to rescan dir? */
929 if (reload_root || 935 if (reload_root ||
930 lastfilter != global_settings.mp3filter || 936 lastfilter != global_settings.dirfilter ||
931 lastsortcase != global_settings.sort_case || 937 lastsortcase != global_settings.sort_case)
932 lastshowhidden != global_settings.show_hidden_files)
933 { 938 {
934 if ( reload_root ) { 939 if ( reload_root ) {
935 strcpy(currdir, "/"); 940 strcpy(currdir, "/");
@@ -939,9 +944,8 @@ bool dirbrowse(char *root)
939 dircursor = 0; 944 dircursor = 0;
940 dirstart = 0; 945 dirstart = 0;
941 lastdir[0] = 0; 946 lastdir[0] = 0;
942 lastfilter = global_settings.mp3filter; 947 lastfilter = global_settings.dirfilter;
943 lastsortcase = global_settings.sort_case; 948 lastsortcase = global_settings.sort_case;
944 lastshowhidden = global_settings.show_hidden_files;
945 restore = true; 949 restore = true;
946 } 950 }
947 951
@@ -964,25 +968,21 @@ bool dirbrowse(char *root)
964 if(lasti!=i || restore) { 968 if(lasti!=i || restore) {
965 lasti=i; 969 lasti=i;
966 lcd_stop_scroll(); 970 lcd_stop_scroll();
967 if (global_settings.mp3filter && 971 if (global_settings.dirfilter == SHOW_MUSIC &&
968 (dircache[i].attr & 972 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
969 (TREE_ATTR_M3U|TREE_ATTR_MPA)))
970 { 973 {
971 int len = strlen(dircache[i].name); 974 int len = strlen(dircache[i].name);
972 char temp = dircache[i].name[len-4]; 975 char temp = dircache[i].name[len-4];
973 dircache[i].name[len-4] = 0; 976 dircache[i].name[len-4] = 0;
974 lcd_puts_scroll(LINE_X, dircursor, 977 lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
975 dircache[i].name);
976 dircache[i].name[len-4] = temp; 978 dircache[i].name[len-4] = temp;
977 } 979 }
978 else 980 else
979 lcd_puts_scroll(LINE_X, dircursor, 981 lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
980 dircache[i].name);
981 } 982 }
982 } 983 }
983 status_draw(); 984 status_draw();
984 lcd_update(); 985 lcd_update();
985
986 } 986 }
987 987
988 return false; 988 return false;