diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/action.h | 1 | ||||
-rw-r--r-- | apps/bookmark.c | 65 | ||||
-rw-r--r-- | apps/bookmark.h | 3 | ||||
-rw-r--r-- | apps/main_menu.c | 7 | ||||
-rw-r--r-- | apps/onplay.c | 266 | ||||
-rw-r--r-- | apps/onplay.h | 2 | ||||
-rw-r--r-- | apps/playlist_menu.c | 24 | ||||
-rw-r--r-- | apps/playlist_viewer.c | 3 | ||||
-rw-r--r-- | apps/tree.c | 30 | ||||
-rw-r--r-- | apps/wps.c | 15 | ||||
-rw-r--r-- | apps/wps.h | 9 |
11 files changed, 281 insertions, 144 deletions
diff --git a/apps/action.h b/apps/action.h index ef17185df2..3c3db7d54e 100644 --- a/apps/action.h +++ b/apps/action.h | |||
@@ -24,5 +24,6 @@ | |||
24 | #define CONTEXT_TREE 2 | 24 | #define CONTEXT_TREE 2 |
25 | #define CONTEXT_RECORD 3 | 25 | #define CONTEXT_RECORD 3 |
26 | #define CONTEXT_MAINMENU 4 | 26 | #define CONTEXT_MAINMENU 4 |
27 | #define CONTEXT_ID3DB 5 | ||
27 | 28 | ||
28 | #endif | 29 | #endif |
diff --git a/apps/bookmark.c b/apps/bookmark.c index d2911af39d..4afba78d14 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark" | 53 | #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark" |
54 | 54 | ||
55 | static bool add_bookmark(const char* bookmark_file_name, const char* bookmark); | 55 | static bool add_bookmark(const char* bookmark_file_name, const char* bookmark); |
56 | static bool bookmark_load_menu(void); | ||
57 | static bool check_bookmark(const char* bookmark); | 56 | static bool check_bookmark(const char* bookmark); |
58 | static char* create_bookmark(void); | 57 | static char* create_bookmark(void); |
59 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id); | 58 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id); |
@@ -87,38 +86,6 @@ static char global_bookmark[MAX_BOOKMARK_SIZE]; | |||
87 | static char global_filename[MAX_PATH]; | 86 | static char global_filename[MAX_PATH]; |
88 | 87 | ||
89 | /* ----------------------------------------------------------------------- */ | 88 | /* ----------------------------------------------------------------------- */ |
90 | /* Displays the bookmark menu options for the user to decide. This is an */ | ||
91 | /* interface function. */ | ||
92 | /* ----------------------------------------------------------------------- */ | ||
93 | bool bookmark_menu(void) | ||
94 | { | ||
95 | int m; | ||
96 | bool result; | ||
97 | |||
98 | static const struct menu_item items[] = { | ||
99 | { ID2P(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu}, | ||
100 | { ID2P(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu}, | ||
101 | { ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load}, | ||
102 | }; | ||
103 | |||
104 | m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, | ||
105 | NULL, NULL, NULL); | ||
106 | |||
107 | #ifdef HAVE_LCD_CHARCELLS | ||
108 | status_set_param(true); | ||
109 | #endif | ||
110 | result = menu_run(m); | ||
111 | #ifdef HAVE_LCD_CHARCELLS | ||
112 | status_set_param(false); | ||
113 | #endif | ||
114 | menu_exit(m); | ||
115 | |||
116 | settings_save(); | ||
117 | |||
118 | return result; | ||
119 | } | ||
120 | |||
121 | /* ----------------------------------------------------------------------- */ | ||
122 | /* This is the interface function from the main menu. */ | 89 | /* This is the interface function from the main menu. */ |
123 | /* ----------------------------------------------------------------------- */ | 90 | /* ----------------------------------------------------------------------- */ |
124 | bool bookmark_create_menu(void) | 91 | bool bookmark_create_menu(void) |
@@ -133,7 +100,7 @@ bool bookmark_create_menu(void) | |||
133 | /* for the user. The user can then select a bookmark to load. */ | 100 | /* for the user. The user can then select a bookmark to load. */ |
134 | /* If no file/directory is currently playing, the menu item does not work. */ | 101 | /* If no file/directory is currently playing, the menu item does not work. */ |
135 | /* ----------------------------------------------------------------------- */ | 102 | /* ----------------------------------------------------------------------- */ |
136 | static bool bookmark_load_menu(void) | 103 | bool bookmark_load_menu(void) |
137 | { | 104 | { |
138 | bool success = true; | 105 | bool success = true; |
139 | int offset; | 106 | int offset; |
@@ -628,6 +595,8 @@ static char* select_bookmark(const char* bookmark_file_name) | |||
628 | int bookmark_count = 0; | 595 | int bookmark_count = 0; |
629 | 596 | ||
630 | #ifdef HAVE_LCD_BITMAP | 597 | #ifdef HAVE_LCD_BITMAP |
598 | int x = lcd_getxmargin(); | ||
599 | int y = lcd_getymargin(); | ||
631 | lcd_setmargins(0, 0); | 600 | lcd_setmargins(0, 0); |
632 | #endif | 601 | #endif |
633 | 602 | ||
@@ -712,6 +681,9 @@ static char* select_bookmark(const char* bookmark_file_name) | |||
712 | #ifdef SETTINGS_OK2 | 681 | #ifdef SETTINGS_OK2 |
713 | case SETTINGS_OK2: | 682 | case SETTINGS_OK2: |
714 | #endif | 683 | #endif |
684 | #ifdef HAVE_LCD_BITMAP | ||
685 | lcd_setmargins(x, y); | ||
686 | #endif | ||
715 | return NULL; | 687 | return NULL; |
716 | 688 | ||
717 | default: | 689 | default: |
@@ -1142,6 +1114,31 @@ static bool generate_bookmark_file_name(const char *in) | |||
1142 | } | 1114 | } |
1143 | 1115 | ||
1144 | /* ----------------------------------------------------------------------- */ | 1116 | /* ----------------------------------------------------------------------- */ |
1117 | /* Returns the bookmark name for the current playlist */ | ||
1118 | /* ----------------------------------------------------------------------- */ | ||
1119 | bool bookmark_exist(void) | ||
1120 | { | ||
1121 | bool exist=false; | ||
1122 | |||
1123 | if(system_check()) | ||
1124 | { | ||
1125 | char* name = playlist_get_name(NULL, global_temp_buffer, | ||
1126 | sizeof(global_temp_buffer)); | ||
1127 | if (generate_bookmark_file_name(name)) | ||
1128 | { | ||
1129 | int fd=open(global_bookmark_file_name, O_RDONLY); | ||
1130 | if (fd >=0) | ||
1131 | { | ||
1132 | close(fd); | ||
1133 | exist=true; | ||
1134 | } | ||
1135 | } | ||
1136 | } | ||
1137 | |||
1138 | return exist; | ||
1139 | } | ||
1140 | |||
1141 | /* ----------------------------------------------------------------------- */ | ||
1145 | /* Checks the current state of the system and returns if it is in a */ | 1142 | /* Checks the current state of the system and returns if it is in a */ |
1146 | /* bookmarkable state. */ | 1143 | /* bookmarkable state. */ |
1147 | /* ----------------------------------------------------------------------- */ | 1144 | /* ----------------------------------------------------------------------- */ |
diff --git a/apps/bookmark.h b/apps/bookmark.h index c5fe6fe7ba..16f4e5609f 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | 23 | ||
24 | bool bookmark_menu(void); | 24 | bool bookmark_load_menu(void); |
25 | bool bookmark_autobookmark(void); | 25 | bool bookmark_autobookmark(void); |
26 | bool bookmark_create_menu(void); | 26 | bool bookmark_create_menu(void); |
27 | bool bookmark_mrb_load(void); | 27 | bool bookmark_mrb_load(void); |
@@ -29,6 +29,7 @@ bool bookmark_autoload(const char* file); | |||
29 | bool bookmark_load(const char* file, bool autoload); | 29 | bool bookmark_load(const char* file, bool autoload); |
30 | void bookmark_play(char* resume_file, int index, int offset, int seed, | 30 | void bookmark_play(char* resume_file, int index, int offset, int seed, |
31 | char *filename); | 31 | char *filename); |
32 | bool bookmark_exist(void); | ||
32 | 33 | ||
33 | #endif /* __BOOKMARK_H__ */ | 34 | #endif /* __BOOKMARK_H__ */ |
34 | 35 | ||
diff --git a/apps/main_menu.c b/apps/main_menu.c index 88599a8705..33e9269a8a 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include "debug_menu.h" | 32 | #include "debug_menu.h" |
33 | #include "sprintf.h" | 33 | #include "sprintf.h" |
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include "playlist.h" | ||
36 | #include "settings.h" | 35 | #include "settings.h" |
37 | #include "settings_menu.h" | 36 | #include "settings_menu.h" |
38 | #include "power.h" | 37 | #include "power.h" |
@@ -41,7 +40,6 @@ | |||
41 | #include "status.h" | 40 | #include "status.h" |
42 | #include "fat.h" | 41 | #include "fat.h" |
43 | #include "bookmark.h" | 42 | #include "bookmark.h" |
44 | #include "wps.h" | ||
45 | #include "buffer.h" | 43 | #include "buffer.h" |
46 | #include "screens.h" | 44 | #include "screens.h" |
47 | #include "playlist_menu.h" | 45 | #include "playlist_menu.h" |
@@ -342,7 +340,6 @@ bool info_menu(void) | |||
342 | 340 | ||
343 | /* info menu */ | 341 | /* info menu */ |
344 | static const struct menu_item items[] = { | 342 | static const struct menu_item items[] = { |
345 | { ID2P(LANG_MENU_SHOW_ID3_INFO), browse_id3 }, | ||
346 | { ID2P(LANG_INFO_MENU), show_info }, | 343 | { ID2P(LANG_INFO_MENU), show_info }, |
347 | { ID2P(LANG_VERSION), show_credits }, | 344 | { ID2P(LANG_VERSION), show_credits }, |
348 | #ifndef SIMULATOR | 345 | #ifndef SIMULATOR |
@@ -373,8 +370,8 @@ bool main_menu(void) | |||
373 | /* main menu */ | 370 | /* main menu */ |
374 | struct menu_item items[9]; | 371 | struct menu_item items[9]; |
375 | 372 | ||
376 | items[i].desc = ID2P(LANG_BOOKMARK_MENU); | 373 | items[i].desc = ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS); |
377 | items[i++].function = bookmark_menu; | 374 | items[i++].function = bookmark_mrb_load; |
378 | 375 | ||
379 | items[i].desc = ID2P(LANG_SOUND_SETTINGS); | 376 | items[i].desc = ID2P(LANG_SOUND_SETTINGS); |
380 | items[i++].function = sound_menu; | 377 | items[i++].function = sound_menu; |
diff --git a/apps/onplay.c b/apps/onplay.c index 78562c5bec..f686533324 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -45,11 +45,68 @@ | |||
45 | #include "onplay.h" | 45 | #include "onplay.h" |
46 | #include "filetypes.h" | 46 | #include "filetypes.h" |
47 | #include "plugin.h" | 47 | #include "plugin.h" |
48 | #include "bookmark.h" | ||
49 | #include "wps.h" | ||
50 | #include "action.h" | ||
51 | #ifdef HAVE_LCD_BITMAP | ||
52 | #include "icons.h" | ||
53 | #endif | ||
48 | 54 | ||
55 | #define DEFAULT_PLAYLIST_NAME "/dynamic.m3u" | ||
56 | |||
57 | static int context; | ||
49 | static char* selected_file = NULL; | 58 | static char* selected_file = NULL; |
50 | static int selected_file_attr = 0; | 59 | static int selected_file_attr = 0; |
51 | static int onplay_result = ONPLAY_OK; | 60 | static int onplay_result = ONPLAY_OK; |
52 | 61 | ||
62 | /* For playlist options */ | ||
63 | struct playlist_args { | ||
64 | int position; | ||
65 | bool queue; | ||
66 | }; | ||
67 | |||
68 | /* ----------------------------------------------------------------------- */ | ||
69 | /* Displays the bookmark menu options for the user to decide. This is an */ | ||
70 | /* interface function. */ | ||
71 | /* ----------------------------------------------------------------------- */ | ||
72 | bool bookmark_menu(void) | ||
73 | { | ||
74 | int i,m; | ||
75 | bool result; | ||
76 | struct menu_item items[3]; | ||
77 | |||
78 | i=0; | ||
79 | |||
80 | if ((audio_status() & AUDIO_STATUS_PLAY)) | ||
81 | { | ||
82 | items[i].desc = ID2P(LANG_BOOKMARK_MENU_CREATE); | ||
83 | items[i].function = bookmark_create_menu; | ||
84 | i++; | ||
85 | |||
86 | if (bookmark_exist()) | ||
87 | { | ||
88 | items[i].desc = ID2P(LANG_BOOKMARK_MENU_LIST); | ||
89 | items[i].function = bookmark_load_menu; | ||
90 | i++; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | m=menu_init( items, i, NULL, NULL, NULL, NULL ); | ||
95 | |||
96 | #ifdef HAVE_LCD_CHARCELLS | ||
97 | status_set_param(true); | ||
98 | #endif | ||
99 | result = menu_run(m); | ||
100 | #ifdef HAVE_LCD_CHARCELLS | ||
101 | status_set_param(false); | ||
102 | #endif | ||
103 | menu_exit(m); | ||
104 | |||
105 | settings_save(); | ||
106 | |||
107 | return result; | ||
108 | } | ||
109 | |||
53 | static bool list_viewers(void) | 110 | static bool list_viewers(void) |
54 | { | 111 | { |
55 | struct menu_item menu[16]; | 112 | struct menu_item menu[16]; |
@@ -70,17 +127,28 @@ static bool list_viewers(void) | |||
70 | splash(HZ*2, true, "No viewers found"); | 127 | splash(HZ*2, true, "No viewers found"); |
71 | } | 128 | } |
72 | 129 | ||
73 | if(ret == PLUGIN_USB_CONNECTED) | 130 | if (ret == PLUGIN_USB_CONNECTED) |
74 | onplay_result = ONPLAY_RELOAD_DIR; | 131 | onplay_result = ONPLAY_RELOAD_DIR; |
75 | 132 | ||
76 | return false; | 133 | return false; |
77 | } | 134 | } |
78 | 135 | ||
79 | /* For playlist options */ | 136 | static bool save_playlist(void) |
80 | struct playlist_args { | 137 | { |
81 | int position; | 138 | char filename[MAX_PATH+1]; |
82 | bool queue; | 139 | |
83 | }; | 140 | strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename)); |
141 | |||
142 | if (!kbd_input(filename, sizeof(filename))) | ||
143 | { | ||
144 | playlist_save(NULL, filename); | ||
145 | |||
146 | /* reload in case playlist was saved to cwd */ | ||
147 | onplay_result = ONPLAY_RELOAD_DIR; | ||
148 | } | ||
149 | |||
150 | return false; | ||
151 | } | ||
84 | 152 | ||
85 | static bool add_to_playlist(int position, bool queue) | 153 | static bool add_to_playlist(int position, bool queue) |
86 | { | 154 | { |
@@ -168,12 +236,13 @@ static bool view_playlist(void) | |||
168 | /* Sub-menu for playlist options */ | 236 | /* Sub-menu for playlist options */ |
169 | static bool playlist_options(void) | 237 | static bool playlist_options(void) |
170 | { | 238 | { |
171 | struct menu_item items[7]; | 239 | struct menu_item items[10]; |
172 | struct playlist_args args[7]; /* increase these 2 if you add entries! */ | 240 | struct playlist_args args[10]; /* increase these 2 if you add entries! */ |
173 | int m, i=0, pstart=0, result; | 241 | int m, i=0, pstart=0, result; |
174 | bool ret = false; | 242 | bool ret = false; |
175 | 243 | ||
176 | if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) | 244 | if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U && |
245 | context == CONTEXT_TREE) | ||
177 | { | 246 | { |
178 | items[i].desc = ID2P(LANG_VIEW); | 247 | items[i].desc = ID2P(LANG_VIEW); |
179 | items[i].function = view_playlist; | 248 | items[i].function = view_playlist; |
@@ -183,43 +252,64 @@ static bool playlist_options(void) | |||
183 | 252 | ||
184 | if (audio_status() & AUDIO_STATUS_PLAY) | 253 | if (audio_status() & AUDIO_STATUS_PLAY) |
185 | { | 254 | { |
186 | items[i].desc = ID2P(LANG_INSERT); | 255 | items[i].desc = ID2P(LANG_VIEW_DYNAMIC_PLAYLIST); |
187 | args[i].position = PLAYLIST_INSERT; | 256 | items[i].function = playlist_viewer; |
188 | args[i].queue = false; | ||
189 | i++; | ||
190 | |||
191 | items[i].desc = ID2P(LANG_INSERT_FIRST); | ||
192 | args[i].position = PLAYLIST_INSERT_FIRST; | ||
193 | args[i].queue = false; | ||
194 | i++; | ||
195 | |||
196 | items[i].desc = ID2P(LANG_INSERT_LAST); | ||
197 | args[i].position = PLAYLIST_INSERT_LAST; | ||
198 | args[i].queue = false; | ||
199 | i++; | ||
200 | |||
201 | items[i].desc = ID2P(LANG_QUEUE); | ||
202 | args[i].position = PLAYLIST_INSERT; | ||
203 | args[i].queue = true; | ||
204 | i++; | ||
205 | |||
206 | items[i].desc = ID2P(LANG_QUEUE_FIRST); | ||
207 | args[i].position = PLAYLIST_INSERT_FIRST; | ||
208 | args[i].queue = true; | ||
209 | i++; | 257 | i++; |
258 | pstart++; | ||
210 | 259 | ||
211 | items[i].desc = ID2P(LANG_QUEUE_LAST); | 260 | items[i].desc = ID2P(LANG_SAVE_DYNAMIC_PLAYLIST); |
212 | args[i].position = PLAYLIST_INSERT_LAST; | 261 | items[i].function = save_playlist; |
213 | args[i].queue = true; | ||
214 | i++; | 262 | i++; |
263 | pstart++; | ||
215 | } | 264 | } |
216 | else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | 265 | |
217 | (selected_file_attr & ATTR_DIRECTORY)) | 266 | if (context == CONTEXT_TREE) |
218 | { | 267 | { |
219 | items[i].desc = ID2P(LANG_INSERT); | 268 | items[i].desc = ID2P(LANG_CREATE_PLAYLIST); |
220 | args[i].position = PLAYLIST_INSERT; | 269 | items[i].function = create_playlist; |
221 | args[i].queue = false; | ||
222 | i++; | 270 | i++; |
271 | pstart++; | ||
272 | |||
273 | if (audio_status() & AUDIO_STATUS_PLAY) | ||
274 | { | ||
275 | items[i].desc = ID2P(LANG_INSERT); | ||
276 | args[i].position = PLAYLIST_INSERT; | ||
277 | args[i].queue = false; | ||
278 | i++; | ||
279 | |||
280 | items[i].desc = ID2P(LANG_INSERT_FIRST); | ||
281 | args[i].position = PLAYLIST_INSERT_FIRST; | ||
282 | args[i].queue = false; | ||
283 | i++; | ||
284 | |||
285 | items[i].desc = ID2P(LANG_INSERT_LAST); | ||
286 | args[i].position = PLAYLIST_INSERT_LAST; | ||
287 | args[i].queue = false; | ||
288 | i++; | ||
289 | |||
290 | items[i].desc = ID2P(LANG_QUEUE); | ||
291 | args[i].position = PLAYLIST_INSERT; | ||
292 | args[i].queue = true; | ||
293 | i++; | ||
294 | |||
295 | items[i].desc = ID2P(LANG_QUEUE_FIRST); | ||
296 | args[i].position = PLAYLIST_INSERT_FIRST; | ||
297 | args[i].queue = true; | ||
298 | i++; | ||
299 | |||
300 | items[i].desc = ID2P(LANG_QUEUE_LAST); | ||
301 | args[i].position = PLAYLIST_INSERT_LAST; | ||
302 | args[i].queue = true; | ||
303 | i++; | ||
304 | } | ||
305 | else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | ||
306 | (selected_file_attr & ATTR_DIRECTORY)) | ||
307 | { | ||
308 | items[i].desc = ID2P(LANG_INSERT); | ||
309 | args[i].position = PLAYLIST_INSERT; | ||
310 | args[i].queue = false; | ||
311 | i++; | ||
312 | } | ||
223 | } | 313 | } |
224 | 314 | ||
225 | m = menu_init( items, i, NULL, NULL, NULL, NULL ); | 315 | m = menu_init( items, i, NULL, NULL, NULL, NULL ); |
@@ -385,11 +475,11 @@ bool create_dir(void) | |||
385 | 475 | ||
386 | pathlen = strlen(dirname); | 476 | pathlen = strlen(dirname); |
387 | rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen); | 477 | rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen); |
388 | if(rc < 0) | 478 | if (rc < 0) |
389 | return false; | 479 | return false; |
390 | 480 | ||
391 | rc = mkdir(dirname, 0); | 481 | rc = mkdir(dirname, 0); |
392 | if(rc < 0) { | 482 | if (rc < 0) { |
393 | splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED)); | 483 | splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED)); |
394 | } else { | 484 | } else { |
395 | onplay_result = ONPLAY_RELOAD_DIR; | 485 | onplay_result = ONPLAY_RELOAD_DIR; |
@@ -398,24 +488,38 @@ bool create_dir(void) | |||
398 | return true; | 488 | return true; |
399 | } | 489 | } |
400 | 490 | ||
401 | int onplay(char* file, int attr) | 491 | int onplay(char* file, int attr, int from) |
402 | { | 492 | { |
403 | struct menu_item items[6]; /* increase this if you add entries! */ | 493 | struct menu_item items[8]; /* increase this if you add entries! */ |
404 | int m, i=0, result; | 494 | int m, i=0, result; |
405 | 495 | ||
406 | onplay_result = ONPLAY_OK; | 496 | onplay_result = ONPLAY_OK; |
497 | context=from; | ||
498 | selected_file = file; | ||
499 | selected_file_attr = attr; | ||
407 | 500 | ||
408 | if(file) | 501 | if (context == CONTEXT_WPS || |
502 | context == CONTEXT_TREE || | ||
503 | context == CONTEXT_ID3DB) | ||
409 | { | 504 | { |
410 | selected_file = file; | 505 | if ((audio_status() & AUDIO_STATUS_PLAY)) |
411 | selected_file_attr = attr; | 506 | { |
412 | 507 | items[i].desc = ID2P(LANG_BOOKMARK_MENU); | |
413 | if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | 508 | items[i].function = bookmark_menu; |
414 | (attr & ATTR_DIRECTORY) || | 509 | i++; |
415 | ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) | 510 | } |
511 | |||
512 | items[i].desc = ID2P(LANG_PLAYLIST); | ||
513 | items[i].function = playlist_options; | ||
514 | i++; | ||
515 | } | ||
516 | |||
517 | if (file) | ||
518 | { | ||
519 | if (context == CONTEXT_WPS) | ||
416 | { | 520 | { |
417 | items[i].desc = ID2P(LANG_PLAYLIST); | 521 | items[i].desc = ID2P(LANG_MENU_SHOW_ID3_INFO); |
418 | items[i].function = playlist_options; | 522 | items[i].function = browse_id3; |
419 | i++; | 523 | i++; |
420 | } | 524 | } |
421 | 525 | ||
@@ -423,11 +527,14 @@ int onplay(char* file, int attr) | |||
423 | if (!(attr & ATTR_VOLUME)) /* no rename+delete for volumes */ | 527 | if (!(attr & ATTR_VOLUME)) /* no rename+delete for volumes */ |
424 | #endif | 528 | #endif |
425 | { | 529 | { |
426 | items[i].desc = ID2P(LANG_RENAME); | 530 | if (context == CONTEXT_TREE) |
427 | items[i].function = rename_file; | 531 | { |
428 | i++; | 532 | items[i].desc = ID2P(LANG_RENAME); |
429 | 533 | items[i].function = rename_file; | |
430 | if (!(attr & ATTR_DIRECTORY)) | 534 | i++; |
535 | } | ||
536 | |||
537 | if (!(attr & ATTR_DIRECTORY) && context == CONTEXT_TREE) | ||
431 | { | 538 | { |
432 | items[i].desc = ID2P(LANG_DELETE); | 539 | items[i].desc = ID2P(LANG_DELETE); |
433 | items[i].function = delete_file; | 540 | items[i].function = delete_file; |
@@ -435,13 +542,16 @@ int onplay(char* file, int attr) | |||
435 | } | 542 | } |
436 | else | 543 | else |
437 | { | 544 | { |
438 | items[i].desc = ID2P(LANG_DELETE_DIR); | 545 | if (context == CONTEXT_TREE) |
439 | items[i].function = delete_dir; | 546 | { |
440 | i++; | 547 | items[i].desc = ID2P(LANG_DELETE_DIR); |
548 | items[i].function = delete_dir; | ||
549 | i++; | ||
550 | } | ||
441 | } | 551 | } |
442 | } | 552 | } |
443 | 553 | ||
444 | if (!(attr & ATTR_DIRECTORY)) | 554 | if (!(attr & ATTR_DIRECTORY) && attr) |
445 | { | 555 | { |
446 | items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH); | 556 | items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH); |
447 | items[i].function = list_viewers; | 557 | items[i].function = list_viewers; |
@@ -449,16 +559,30 @@ int onplay(char* file, int attr) | |||
449 | } | 559 | } |
450 | } | 560 | } |
451 | 561 | ||
452 | items[i].desc = ID2P(LANG_CREATE_DIR); | 562 | if (context == CONTEXT_TREE) |
453 | items[i].function = create_dir; | 563 | { |
454 | i++; | 564 | items[i].desc = ID2P(LANG_CREATE_DIR); |
565 | items[i].function = create_dir; | ||
566 | i++; | ||
567 | } | ||
455 | 568 | ||
456 | /* DIY menu handling, since we want to exit after selection */ | 569 | /* DIY menu handling, since we want to exit after selection */ |
457 | m = menu_init( items, i, NULL, NULL, NULL, NULL ); | 570 | button_clear_queue(); |
458 | result = menu_show(m); | 571 | if (i) |
459 | if (result >= 0) | 572 | { |
460 | items[result].function(); | 573 | m = menu_init( items, i, NULL, NULL, NULL, NULL ); |
461 | menu_exit(m); | 574 | result = menu_show(m); |
575 | if (result >= 0) | ||
576 | items[result].function(); | ||
577 | menu_exit(m); | ||
578 | |||
579 | #ifdef HAVE_LCD_BITMAP | ||
580 | if (global_settings.statusbar) | ||
581 | lcd_setmargins(0, STATUSBAR_HEIGHT); | ||
582 | else | ||
583 | lcd_setmargins(0, 0); | ||
584 | #endif | ||
585 | } | ||
462 | 586 | ||
463 | return onplay_result; | 587 | return onplay_result; |
464 | } | 588 | } |
diff --git a/apps/onplay.h b/apps/onplay.h index 7b47479e4b..08737becca 100644 --- a/apps/onplay.h +++ b/apps/onplay.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #ifndef _ONPLAY_H_ | 19 | #ifndef _ONPLAY_H_ |
20 | #define _ONPLAY_H_ | 20 | #define _ONPLAY_H_ |
21 | 21 | ||
22 | int onplay(char* file, int attr); | 22 | int onplay(char* file, int attr, int from_screen); |
23 | 23 | ||
24 | enum { | 24 | enum { |
25 | ONPLAY_OK, | 25 | ONPLAY_OK, |
diff --git a/apps/playlist_menu.c b/apps/playlist_menu.c index 3497b1d54d..444e0ae3d2 100644 --- a/apps/playlist_menu.c +++ b/apps/playlist_menu.c | |||
@@ -20,34 +20,13 @@ | |||
20 | #include <string.h> | 20 | #include <string.h> |
21 | 21 | ||
22 | #include "menu.h" | 22 | #include "menu.h" |
23 | #include "file.h" | ||
24 | #include "keyboard.h" | 23 | #include "keyboard.h" |
25 | #include "playlist.h" | 24 | #include "playlist.h" |
26 | #include "tree.h" | 25 | #include "tree.h" |
27 | #include "settings.h" | 26 | #include "settings.h" |
28 | #include "playlist_viewer.h" | ||
29 | #include "talk.h" | 27 | #include "talk.h" |
30 | #include "lang.h" | 28 | #include "lang.h" |
31 | 29 | ||
32 | #define DEFAULT_PLAYLIST_NAME "/dynamic.m3u" | ||
33 | |||
34 | static bool save_playlist(void) | ||
35 | { | ||
36 | char filename[MAX_PATH+1]; | ||
37 | |||
38 | strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename)); | ||
39 | |||
40 | if (!kbd_input(filename, sizeof(filename))) | ||
41 | { | ||
42 | playlist_save(NULL, filename); | ||
43 | |||
44 | /* reload in case playlist was saved to cwd */ | ||
45 | reload_directory(); | ||
46 | } | ||
47 | |||
48 | return false; | ||
49 | } | ||
50 | |||
51 | static bool recurse_directory(void) | 30 | static bool recurse_directory(void) |
52 | { | 31 | { |
53 | static const struct opt_items names[] = { | 32 | static const struct opt_items names[] = { |
@@ -67,9 +46,6 @@ bool playlist_menu(void) | |||
67 | bool result; | 46 | bool result; |
68 | 47 | ||
69 | static const struct menu_item items[] = { | 48 | static const struct menu_item items[] = { |
70 | { ID2P(LANG_CREATE_PLAYLIST), create_playlist }, | ||
71 | { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer }, | ||
72 | { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, | ||
73 | { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory }, | 49 | { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory }, |
74 | }; | 50 | }; |
75 | 51 | ||
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 64d57d7d2e..8b517b686d 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "onplay.h" | 33 | #include "onplay.h" |
34 | #include "talk.h" | 34 | #include "talk.h" |
35 | #include "misc.h" | 35 | #include "misc.h" |
36 | #include "action.h" | ||
36 | 37 | ||
37 | #ifdef HAVE_LCD_BITMAP | 38 | #ifdef HAVE_LCD_BITMAP |
38 | #include "widgets.h" | 39 | #include "widgets.h" |
@@ -728,7 +729,7 @@ static int onplay_menu(int index) | |||
728 | break; | 729 | break; |
729 | case 2: | 730 | case 2: |
730 | { | 731 | { |
731 | onplay(tracks[index].name, TREE_ATTR_MPA); | 732 | onplay(tracks[index].name, TREE_ATTR_MPA, CONTEXT_TREE); |
732 | 733 | ||
733 | if (!viewer.playlist) | 734 | if (!viewer.playlist) |
734 | ret = 1; | 735 | ret = 1; |
diff --git a/apps/tree.c b/apps/tree.c index 1332fc07ba..344088d12a 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -110,6 +110,7 @@ static bool reload_dir = false; | |||
110 | 110 | ||
111 | static bool start_wps = false; | 111 | static bool start_wps = false; |
112 | static bool dirbrowse(void); | 112 | static bool dirbrowse(void); |
113 | static int curr_context = false; | ||
113 | 114 | ||
114 | bool check_rockboxdir(void) | 115 | bool check_rockboxdir(void) |
115 | { | 116 | { |
@@ -625,10 +626,14 @@ static bool check_changed_id3mode(bool currmode) | |||
625 | if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) { | 626 | if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) { |
626 | currmode = global_settings.dirfilter == SHOW_ID3DB; | 627 | currmode = global_settings.dirfilter == SHOW_ID3DB; |
627 | if (currmode) { | 628 | if (currmode) { |
629 | curr_context=CONTEXT_ID3DB; | ||
628 | db_load(&tc); | 630 | db_load(&tc); |
629 | } | 631 | } |
630 | else | 632 | else |
633 | { | ||
634 | curr_context=CONTEXT_TREE; | ||
631 | ft_load(&tc, NULL); | 635 | ft_load(&tc, NULL); |
636 | } | ||
632 | } | 637 | } |
633 | return currmode; | 638 | return currmode; |
634 | } | 639 | } |
@@ -660,6 +665,11 @@ static bool dirbrowse(void) | |||
660 | char* currdir = tc.currdir; /* just a shortcut */ | 665 | char* currdir = tc.currdir; /* just a shortcut */ |
661 | bool id3db = *tc.dirfilter == SHOW_ID3DB; | 666 | bool id3db = *tc.dirfilter == SHOW_ID3DB; |
662 | 667 | ||
668 | if (id3db) | ||
669 | curr_context=CONTEXT_ID3DB; | ||
670 | else | ||
671 | curr_context=CONTEXT_TREE; | ||
672 | |||
663 | #ifdef HAVE_LCD_BITMAP | 673 | #ifdef HAVE_LCD_BITMAP |
664 | tree_max_on_screen = recalc_screen_height(); | 674 | tree_max_on_screen = recalc_screen_height(); |
665 | #else | 675 | #else |
@@ -1059,7 +1069,7 @@ static bool dirbrowse(void) | |||
1059 | /* don't enter f2 from plugin browser */ | 1069 | /* don't enter f2 from plugin browser */ |
1060 | if (*tc.dirfilter < NUM_FILTER_MODES) | 1070 | if (*tc.dirfilter < NUM_FILTER_MODES) |
1061 | { | 1071 | { |
1062 | if (quick_screen(CONTEXT_TREE, BUTTON_F2)) | 1072 | if (quick_screen(curr_context, BUTTON_F2)) |
1063 | reload_dir = true; | 1073 | reload_dir = true; |
1064 | restore = true; | 1074 | restore = true; |
1065 | 1075 | ||
@@ -1071,7 +1081,7 @@ static bool dirbrowse(void) | |||
1071 | /* don't enter f3 from plugin browser */ | 1081 | /* don't enter f3 from plugin browser */ |
1072 | if (*tc.dirfilter < NUM_FILTER_MODES) | 1082 | if (*tc.dirfilter < NUM_FILTER_MODES) |
1073 | { | 1083 | { |
1074 | if (quick_screen(CONTEXT_TREE, BUTTON_F3)) | 1084 | if (quick_screen(curr_context, BUTTON_F3)) |
1075 | reload_dir = true; | 1085 | reload_dir = true; |
1076 | tree_max_on_screen = recalc_screen_height(); | 1086 | tree_max_on_screen = recalc_screen_height(); |
1077 | restore = true; | 1087 | restore = true; |
@@ -1091,7 +1101,7 @@ static bool dirbrowse(void) | |||
1091 | int attr = 0; | 1101 | int attr = 0; |
1092 | 1102 | ||
1093 | if(!numentries) | 1103 | if(!numentries) |
1094 | onplay_result = onplay(NULL, 0); | 1104 | onplay_result = onplay(NULL, 0, curr_context); |
1095 | else { | 1105 | else { |
1096 | if (currdir[1]) | 1106 | if (currdir[1]) |
1097 | snprintf(buf, sizeof buf, "%s/%s", | 1107 | snprintf(buf, sizeof buf, "%s/%s", |
@@ -1099,9 +1109,19 @@ static bool dirbrowse(void) | |||
1099 | else | 1109 | else |
1100 | snprintf(buf, sizeof buf, "/%s", | 1110 | snprintf(buf, sizeof buf, "/%s", |
1101 | dircache[tc.dircursor+tc.dirstart].name); | 1111 | dircache[tc.dircursor+tc.dirstart].name); |
1102 | if (!id3db) | 1112 | if (id3db) |
1113 | switch (tc.currtable) | ||
1114 | { | ||
1115 | case allsongs: | ||
1116 | case songs4album: | ||
1117 | case songs4artist: | ||
1118 | case searchsongs: | ||
1119 | attr=TREE_ATTR_MPA; | ||
1120 | break; | ||
1121 | } | ||
1122 | else | ||
1103 | attr = dircache[tc.dircursor+tc.dirstart].attr; | 1123 | attr = dircache[tc.dircursor+tc.dirstart].attr; |
1104 | onplay_result = onplay(buf, attr); | 1124 | onplay_result = onplay(buf, attr, curr_context); |
1105 | } | 1125 | } |
1106 | 1126 | ||
1107 | switch (onplay_result) | 1127 | switch (onplay_result) |
diff --git a/apps/wps.c b/apps/wps.c index 3934f2483f..d6b068cd58 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include "bookmark.h" | 50 | #include "bookmark.h" |
51 | #include "misc.h" | 51 | #include "misc.h" |
52 | #include "sound.h" | 52 | #include "sound.h" |
53 | #include "onplay.h" | ||
53 | 54 | ||
54 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ | 55 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ |
55 | /* 3% of 30min file == 54s step size */ | 56 | /* 3% of 30min file == 54s step size */ |
@@ -472,6 +473,12 @@ long wps_show(void) | |||
472 | 473 | ||
473 | switch(button) | 474 | switch(button) |
474 | { | 475 | { |
476 | #ifdef WPS_CONTEXT | ||
477 | case WPS_CONTEXT: | ||
478 | onplay(id3->path, TREE_ATTR_MPA, CONTEXT_WPS); | ||
479 | restore = true; | ||
480 | break; | ||
481 | #endif | ||
475 | #ifdef WPS_RC_BROWSE | 482 | #ifdef WPS_RC_BROWSE |
476 | case WPS_RC_BROWSE: | 483 | case WPS_RC_BROWSE: |
477 | #endif | 484 | #endif |
@@ -503,6 +510,14 @@ long wps_show(void) | |||
503 | #ifdef WPS_RC_PAUSE | 510 | #ifdef WPS_RC_PAUSE |
504 | case WPS_RC_PAUSE: | 511 | case WPS_RC_PAUSE: |
505 | #endif | 512 | #endif |
513 | #ifdef WPS_PAUSE_PRE | ||
514 | if ((lastbutton != WPS_PAUSE_PRE) | ||
515 | #ifdef WPS_RC_PAUSE_PRE | ||
516 | && (lastbutton != WPS_RC_PAUSE_PRE) | ||
517 | #endif | ||
518 | ) | ||
519 | break; | ||
520 | #endif | ||
506 | if ( paused ) | 521 | if ( paused ) |
507 | { | 522 | { |
508 | paused = false; | 523 | paused = false; |
diff --git a/apps/wps.h b/apps/wps.h index 2a1826aaa8..2af2c72ef3 100644 --- a/apps/wps.h +++ b/apps/wps.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #define WPS_BROWSE_PRE BUTTON_SELECT | 38 | #define WPS_BROWSE_PRE BUTTON_SELECT |
39 | #define WPS_EXIT BUTTON_OFF | 39 | #define WPS_EXIT BUTTON_OFF |
40 | #define WPS_ID3 (BUTTON_MODE | BUTTON_ON) | 40 | #define WPS_ID3 (BUTTON_MODE | BUTTON_ON) |
41 | #define WPS_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT) | ||
41 | 42 | ||
42 | #define WPS_RC_NEXT BUTTON_RC_FF | 43 | #define WPS_RC_NEXT BUTTON_RC_FF |
43 | #define WPS_RC_PREV BUTTON_RC_REW | 44 | #define WPS_RC_PREV BUTTON_RC_REW |
@@ -59,7 +60,8 @@ | |||
59 | #define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT) | 60 | #define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT) |
60 | #define WPS_INCVOL BUTTON_UP | 61 | #define WPS_INCVOL BUTTON_UP |
61 | #define WPS_DECVOL BUTTON_DOWN | 62 | #define WPS_DECVOL BUTTON_DOWN |
62 | #define WPS_PAUSE BUTTON_PLAY | 63 | #define WPS_PAUSE_PRE BUTTON_PLAY |
64 | #define WPS_PAUSE (BUTTON_PLAY | BUTTON_REL) | ||
63 | #define WPS_MENU (BUTTON_F1 | BUTTON_REL) | 65 | #define WPS_MENU (BUTTON_F1 | BUTTON_REL) |
64 | #define WPS_MENU_PRE BUTTON_F1 | 66 | #define WPS_MENU_PRE BUTTON_F1 |
65 | #define WPS_BROWSE (BUTTON_ON | BUTTON_REL) | 67 | #define WPS_BROWSE (BUTTON_ON | BUTTON_REL) |
@@ -67,6 +69,7 @@ | |||
67 | #define WPS_EXIT BUTTON_OFF | 69 | #define WPS_EXIT BUTTON_OFF |
68 | #define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN) | 70 | #define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN) |
69 | #define WPS_ID3 (BUTTON_F1 | BUTTON_ON) | 71 | #define WPS_ID3 (BUTTON_F1 | BUTTON_ON) |
72 | #define WPS_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT) | ||
70 | 73 | ||
71 | #define WPS_RC_NEXT BUTTON_RC_RIGHT | 74 | #define WPS_RC_NEXT BUTTON_RC_RIGHT |
72 | #define WPS_RC_PREV BUTTON_RC_LEFT | 75 | #define WPS_RC_PREV BUTTON_RC_LEFT |
@@ -84,7 +87,8 @@ | |||
84 | #define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT) | 87 | #define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT) |
85 | #define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT) | 88 | #define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT) |
86 | #define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT) | 89 | #define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT) |
87 | #define WPS_PAUSE BUTTON_PLAY | 90 | #define WPS_PAUSE_PRE BUTTON_PLAY |
91 | #define WPS_PAUSE (BUTTON_PLAY | BUTTON_REL) | ||
88 | #define WPS_MENU (BUTTON_MENU | BUTTON_REL) | 92 | #define WPS_MENU (BUTTON_MENU | BUTTON_REL) |
89 | #define WPS_MENU_PRE BUTTON_MENU | 93 | #define WPS_MENU_PRE BUTTON_MENU |
90 | #define WPS_BROWSE (BUTTON_ON | BUTTON_REL) | 94 | #define WPS_BROWSE (BUTTON_ON | BUTTON_REL) |
@@ -92,6 +96,7 @@ | |||
92 | #define WPS_EXIT BUTTON_STOP | 96 | #define WPS_EXIT BUTTON_STOP |
93 | #define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP) | 97 | #define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP) |
94 | #define WPS_ID3 (BUTTON_MENU | BUTTON_ON) | 98 | #define WPS_ID3 (BUTTON_MENU | BUTTON_ON) |
99 | #define WPS_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT) | ||
95 | 100 | ||
96 | #define WPS_RC_NEXT BUTTON_RC_RIGHT | 101 | #define WPS_RC_NEXT BUTTON_RC_RIGHT |
97 | #define WPS_RC_PREV BUTTON_RC_LEFT | 102 | #define WPS_RC_PREV BUTTON_RC_LEFT |