diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-06-20 21:53:47 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-06-20 21:53:47 +0000 |
commit | 298316d19297eea82869b63235b535e5904fc0dd (patch) | |
tree | 0426e9c8cecac7532a88888e78e5e54ea9bb6145 /apps/plugins/text_viewer/tv_menu.c | |
parent | 17a2f9d8d2dfddd8d2d81ff638e21302efef1c8e (diff) | |
download | rockbox-298316d19297eea82869b63235b535e5904fc0dd.tar.gz rockbox-298316d19297eea82869b63235b535e5904fc0dd.zip |
text_viewer: cleanup & bugfix
cleanup:
- don't use enum in struct / return values
- don't use a getter for preferences but a global pointer
- explicitely make enums start at 0
- use static tables for header/footer settings
- remove unneeded memset before strlcpy
- use static buffer allocation, not dynamic
- check header/footer preferences before using the callbacks
- don't include font filename in archos player preferences (break
file format)
bugfix:
- statically allocate old preferences in tv_set_preferences()
Sometimes I can read a file on Clipv2, but it still aborts quite often
refs: FS#11399
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26998 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer/tv_menu.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_menu.c | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c index ce85dc9325..c90386aabc 100644 --- a/apps/plugins/text_viewer/tv_menu.c +++ b/apps/plugins/text_viewer/tv_menu.c | |||
@@ -219,44 +219,30 @@ static bool tv_alignment_setting(void) | |||
219 | #ifdef HAVE_LCD_BITMAP | 219 | #ifdef HAVE_LCD_BITMAP |
220 | static bool tv_header_setting(void) | 220 | static bool tv_header_setting(void) |
221 | { | 221 | { |
222 | int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2; | 222 | static const struct opt_items names[4] = |
223 | struct opt_items names[len]; | ||
224 | |||
225 | names[0].string = "None"; | ||
226 | names[0].voice_id = -1; | ||
227 | names[1].string = "File path"; | ||
228 | names[1].voice_id = -1; | ||
229 | |||
230 | if (rb->global_settings->statusbar == STATUSBAR_TOP) | ||
231 | { | 223 | { |
232 | names[2].string = "Status bar"; | 224 | {"None", -1}, |
233 | names[2].voice_id = -1; | 225 | {"File path", -1}, |
234 | names[3].string = "Both"; | 226 | {"Status bar", -1}, |
235 | names[3].voice_id = -1; | 227 | {"Both", -1}, |
236 | } | 228 | }; |
237 | 229 | ||
230 | int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2; | ||
238 | return rb->set_option("Show Header", &new_prefs.header_mode, INT, | 231 | return rb->set_option("Show Header", &new_prefs.header_mode, INT, |
239 | names, len, NULL); | 232 | names, len, NULL); |
240 | } | 233 | } |
241 | 234 | ||
242 | static bool tv_footer_setting(void) | 235 | static bool tv_footer_setting(void) |
243 | { | 236 | { |
244 | int len = (rb->global_settings->statusbar == STATUSBAR_BOTTOM)? 4 : 2; | 237 | static const struct opt_items names[4] = |
245 | struct opt_items names[len]; | ||
246 | |||
247 | names[0].string = "None"; | ||
248 | names[0].voice_id = -1; | ||
249 | names[1].string = "Page Num"; | ||
250 | names[1].voice_id = -1; | ||
251 | |||
252 | if (rb->global_settings->statusbar == STATUSBAR_BOTTOM) | ||
253 | { | 238 | { |
254 | names[2].string = "Status bar"; | 239 | {"None", -1}, |
255 | names[2].voice_id = -1; | 240 | {"Page Num", -1}, |
256 | names[3].string = "Both"; | 241 | {"Status bar", -1}, |
257 | names[3].voice_id = -1; | 242 | {"Both", -1}, |
258 | } | 243 | }; |
259 | 244 | ||
245 | int len = (rb->global_settings->statusbar == STATUSBAR_BOTTOM)? 4 : 2; | ||
260 | return rb->set_option("Show Footer", &new_prefs.footer_mode, INT, | 246 | return rb->set_option("Show Footer", &new_prefs.footer_mode, INT, |
261 | names, len, NULL); | 247 | names, len, NULL); |
262 | } | 248 | } |
@@ -304,10 +290,7 @@ static bool tv_font_setting(void) | |||
304 | names, count, NULL); | 290 | names, count, NULL); |
305 | 291 | ||
306 | if (new_font != old_font) | 292 | if (new_font != old_font) |
307 | { | ||
308 | rb->memset(new_prefs.font_name, 0, MAX_PATH); | ||
309 | rb->strlcpy(new_prefs.font_name, names[new_font].string, MAX_PATH); | 293 | rb->strlcpy(new_prefs.font_name, names[new_font].string, MAX_PATH); |
310 | } | ||
311 | 294 | ||
312 | *tree = backup; | 295 | *tree = backup; |
313 | rb->set_current_file(backup.currdir); | 296 | rb->set_current_file(backup.currdir); |
@@ -350,9 +333,9 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, | |||
350 | #endif | 333 | #endif |
351 | &scroll_menu, &indent_spaces_item); | 334 | &scroll_menu, &indent_spaces_item); |
352 | 335 | ||
353 | static enum tv_menu_result tv_options_menu(void) | 336 | static unsigned tv_options_menu(void) |
354 | { | 337 | { |
355 | enum tv_menu_result result = TV_MENU_RESULT_EXIT_MENU; | 338 | unsigned result = TV_MENU_RESULT_EXIT_MENU; |
356 | 339 | ||
357 | if (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB) | 340 | if (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB) |
358 | result = TV_MENU_RESULT_ATTACHED_USB; | 341 | result = TV_MENU_RESULT_ATTACHED_USB; |
@@ -360,9 +343,9 @@ static enum tv_menu_result tv_options_menu(void) | |||
360 | return result; | 343 | return result; |
361 | } | 344 | } |
362 | 345 | ||
363 | enum tv_menu_result tv_display_menu(void) | 346 | unsigned tv_display_menu(void) |
364 | { | 347 | { |
365 | enum tv_menu_result result = TV_MENU_RESULT_EXIT_MENU; | 348 | unsigned result = TV_MENU_RESULT_EXIT_MENU; |
366 | 349 | ||
367 | MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL, | 350 | MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL, |
368 | "Return", "Viewer Options", | 351 | "Return", "Viewer Options", |