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
This commit is contained in:
parent
ae75c6eb0a
commit
efbcece07b
8 changed files with 65 additions and 7 deletions
|
@ -12619,3 +12619,31 @@
|
||||||
*: "Update on Stop"
|
*: "Update on Stop"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</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>
|
||||||
|
|
|
@ -344,6 +344,7 @@ MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
|
||||||
static int clear_rec_directory(void)
|
static int clear_rec_directory(void)
|
||||||
{
|
{
|
||||||
strcpy(global_settings.rec_directory, REC_BASE_DIR);
|
strcpy(global_settings.rec_directory, REC_BASE_DIR);
|
||||||
|
settings_save();
|
||||||
splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
|
splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,15 @@ MENUITEM_SETTING(browse_current, &global_settings.browse_current, NULL);
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
|
MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
|
||||||
#endif
|
#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 fileview_callback(int action,const struct menu_item_ex *this_item)
|
||||||
{
|
{
|
||||||
static int oldval;
|
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,
|
&sort_case, &sort_dir, &sort_file, &interpret_numbers,
|
||||||
&dirfilter, &show_filename_ext, &browse_current,
|
&dirfilter, &show_filename_ext, &browse_current,
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
&show_path_in_browser
|
&show_path_in_browser,
|
||||||
#endif
|
#endif
|
||||||
|
&clear_start_directory_item
|
||||||
);
|
);
|
||||||
/* FILE VIEW MENU */
|
/* FILE VIEW MENU */
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
|
@ -1045,6 +1045,16 @@ static bool set_recdir(void)
|
||||||
MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR),
|
MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR),
|
||||||
set_recdir, NULL, clipboard_callback, Icon_Recording);
|
set_recdir, NULL, clipboard_callback, Icon_Recording);
|
||||||
#endif
|
#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)
|
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))
|
else if ((selected_file_attr & ATTR_DIRECTORY))
|
||||||
{
|
{
|
||||||
/* only for directories */
|
/* only for directories */
|
||||||
if (this_item == &delete_dir_item
|
if (this_item == &delete_dir_item ||
|
||||||
|
this_item == &set_startdir_item
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef HAVE_RECORDING
|
||||||
|| this_item == &set_recdir_item
|
|| this_item == &set_recdir_item
|
||||||
#endif
|
#endif
|
||||||
|
@ -1162,7 +1173,7 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef HAVE_RECORDING
|
||||||
&set_recdir_item,
|
&set_recdir_item,
|
||||||
#endif
|
#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)
|
static int onplaymenu_callback(int action,const struct menu_item_ex *this_item)
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,6 +115,10 @@ static int browser(void* param)
|
||||||
{
|
{
|
||||||
strcpy(folder, current_track_path);
|
strcpy(folder, current_track_path);
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(last_folder, "/"))
|
||||||
|
{
|
||||||
|
strcpy(folder, global_settings.start_directory);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef HAVE_HOTSWAP
|
#ifdef HAVE_HOTSWAP
|
||||||
|
@ -142,9 +146,9 @@ static int browser(void* param)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!in_hotswap)
|
if (!in_hotswap)
|
||||||
#endif
|
#endif
|
||||||
strcpy(folder, last_folder);
|
strcpy(folder, last_folder);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
|
@ -252,7 +256,8 @@ static int browser(void* param)
|
||||||
switch ((intptr_t)param)
|
switch ((intptr_t)param)
|
||||||
{
|
{
|
||||||
case GO_TO_FILEBROWSER:
|
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[0] = '/';
|
||||||
last_folder[1] = '\0';
|
last_folder[1] = '\0';
|
||||||
|
|
|
@ -810,6 +810,7 @@ struct user_settings
|
||||||
#endif
|
#endif
|
||||||
} hw_eq_bands[AUDIOHW_EQ_BAND_NUM];
|
} hw_eq_bands[AUDIOHW_EQ_BAND_NUM];
|
||||||
#endif /* AUDIOHW_HAVE_EQ */
|
#endif /* AUDIOHW_HAVE_EQ */
|
||||||
|
char start_directory[2*MAX_FILENAME+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** global variables **/
|
/** global variables **/
|
||||||
|
|
|
@ -958,6 +958,7 @@ const struct settings_list settings[] = {
|
||||||
UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown),
|
UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown),
|
||||||
#endif /* HAVE_DISK_STORAGE */
|
#endif /* HAVE_DISK_STORAGE */
|
||||||
/* browser */
|
/* browser */
|
||||||
|
TEXT_SETTING(0, start_directory, "start directory", "/", NULL, NULL),
|
||||||
CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files",
|
CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files",
|
||||||
"all,supported,music,playlists", NULL, 4, ID2P(LANG_ALL),
|
"all,supported,music,playlists", NULL, 4, ID2P(LANG_ALL),
|
||||||
ID2P(LANG_FILTER_SUPPORTED), ID2P(LANG_FILTER_MUSIC),
|
ID2P(LANG_FILTER_SUPPORTED), ID2P(LANG_FILTER_MUSIC),
|
||||||
|
|
|
@ -545,7 +545,8 @@ char* get_current_file(char* buffer, size_t buffer_len)
|
||||||
{
|
{
|
||||||
if (tc.dirlength)
|
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)
|
if (strlcat(buffer, e->name, buffer_len) >= buffer_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue