diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tree.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/apps/tree.c b/apps/tree.c index 97ddfbb44d..8889b160e8 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -923,6 +923,7 @@ int rockbox_browse(const char *root, int dirfilter) | |||
923 | static struct tree_context backup; | 923 | static struct tree_context backup; |
924 | char current[MAX_PATH]; | 924 | char current[MAX_PATH]; |
925 | int last_context; | 925 | int last_context; |
926 | const char *dir, *ext, *setting; | ||
926 | 927 | ||
927 | backup = tc; | 928 | backup = tc; |
928 | tc.selected_item = 0; | 929 | tc.selected_item = 0; |
@@ -930,61 +931,62 @@ int rockbox_browse(const char *root, int dirfilter) | |||
930 | memcpy(tc.currdir, root, sizeof(tc.currdir)); | 931 | memcpy(tc.currdir, root, sizeof(tc.currdir)); |
931 | start_wps = false; | 932 | start_wps = false; |
932 | last_context = curr_context; | 933 | last_context = curr_context; |
933 | 934 | ||
934 | /* Center on the currently loaded language when browsing languages. */ | 935 | /* if we are in a special settings folder, center the current setting */ |
935 | if (dirfilter == SHOW_LNG) | 936 | switch(dirfilter) |
936 | { | ||
937 | if (global_settings.lang_file[0]) | ||
938 | { | ||
939 | snprintf(current, sizeof(current), LANG_DIR "/%s.lng", | ||
940 | global_settings.lang_file); | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | strlcpy(current, LANG_DIR "/english.lng", sizeof(current)); | ||
945 | } | ||
946 | } | ||
947 | /* Center on currently loaded WPS */ | ||
948 | else if (dirfilter == SHOW_WPS) | ||
949 | { | 937 | { |
950 | snprintf(current, sizeof(current), WPS_DIR "/%s.wps", | 938 | case SHOW_LNG: |
951 | global_settings.wps_file); | 939 | dir = LANG_DIR; |
952 | } | 940 | ext = "lng"; |
941 | if (global_settings.lang_file[0]) | ||
942 | setting = global_settings.lang_file; | ||
943 | else | ||
944 | setting = "english"; | ||
945 | break; | ||
946 | case SHOW_WPS: | ||
947 | dir = WPS_DIR; | ||
948 | ext = "wps"; | ||
949 | setting = global_settings.wps_file; | ||
950 | break; | ||
953 | #ifdef HAVE_REMOTE_LCD | 951 | #ifdef HAVE_REMOTE_LCD |
954 | /* Center on currently loaded RWPS */ | 952 | case SHOW_RWPS: |
955 | else if (dirfilter == SHOW_RWPS) | 953 | dir = WPS_DIR; |
956 | { | 954 | ext = "rwps"; |
957 | snprintf(current, sizeof(current), WPS_DIR "/%s.rwps", | 955 | setting = global_settings.rwps_file; |
958 | global_settings.rwps_file); | 956 | break; |
959 | } | 957 | case SHOW_RSBS: |
960 | else if (dirfilter == SHOW_RSBS) | 958 | dir = WPS_DIR; |
961 | { | 959 | ext = "rsbs"; |
962 | snprintf(current, sizeof(current), SBS_DIR "/%s.rsbs", | 960 | setting = global_settings.rsbs_file; |
963 | global_settings.rsbs_file); | 961 | break; |
964 | } | ||
965 | #endif | 962 | #endif |
966 | #ifdef HAVE_LCD_BITMAP | 963 | #ifdef HAVE_LCD_BITMAP |
967 | /* Center on the currently loaded font when browsing fonts */ | 964 | case SHOW_FONT: |
968 | else if (dirfilter == SHOW_FONT) | 965 | dir = FONT_DIR; |
969 | { | 966 | ext = "fnt"; |
970 | snprintf(current, sizeof(current), FONT_DIR "/%s.fnt", | 967 | setting = global_settings.font_file; |
971 | global_settings.font_file); | 968 | break; |
972 | } | 969 | case SHOW_SBS: |
973 | else if (dirfilter == SHOW_SBS) | 970 | dir = WPS_DIR; |
974 | { | 971 | ext = "sbs"; |
975 | snprintf(current, sizeof(current), SBS_DIR "/%s.sbs", | 972 | setting = global_settings.sbs_file; |
976 | global_settings.sbs_file); | 973 | break; |
977 | } | ||
978 | #endif | 974 | #endif |
979 | #if CONFIG_TUNER | 975 | #if CONFIG_TUNER |
980 | /* Center on the currently loaded FM preset when browsing those */ | 976 | case SHOW_FMR: |
981 | else if (dirfilter == SHOW_FMR) | 977 | dir = FMPRESET_PATH; |
982 | { | 978 | ext = "fmr"; |
983 | snprintf(current, sizeof(current), FMPRESET_PATH "/%s.fmr", | 979 | setting = global_settings.fmr_file; |
984 | global_settings.fmr_file); | 980 | break; |
985 | } | ||
986 | #endif | 981 | #endif |
987 | else /* reset current[] */ | 982 | default: |
983 | dir = ext = setting = NULL; | ||
984 | break; | ||
985 | } | ||
986 | |||
987 | if (setting) | ||
988 | snprintf(current, sizeof(current), "%s/%s.%s", dir, setting, ext); | ||
989 | else /* reset current, the next call might use the old value */ | ||
988 | current[0] = '\0'; | 990 | current[0] = '\0'; |
989 | 991 | ||
990 | /* If we've found a file to center on, do it */ | 992 | /* If we've found a file to center on, do it */ |