summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-10-04 10:34:38 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-10-04 10:34:38 +0000
commitefbcece07b3a91f4b475559997f892e24751f0e6 (patch)
treec7ee12626dbd268df4a94bd46b29f6fc7126d2d4
parentae75c6eb0ae9c75173ab1b06a26cad30fc5344c9 (diff)
downloadrockbox-efbcece07b3a91f4b475559997f892e24751f0e6.tar.gz
rockbox-efbcece07b3a91f4b475559997f892e24751f0e6.zip
New setting to control the file browser start location.
Set using the menu item in folder context menus, clear in the filebrowser settings. Can be abused to start selecting a *file* (or have a folder selected) instead of a starting inside a folder by removing the trailing / in the .cfg This only affects the file browser when it would open in / before (on boot, or when entereing after backing out of the browser before (*not* when exited with the menu action) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28206 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/menus/recording_menu.c1
-rw-r--r--apps/menus/settings_menu.c12
-rw-r--r--apps/onplay.c15
-rw-r--r--apps/root_menu.c11
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_list.c1
-rw-r--r--apps/tree.c3
8 files changed, 65 insertions, 7 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 653a0be3ed..3074ab3baf 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12619,3 +12619,31 @@
*: "Update on Stop"
</voice>
</phrase>
+<phrase>
+ id: LANG_SET_AS_START_DIR
+ desc: used in the onplay menu to set a starting browser dir
+ user: core
+ <source>
+ *: "Start File Browser Here"
+ </source>
+ <dest>
+ *: "Start File Browser Here"
+ </dest>
+ <voice>
+ *: "Start File Browser Here"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_RESET_START_DIR
+ desc: reset the browser start directory
+ user: core
+ <source>
+ *: "Start File Browser at /"
+ </source>
+ <dest>
+ *: "Start File Browser at /"
+ </dest>
+ <voice>
+ *: "Start File Browser at root"
+ </voice>
+</phrase>
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index daea1ea8fc..6a1c1d31e8 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -344,6 +344,7 @@ MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
static int clear_rec_directory(void)
{
strcpy(global_settings.rec_directory, REC_BASE_DIR);
+ settings_save();
splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
return false;
}
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index b49a8a813d..5de3a305f9 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -103,6 +103,15 @@ MENUITEM_SETTING(browse_current, &global_settings.browse_current, NULL);
#ifdef HAVE_LCD_BITMAP
MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
#endif
+static int clear_start_directory(void)
+{
+ strcpy(global_settings.start_directory, "/");
+ settings_save();
+ splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
+ return false;
+}
+MENUITEM_FUNCTION(clear_start_directory_item, 0, ID2P(LANG_RESET_START_DIR),
+ clear_start_directory, NULL, NULL, Icon_file_view_menu);
static int fileview_callback(int action,const struct menu_item_ex *this_item)
{
static int oldval;
@@ -124,8 +133,9 @@ MAKE_MENU(file_menu, ID2P(LANG_FILE), 0, Icon_file_view_menu,
&sort_case, &sort_dir, &sort_file, &interpret_numbers,
&dirfilter, &show_filename_ext, &browse_current,
#ifdef HAVE_LCD_BITMAP
- &show_path_in_browser
+ &show_path_in_browser,
#endif
+ &clear_start_directory_item
);
/* FILE VIEW MENU */
/***********************************/
diff --git a/apps/onplay.c b/apps/onplay.c
index 92864f5f16..1d59b34aa4 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1045,6 +1045,16 @@ static bool set_recdir(void)
MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR),
set_recdir, NULL, clipboard_callback, Icon_Recording);
#endif
+static bool set_startdir(void)
+{
+ snprintf(global_settings.start_directory,
+ sizeof(global_settings.start_directory),
+ "%s/", selected_file);
+ settings_save();
+ return false;
+}
+MENUITEM_FUNCTION(set_startdir_item, 0, ID2P(LANG_SET_AS_START_DIR),
+ set_startdir, NULL, clipboard_callback, Icon_file_view_menu);
static int clipboard_callback(int action,const struct menu_item_ex *this_item)
{
@@ -1097,7 +1107,8 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
else if ((selected_file_attr & ATTR_DIRECTORY))
{
/* only for directories */
- if (this_item == &delete_dir_item
+ if (this_item == &delete_dir_item ||
+ this_item == &set_startdir_item
#ifdef HAVE_RECORDING
|| this_item == &set_recdir_item
#endif
@@ -1162,7 +1173,7 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
#ifdef HAVE_RECORDING
&set_recdir_item,
#endif
- &add_to_faves_item,
+ &set_startdir_item, &add_to_faves_item,
);
static int onplaymenu_callback(int action,const struct menu_item_ex *this_item)
{
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 0f2e38e395..92e0c66ff6 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -115,6 +115,10 @@ static int browser(void* param)
{
strcpy(folder, current_track_path);
}
+ else if (!strcmp(last_folder, "/"))
+ {
+ strcpy(folder, global_settings.start_directory);
+ }
else
{
#ifdef HAVE_HOTSWAP
@@ -142,9 +146,9 @@ static int browser(void* param)
break;
}
}
- if (!in_hotswap)
+ if (!in_hotswap)
#endif
- strcpy(folder, last_folder);
+ strcpy(folder, last_folder);
}
break;
#ifdef HAVE_TAGCACHE
@@ -252,7 +256,8 @@ static int browser(void* param)
switch ((intptr_t)param)
{
case GO_TO_FILEBROWSER:
- if (!get_current_file(last_folder, MAX_PATH))
+ if (!get_current_file(last_folder, MAX_PATH) ||
+ !strchr(&last_folder[1], '/'))
{
last_folder[0] = '/';
last_folder[1] = '\0';
diff --git a/apps/settings.h b/apps/settings.h
index 443369b77e..20aee18885 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -810,6 +810,7 @@ struct user_settings
#endif
} hw_eq_bands[AUDIOHW_EQ_BAND_NUM];
#endif /* AUDIOHW_HAVE_EQ */
+ char start_directory[2*MAX_FILENAME+1];
};
/** global variables **/
diff --git a/apps/settings_list.c b/apps/settings_list.c
index a8c3c36651..756d58e88f 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -958,6 +958,7 @@ const struct settings_list settings[] = {
UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown),
#endif /* HAVE_DISK_STORAGE */
/* browser */
+ TEXT_SETTING(0, start_directory, "start directory", "/", NULL, NULL),
CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files",
"all,supported,music,playlists", NULL, 4, ID2P(LANG_ALL),
ID2P(LANG_FILTER_SUPPORTED), ID2P(LANG_FILTER_MUSIC),
diff --git a/apps/tree.c b/apps/tree.c
index 730c59f611..01a00d1f40 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -545,7 +545,8 @@ char* get_current_file(char* buffer, size_t buffer_len)
{
if (tc.dirlength)
{
- strlcat(buffer, "/", buffer_len);
+ if (buffer[strlen(buffer)-1] != '/')
+ strlcat(buffer, "/", buffer_len);
if (strlcat(buffer, e->name, buffer_len) >= buffer_len)
return NULL;
}