diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2019-07-28 14:36:12 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2019-08-01 15:17:40 +0200 |
commit | c3a775c05b70ea538076c3f02909137e9474c52e (patch) | |
tree | f1c430c12485e6fb0145a0d8fdb72c314d7f0a66 | |
parent | 722ddcf6ba35b5b06ae42b399140056ca67ad7ed (diff) | |
download | rockbox-c3a775c05b70ea538076c3f02909137e9474c52e.tar.gz rockbox-c3a775c05b70ea538076c3f02909137e9474c52e.zip |
Make info screen properly multi-volume aware.
It will now display a line for every volume that's backed by a real drive.
Change-Id: I8fec9018729fc1b0d4f4322cd4421ce7fa945e75
-rw-r--r-- | apps/lang/english.lang | 9 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 165 |
2 files changed, 76 insertions, 98 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index fd2e4511cd..43a3ddabe5 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -6674,16 +6674,13 @@ | |||
6674 | desc: in info menu; name for internal disk with multivolume (keep short!) | 6674 | desc: in info menu; name for internal disk with multivolume (keep short!) |
6675 | user: core | 6675 | user: core |
6676 | <source> | 6676 | <source> |
6677 | *: none | 6677 | *: "Int:" |
6678 | multivolume: "Int:" | ||
6679 | </source> | 6678 | </source> |
6680 | <dest> | 6679 | <dest> |
6681 | *: none | 6680 | *: "Int:" |
6682 | multivolume: "Int:" | ||
6683 | </dest> | 6681 | </dest> |
6684 | <voice> | 6682 | <voice> |
6685 | *: none | 6683 | *: "Internal" |
6686 | multivolume: "Internal" | ||
6687 | </voice> | 6684 | </voice> |
6688 | </phrase> | 6685 | </phrase> |
6689 | <phrase> | 6686 | <phrase> |
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index c1dd364481..6e63951319 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -90,13 +90,13 @@ static int write_settings_file(void* param) | |||
90 | return settings_save_config((intptr_t)param); | 90 | return settings_save_config((intptr_t)param); |
91 | } | 91 | } |
92 | 92 | ||
93 | MENUITEM_FUNCTION(browse_configs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG), | 93 | MENUITEM_FUNCTION(browse_configs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG), |
94 | browse_folder, (void*)&config, NULL, Icon_NOICON); | 94 | browse_folder, (void*)&config, NULL, Icon_NOICON); |
95 | MENUITEM_FUNCTION(save_settings_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SETTINGS), | 95 | MENUITEM_FUNCTION(save_settings_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SETTINGS), |
96 | write_settings_file, (void*)SETTINGS_SAVE_ALL, NULL, Icon_NOICON); | 96 | write_settings_file, (void*)SETTINGS_SAVE_ALL, NULL, Icon_NOICON); |
97 | MENUITEM_FUNCTION(save_theme_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_THEME), | 97 | MENUITEM_FUNCTION(save_theme_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_THEME), |
98 | write_settings_file, (void*)SETTINGS_SAVE_THEME, NULL, Icon_NOICON); | 98 | write_settings_file, (void*)SETTINGS_SAVE_THEME, NULL, Icon_NOICON); |
99 | MENUITEM_FUNCTION(save_sound_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SOUND), | 99 | MENUITEM_FUNCTION(save_sound_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SOUND), |
100 | write_settings_file, (void*)SETTINGS_SAVE_SOUND, NULL, Icon_NOICON); | 100 | write_settings_file, (void*)SETTINGS_SAVE_SOUND, NULL, Icon_NOICON); |
101 | MENUITEM_FUNCTION(reset_settings_item, 0, ID2P(LANG_RESET), | 101 | MENUITEM_FUNCTION(reset_settings_item, 0, ID2P(LANG_RESET), |
102 | reset_settings, NULL, NULL, Icon_NOICON); | 102 | reset_settings, NULL, NULL, Icon_NOICON); |
@@ -130,22 +130,17 @@ static int show_credits(void) | |||
130 | #else | 130 | #else |
131 | #define SIZE_FMT "%s %s" | 131 | #define SIZE_FMT "%s %s" |
132 | #endif | 132 | #endif |
133 | struct info_data | 133 | struct info_data |
134 | 134 | ||
135 | { | 135 | { |
136 | unsigned long size[NUM_VOLUMES]; | ||
137 | unsigned long free[NUM_VOLUMES]; | ||
138 | unsigned long name[NUM_VOLUMES]; | ||
136 | bool new_data; | 139 | bool new_data; |
137 | unsigned long size; | ||
138 | unsigned long free; | ||
139 | #ifdef HAVE_MULTIVOLUME | ||
140 | unsigned long size2; | ||
141 | unsigned long free2; | ||
142 | #endif | ||
143 | }; | 140 | }; |
144 | enum infoscreenorder | 141 | enum infoscreenorder |
145 | { | 142 | { |
146 | INFO_BATTERY = 0, | 143 | INFO_BATTERY = 0, |
147 | INFO_DISK1, /* capacity or internal capacity/free on hotswap */ | ||
148 | INFO_DISK2, /* free space or external capacity/free on hotswap */ | ||
149 | INFO_BUFFER, | 144 | INFO_BUFFER, |
150 | #ifdef HAVE_RECORDING | 145 | #ifdef HAVE_RECORDING |
151 | INFO_REC_DIR, | 146 | INFO_REC_DIR, |
@@ -155,9 +150,42 @@ enum infoscreenorder | |||
155 | INFO_DATE, | 150 | INFO_DATE, |
156 | INFO_TIME, | 151 | INFO_TIME, |
157 | #endif | 152 | #endif |
153 | INFO_DISK1, /* capacity/free on internal */ | ||
158 | INFO_COUNT | 154 | INFO_COUNT |
159 | }; | 155 | }; |
160 | 156 | ||
157 | /* NOTE: This code is not quite right for | ||
158 | (HAVE_MULTIVOLUME && !HAVE_MULTIDRIVE), but there are no | ||
159 | in-tree matches so.. eh. | ||
160 | */ | ||
161 | static int refresh_data(struct info_data *info) | ||
162 | { | ||
163 | int i; | ||
164 | #ifdef HAVE_MULTIDRIVE | ||
165 | int drive; | ||
166 | int max = -1; | ||
167 | #endif | ||
168 | |||
169 | for (i = 0 ; CHECK_VOL(i) ; i++) { | ||
170 | volume_size(IF_MV(i,) &info->size[i], &info->free[i]); | ||
171 | #ifdef HAVE_MULTIDRIVE | ||
172 | drive = volume_drive(i); | ||
173 | if (drive > 0 || info->size[i] == 0) | ||
174 | info->name[i] = LANG_DISK_NAME_MMC; | ||
175 | else | ||
176 | #endif | ||
177 | info->name[i] = LANG_DISK_NAME_INTERNAL; | ||
178 | #ifdef HAVE_MULTIDRIVE | ||
179 | if (drive > max) | ||
180 | max = drive; | ||
181 | else if (drive < max) | ||
182 | break; | ||
183 | #endif | ||
184 | } | ||
185 | info->new_data = false; | ||
186 | return i; | ||
187 | } | ||
188 | |||
161 | static const char* info_getname(int selected_item, void *data, | 189 | static const char* info_getname(int selected_item, void *data, |
162 | char *buffer, size_t buffer_len) | 190 | char *buffer, size_t buffer_len) |
163 | { | 191 | { |
@@ -166,26 +194,16 @@ static const char* info_getname(int selected_item, void *data, | |||
166 | struct tm *tm; | 194 | struct tm *tm; |
167 | #endif | 195 | #endif |
168 | char s1[32]; | 196 | char s1[32]; |
169 | #if defined(HAVE_MULTIVOLUME) | ||
170 | char s2[32]; | 197 | char s2[32]; |
171 | #endif | 198 | int i; |
199 | |||
172 | if (info->new_data) | 200 | if (info->new_data) |
173 | { | 201 | refresh_data(info); |
174 | volume_size(IF_MV(0,) &info->size, &info->free); | ||
175 | #ifdef HAVE_MULTIVOLUME | ||
176 | #ifndef APPLICATION | ||
177 | volume_size(1, &info->size2, &info->free2); | ||
178 | #else | ||
179 | info->size2 = 0; | ||
180 | #endif | ||
181 | 202 | ||
182 | #endif | ||
183 | info->new_data = false; | ||
184 | } | ||
185 | switch (selected_item) | 203 | switch (selected_item) |
186 | { | 204 | { |
187 | case INFO_VERSION: | 205 | case INFO_VERSION: |
188 | snprintf(buffer, buffer_len, "%s: %s", | 206 | snprintf(buffer, buffer_len, "%s: %s", |
189 | str(LANG_VERSION), rbversion); | 207 | str(LANG_VERSION), rbversion); |
190 | break; | 208 | break; |
191 | 209 | ||
@@ -265,35 +283,20 @@ static const char* info_getname(int selected_item, void *data, | |||
265 | else | 283 | else |
266 | return "Battery n/a"; /* translating worth it? */ | 284 | return "Battery n/a"; /* translating worth it? */ |
267 | break; | 285 | break; |
268 | case INFO_DISK1: /* disk usage 1 */ | 286 | case INFO_DISK1: /* disk usage for internal */ |
287 | default: | ||
288 | i = selected_item - INFO_DISK1; | ||
289 | if (info->size[i]) { | ||
290 | output_dyn_value(s1, sizeof s1, info->free[i], kibyte_units, 3, true); | ||
291 | output_dyn_value(s2, sizeof s2, info->size[i], kibyte_units, 3, true); | ||
292 | snprintf(buffer, buffer_len, "%s %s/%s", str(info->name[i]), | ||
293 | s1, s2); | ||
269 | #ifdef HAVE_MULTIVOLUME | 294 | #ifdef HAVE_MULTIVOLUME |
270 | output_dyn_value(s1, sizeof s1, info->free, kibyte_units, 3, true); | 295 | } else { |
271 | output_dyn_value(s2, sizeof s2, info->size, kibyte_units, 3, true); | 296 | snprintf(buffer, buffer_len, "%s %s", str(info->name[i]), |
272 | snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL), | 297 | str(LANG_NOT_PRESENT)); |
273 | s1, s2); | ||
274 | #else | ||
275 | output_dyn_value(s1, sizeof s1, info->free, kibyte_units, 3, true); | ||
276 | snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1); | ||
277 | #endif | ||
278 | break; | ||
279 | case INFO_DISK2: /* disk usage 2 */ | ||
280 | #ifdef HAVE_MULTIVOLUME | ||
281 | if (info->size2) | ||
282 | { | ||
283 | output_dyn_value(s1, sizeof s1, info->free2, kibyte_units, 3, true); | ||
284 | output_dyn_value(s2, sizeof s2, info->size2, kibyte_units, 3, true); | ||
285 | snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_MMC), | ||
286 | s1, s2); | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | snprintf(buffer, buffer_len, "%s %s", str(LANG_DISK_NAME_MMC), | ||
291 | str(LANG_NOT_PRESENT)); | ||
292 | } | ||
293 | #else | ||
294 | output_dyn_value(s1, sizeof s1, info->size, kibyte_units, 3, true); | ||
295 | snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1); | ||
296 | #endif | 298 | #endif |
299 | } | ||
297 | break; | 300 | break; |
298 | } | 301 | } |
299 | return buffer; | 302 | return buffer; |
@@ -306,20 +309,10 @@ static int info_speak_item(int selected_item, void * data) | |||
306 | #if CONFIG_RTC | 309 | #if CONFIG_RTC |
307 | struct tm *tm; | 310 | struct tm *tm; |
308 | #endif | 311 | #endif |
312 | int i; | ||
309 | 313 | ||
310 | if (info->new_data) | 314 | if (info->new_data) |
311 | { | 315 | refresh_data(info); |
312 | volume_size(IF_MV(0,) &info->size, &info->free); | ||
313 | #ifdef HAVE_DIRCACHE | ||
314 | #ifdef HAVE_MULTIVOLUME | ||
315 | if (volume_ismounted(1)) | ||
316 | volume_size(1, &info->size2, &info->free2); | ||
317 | else | ||
318 | info->size2 = 0; | ||
319 | #endif | ||
320 | #endif | ||
321 | info->new_data = false; | ||
322 | } | ||
323 | 316 | ||
324 | switch (selected_item) | 317 | switch (selected_item) |
325 | { | 318 | { |
@@ -437,33 +430,19 @@ static int info_speak_item(int selected_item, void * data) | |||
437 | else talk_id(VOICE_BLANK, false); | 430 | else talk_id(VOICE_BLANK, false); |
438 | break; | 431 | break; |
439 | case INFO_DISK1: /* disk 1 */ | 432 | case INFO_DISK1: /* disk 1 */ |
433 | default: | ||
434 | i = selected_item - INFO_DISK1; | ||
435 | if (info->size[i]) { | ||
436 | talk_ids(false, info->name[i], LANG_DISK_FREE_INFO); | ||
437 | output_dyn_value(NULL, 0, info->free[i], kibyte_units, 3, true); | ||
438 | talk_id(LANG_DISK_SIZE_INFO, true); | ||
439 | output_dyn_value(NULL, 0, info->size[i], kibyte_units, 3, true); | ||
440 | #ifdef HAVE_MULTIVOLUME | 440 | #ifdef HAVE_MULTIVOLUME |
441 | talk_ids(false, LANG_DISK_NAME_INTERNAL, LANG_DISK_FREE_INFO); | 441 | } else { |
442 | output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true); | 442 | talk_id(LANG_NOT_PRESENT, true); |
443 | talk_id(LANG_DISK_SIZE_INFO, true); | ||
444 | output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true); | ||
445 | #else | ||
446 | talk_id(LANG_DISK_FREE_INFO, false); | ||
447 | output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true); | ||
448 | #endif | ||
449 | break; | ||
450 | case INFO_DISK2: /* disk 2 */ | ||
451 | #ifdef HAVE_MULTIVOLUME | ||
452 | talk_id(LANG_DISK_NAME_MMC, false); | ||
453 | if (info->size2) | ||
454 | { | ||
455 | talk_id(LANG_DISK_FREE_INFO, true); | ||
456 | output_dyn_value(NULL, 0, info->free2, kibyte_units, 3, true); | ||
457 | talk_id(LANG_DISK_SIZE_INFO, true); | ||
458 | output_dyn_value(NULL, 0, info->size2, kibyte_units, 3, true); | ||
459 | } | ||
460 | else talk_id(LANG_NOT_PRESENT, true); | ||
461 | #else | ||
462 | talk_id(LANG_DISK_SIZE_INFO, false); | ||
463 | output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true); | ||
464 | #endif | 443 | #endif |
465 | break; | 444 | } |
466 | 445 | break; | |
467 | } | 446 | } |
468 | return 0; | 447 | return 0; |
469 | } | 448 | } |
@@ -503,11 +482,13 @@ static int info_action_callback(int action, struct gui_synclist *lists) | |||
503 | #endif | 482 | #endif |
504 | return action; | 483 | return action; |
505 | } | 484 | } |
485 | |||
506 | static int show_info(void) | 486 | static int show_info(void) |
507 | { | 487 | { |
508 | struct info_data data = {.new_data = true }; | 488 | struct info_data data = {.new_data = true }; |
509 | struct simplelist_info info; | 489 | struct simplelist_info info; |
510 | simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), INFO_COUNT, (void*)&data); | 490 | int count = INFO_COUNT + refresh_data(&data) - 1; |
491 | simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), count, (void*)&data); | ||
511 | info.hide_selection = !global_settings.talk_menu; | 492 | info.hide_selection = !global_settings.talk_menu; |
512 | if (info.hide_selection) | 493 | if (info.hide_selection) |
513 | info.scroll_all = true; | 494 | info.scroll_all = true; |