summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2003-07-02 15:54:44 +0000
committerHardeep Sidhu <dyp@pobox.com>2003-07-02 15:54:44 +0000
commit11e7ad50a07c0ffcb2005e40c3314bb49a9a1d8b (patch)
tree4ff3c606a0e46d353253c3b1cb44f4170cf31e4f /apps
parent8dd3a822c7cf48ae23440697e8ba76415c441a55 (diff)
downloadrockbox-11e7ad50a07c0ffcb2005e40c3314bb49a9a1d8b.tar.gz
rockbox-11e7ad50a07c0ffcb2005e40c3314bb49a9a1d8b.tar.bz2
rockbox-11e7ad50a07c0ffcb2005e40c3314bb49a9a1d8b.zip
Added "Ask" option to recursive dir insert which, if enabled, will ask users whether they want to recursively insert selected dir. Also, renamed "Insert first" and "Queue first" to "Insert next" and "Queue next" respectively.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3799 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang9
-rw-r--r--apps/onplay.c40
-rw-r--r--apps/playlist.c14
-rw-r--r--apps/playlist.h3
-rw-r--r--apps/playlist_menu.c9
-rw-r--r--apps/settings.c20
-rw-r--r--apps/settings.h5
7 files changed, 80 insertions, 20 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index dab8fa6bd4..5360c7c21e 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1650,12 +1650,12 @@ new:
id: LANG_QUEUE_FIRST
desc: in onplay menu. queue a track/playlist into dynamic playlist.
-eng: "Queue first"
+eng: "Queue next"
new:
id: LANG_INSERT_FIRST
desc: in onplay menu. insert a track/playlist into dynamic playlist.
-eng: "Insert first"
+eng: "Insert next"
new:
id: LANG_SAVE_DYNAMIC_PLAYLIST
@@ -1722,3 +1722,8 @@ id: LANG_RECURSE_DIRECTORY
desc: In playlist menu
eng: "Recursively Insert Directories"
new:
+
+id: LANG_RECURSE_DIRECTORY_QUESTION
+desc: Asked from onplay screen
+eng: "Recursively?"
+new:
diff --git a/apps/onplay.c b/apps/onplay.c
index 6c538f8d8a..6c6b2eed0b 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -62,7 +62,45 @@ static bool add_to_playlist(int position, bool queue)
if (selected_file_attr & TREE_ATTR_MPA)
playlist_insert_track(selected_file, position, queue);
else if (selected_file_attr & ATTR_DIRECTORY)
- playlist_insert_directory(selected_file, position, queue);
+ {
+ bool recurse = false;
+
+ if (global_settings.recursive_dir_insert != RECURSE_ASK)
+ recurse = (bool)global_settings.recursive_dir_insert;
+ else
+ {
+ /* Ask if user wants to recurse directory */
+ bool exit = false;
+
+ lcd_clear_display();
+ lcd_puts_scroll(0,0,str(LANG_RECURSE_DIRECTORY_QUESTION));
+ lcd_puts_scroll(0,1,selected_file);
+
+#ifdef HAVE_LCD_BITMAP
+ lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
+ lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER));
+#endif
+
+ lcd_update();
+
+ while (!exit) {
+ int btn = button_get(true);
+ switch (btn) {
+ case BUTTON_PLAY:
+ recurse = true;
+ exit = true;
+ break;
+ default:
+ /* ignore button releases */
+ if (!(btn & BUTTON_REL))
+ exit = true;
+ break;
+ }
+ }
+ }
+
+ playlist_insert_directory(selected_file, position, queue, recurse);
+ }
else if (selected_file_attr & TREE_ATTR_M3U)
playlist_insert_playlist(selected_file, position, queue);
diff --git a/apps/playlist.c b/apps/playlist.c
index 05149d164f..b5309cdba0 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -131,7 +131,7 @@ static int add_indices_to_playlist(void);
static int add_track_to_playlist(char *filename, int position, bool queue,
int seek_pos);
static int add_directory_to_playlist(char *dirname, int *position, bool queue,
- int *count);
+ int *count, bool recurse);
static int remove_track_from_playlist(int position, bool write);
static int randomise_playlist(unsigned int seed, bool start_current,
bool write);
@@ -402,7 +402,7 @@ static int add_track_to_playlist(char *filename, int position, bool queue,
* Insert directory into playlist. May be called recursively.
*/
static int add_directory_to_playlist(char *dirname, int *position, bool queue,
- int *count)
+ int *count, bool recurse)
{
char buf[MAX_PATH+1];
char *count_str;
@@ -446,12 +446,12 @@ static int add_directory_to_playlist(char *dirname, int *position, bool queue,
if (files[i].attr & ATTR_DIRECTORY)
{
- if (global_settings.recursive_dir_insert)
+ if (recurse)
{
/* recursively add directories */
snprintf(buf, sizeof(buf), "%s/%s", dirname, files[i].name);
result = add_directory_to_playlist(buf, position, queue,
- count);
+ count, recurse);
if (result < 0)
break;
@@ -1385,7 +1385,8 @@ int playlist_insert_track(char *filename, int position, bool queue)
/*
* Insert all tracks from specified directory into playlist.
*/
-int playlist_insert_directory(char *dirname, int position, bool queue)
+int playlist_insert_directory(char *dirname, int position, bool queue,
+ bool recurse)
{
int count = 0;
int result;
@@ -1398,7 +1399,8 @@ int playlist_insert_directory(char *dirname, int position, bool queue)
display_playlist_count(count, count_str);
- result = add_directory_to_playlist(dirname, &position, queue, &count);
+ result = add_directory_to_playlist(dirname, &position, queue, &count,
+ recurse);
fsync(playlist.control_fd);
display_playlist_count(count, count_str);
diff --git a/apps/playlist.h b/apps/playlist.h
index a5318cd202..0b30e7a3e1 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -51,7 +51,8 @@ int playlist_create(char *dir, char *file);
int playlist_resume(void);
int playlist_add(char *filename);
int playlist_insert_track(char *filename, int position, bool queue);
-int playlist_insert_directory(char *dirname, int position, bool queue);
+int playlist_insert_directory(char *dirname, int position, bool queue,
+ bool recurse);
int playlist_insert_playlist(char *filename, int position, bool queue);
int playlist_delete(int index);
int playlist_shuffle(int random_seed, int start_index);
diff --git a/apps/playlist_menu.c b/apps/playlist_menu.c
index 3508240efe..4223e3cf72 100644
--- a/apps/playlist_menu.c
+++ b/apps/playlist_menu.c
@@ -49,8 +49,13 @@ static bool save_playlist(void)
static bool recurse_directory(void)
{
- return (set_bool( str(LANG_RECURSE_DIRECTORY),
- &global_settings.recursive_dir_insert));
+ char* names[] = { str(LANG_OFF),
+ str(LANG_ON),
+ str(LANG_RESUME_SETTING_ASK) };
+
+ return set_option( str(LANG_RECURSE_DIRECTORY),
+ &global_settings.recursive_dir_insert, INT, names, 3,
+ NULL );
}
bool playlist_menu(void)
diff --git a/apps/settings.c b/apps/settings.c
index e5fbfb5e06..90775edab3 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -351,7 +351,7 @@ int settings_save( void )
config_block[0x1b] = (unsigned char)
(((global_settings.browse_current & 1)) |
((global_settings.play_selected & 1) << 1) |
- ((global_settings.recursive_dir_insert & 1) << 2));
+ ((global_settings.recursive_dir_insert & 3) << 2));
config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold |
(global_settings.rec_editable?0x80:0);
@@ -646,7 +646,7 @@ void settings_load(void)
global_settings.browse_current = (config_block[0x1b]) & 1;
global_settings.play_selected = (config_block[0x1b] >> 1) & 1;
global_settings.recursive_dir_insert =
- (config_block[0x1b] >> 2) & 1;
+ (config_block[0x1b] >> 2) & 3;
}
if (config_block[0x1c] != 0xFF) {
@@ -1079,8 +1079,11 @@ bool settings_load_config(char* file)
else if (!strcasecmp(name, "max files in playlist"))
set_cfg_int(&global_settings.max_files_in_playlist, value,
1000, 20000);
- else if (!strcasecmp(name, "recursive directory insert"))
- set_cfg_bool(&global_settings.recursive_dir_insert, value);
+ else if (!strcasecmp(name, "recursive directory insert")) {
+ static char* options[] = {"off", "on", "ask"};
+ set_cfg_option(&global_settings.recursive_dir_insert, value,
+ options, 3);
+ }
}
close(fd);
@@ -1369,8 +1372,11 @@ bool settings_save_config(void)
fprintf(fd, "max files in playlist: %d\r\n",
global_settings.max_files_in_playlist);
- fprintf(fd, "recursive directory insert: %s\r\n",
- boolopt[global_settings.recursive_dir_insert]);
+ {
+ static char* options[] = {"off", "on", "ask"};
+ fprintf(fd, "recursive directory insert: %s\r\n",
+ options[global_settings.recursive_dir_insert]);
+ }
close(fd);
@@ -1459,7 +1465,7 @@ void settings_reset(void) {
global_settings.max_files_in_dir = 400;
global_settings.max_files_in_playlist = 10000;
global_settings.show_icons = true;
- global_settings.recursive_dir_insert = false;
+ global_settings.recursive_dir_insert = RECURSE_OFF;
}
bool set_bool(char* string, bool* variable )
diff --git a/apps/settings.h b/apps/settings.h
index 25efd65e9a..e3eff50448 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -166,7 +166,7 @@ struct user_settings
int max_files_in_dir; /* Max entries in directory (file browser) */
int max_files_in_playlist; /* Max entries in playlist */
bool show_icons; /* 0=hide 1=show */
- bool recursive_dir_insert;/* should directories be inserted recursively */
+ int recursive_dir_insert; /* should directories be inserted recursively */
};
enum optiontype { INT, BOOL };
@@ -223,4 +223,7 @@ enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
/* dir filter options */
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES };
+/* recursive dir insert options */
+enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
+
#endif /* __SETTINGS_H__ */