summaryrefslogtreecommitdiff
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 @@
12619 *: "Update on Stop" 12619 *: "Update on Stop"
12620 </voice> 12620 </voice>
12621</phrase> 12621</phrase>
12622<phrase>
12623 id: LANG_SET_AS_START_DIR
12624 desc: used in the onplay menu to set a starting browser dir
12625 user: core
12626 <source>
12627 *: "Start File Browser Here"
12628 </source>
12629 <dest>
12630 *: "Start File Browser Here"
12631 </dest>
12632 <voice>
12633 *: "Start File Browser Here"
12634 </voice>
12635</phrase>
12636<phrase>
12637 id: LANG_RESET_START_DIR
12638 desc: reset the browser start directory
12639 user: core
12640 <source>
12641 *: "Start File Browser at /"
12642 </source>
12643 <dest>
12644 *: "Start File Browser at /"
12645 </dest>
12646 <voice>
12647 *: "Start File Browser at root"
12648 </voice>
12649</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);
344static int clear_rec_directory(void) 344static int clear_rec_directory(void)
345{ 345{
346 strcpy(global_settings.rec_directory, REC_BASE_DIR); 346 strcpy(global_settings.rec_directory, REC_BASE_DIR);
347 settings_save();
347 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); 348 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
348 return false; 349 return false;
349} 350}
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);
103#ifdef HAVE_LCD_BITMAP 103#ifdef HAVE_LCD_BITMAP
104MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL); 104MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
105#endif 105#endif
106static int clear_start_directory(void)
107{
108 strcpy(global_settings.start_directory, "/");
109 settings_save();
110 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
111 return false;
112}
113MENUITEM_FUNCTION(clear_start_directory_item, 0, ID2P(LANG_RESET_START_DIR),
114 clear_start_directory, NULL, NULL, Icon_file_view_menu);
106static int fileview_callback(int action,const struct menu_item_ex *this_item) 115static int fileview_callback(int action,const struct menu_item_ex *this_item)
107{ 116{
108 static int oldval; 117 static int oldval;
@@ -124,8 +133,9 @@ MAKE_MENU(file_menu, ID2P(LANG_FILE), 0, Icon_file_view_menu,
124 &sort_case, &sort_dir, &sort_file, &interpret_numbers, 133 &sort_case, &sort_dir, &sort_file, &interpret_numbers,
125 &dirfilter, &show_filename_ext, &browse_current, 134 &dirfilter, &show_filename_ext, &browse_current,
126#ifdef HAVE_LCD_BITMAP 135#ifdef HAVE_LCD_BITMAP
127 &show_path_in_browser 136 &show_path_in_browser,
128#endif 137#endif
138 &clear_start_directory_item
129 ); 139 );
130/* FILE VIEW MENU */ 140/* FILE VIEW MENU */
131/***********************************/ 141/***********************************/
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)
1045MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR), 1045MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR),
1046 set_recdir, NULL, clipboard_callback, Icon_Recording); 1046 set_recdir, NULL, clipboard_callback, Icon_Recording);
1047#endif 1047#endif
1048static bool set_startdir(void)
1049{
1050 snprintf(global_settings.start_directory,
1051 sizeof(global_settings.start_directory),
1052 "%s/", selected_file);
1053 settings_save();
1054 return false;
1055}
1056MENUITEM_FUNCTION(set_startdir_item, 0, ID2P(LANG_SET_AS_START_DIR),
1057 set_startdir, NULL, clipboard_callback, Icon_file_view_menu);
1048 1058
1049static int clipboard_callback(int action,const struct menu_item_ex *this_item) 1059static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1050{ 1060{
@@ -1097,7 +1107,8 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1097 else if ((selected_file_attr & ATTR_DIRECTORY)) 1107 else if ((selected_file_attr & ATTR_DIRECTORY))
1098 { 1108 {
1099 /* only for directories */ 1109 /* only for directories */
1100 if (this_item == &delete_dir_item 1110 if (this_item == &delete_dir_item ||
1111 this_item == &set_startdir_item
1101#ifdef HAVE_RECORDING 1112#ifdef HAVE_RECORDING
1102 || this_item == &set_recdir_item 1113 || this_item == &set_recdir_item
1103#endif 1114#endif
@@ -1162,7 +1173,7 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
1162#ifdef HAVE_RECORDING 1173#ifdef HAVE_RECORDING
1163 &set_recdir_item, 1174 &set_recdir_item,
1164#endif 1175#endif
1165 &add_to_faves_item, 1176 &set_startdir_item, &add_to_faves_item,
1166 ); 1177 );
1167static int onplaymenu_callback(int action,const struct menu_item_ex *this_item) 1178static int onplaymenu_callback(int action,const struct menu_item_ex *this_item)
1168{ 1179{
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)
115 { 115 {
116 strcpy(folder, current_track_path); 116 strcpy(folder, current_track_path);
117 } 117 }
118 else if (!strcmp(last_folder, "/"))
119 {
120 strcpy(folder, global_settings.start_directory);
121 }
118 else 122 else
119 { 123 {
120#ifdef HAVE_HOTSWAP 124#ifdef HAVE_HOTSWAP
@@ -142,9 +146,9 @@ static int browser(void* param)
142 break; 146 break;
143 } 147 }
144 } 148 }
145 if (!in_hotswap) 149 if (!in_hotswap)
146#endif 150#endif
147 strcpy(folder, last_folder); 151 strcpy(folder, last_folder);
148 } 152 }
149 break; 153 break;
150#ifdef HAVE_TAGCACHE 154#ifdef HAVE_TAGCACHE
@@ -252,7 +256,8 @@ static int browser(void* param)
252 switch ((intptr_t)param) 256 switch ((intptr_t)param)
253 { 257 {
254 case GO_TO_FILEBROWSER: 258 case GO_TO_FILEBROWSER:
255 if (!get_current_file(last_folder, MAX_PATH)) 259 if (!get_current_file(last_folder, MAX_PATH) ||
260 !strchr(&last_folder[1], '/'))
256 { 261 {
257 last_folder[0] = '/'; 262 last_folder[0] = '/';
258 last_folder[1] = '\0'; 263 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
810#endif 810#endif
811 } hw_eq_bands[AUDIOHW_EQ_BAND_NUM]; 811 } hw_eq_bands[AUDIOHW_EQ_BAND_NUM];
812#endif /* AUDIOHW_HAVE_EQ */ 812#endif /* AUDIOHW_HAVE_EQ */
813 char start_directory[2*MAX_FILENAME+1];
813}; 814};
814 815
815/** global variables **/ 816/** 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[] = {
958 UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown), 958 UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown),
959#endif /* HAVE_DISK_STORAGE */ 959#endif /* HAVE_DISK_STORAGE */
960 /* browser */ 960 /* browser */
961 TEXT_SETTING(0, start_directory, "start directory", "/", NULL, NULL),
961 CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files", 962 CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files",
962 "all,supported,music,playlists", NULL, 4, ID2P(LANG_ALL), 963 "all,supported,music,playlists", NULL, 4, ID2P(LANG_ALL),
963 ID2P(LANG_FILTER_SUPPORTED), ID2P(LANG_FILTER_MUSIC), 964 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)
545 { 545 {
546 if (tc.dirlength) 546 if (tc.dirlength)
547 { 547 {
548 strlcat(buffer, "/", buffer_len); 548 if (buffer[strlen(buffer)-1] != '/')
549 strlcat(buffer, "/", buffer_len);
549 if (strlcat(buffer, e->name, buffer_len) >= buffer_len) 550 if (strlcat(buffer, e->name, buffer_len) >= buffer_len)
550 return NULL; 551 return NULL;
551 } 552 }