diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c index ce85dc9..8a6d80e 100644 --- a/apps/plugins/text_viewer/tv_menu.c +++ b/apps/plugins/text_viewer/tv_menu.c @@ -42,8 +42,8 @@ static bool tv_horizontal_scrollbar_setting(void) {"Yes", -1}, }; - return rb->set_option("Horizontal Scrollbar", &new_prefs.horizontal_scrollbar, INT, - names, 2, NULL); + return rb->set_option("Horizontal Scrollbar", &new_prefs.horizontal_scrollbar, + sizeof(new_prefs.horizontal_scrollbar), names, 2, NULL); } #endif @@ -54,8 +54,8 @@ static bool tv_horizontal_scroll_mode_setting(void) {"Scroll by Column", -1}, }; - return rb->set_option("Scroll Mode", &new_prefs.horizontal_scroll_mode, INT, - names, 2, NULL); + return rb->set_option("Scroll Mode", &new_prefs.horizontal_scroll_mode, + sizeof(new_prefs.horizontal_scroll_mode), names, 2, NULL); } #ifdef HAVE_LCD_BITMAP @@ -84,8 +84,8 @@ static bool tv_vertical_scrollbar_setting(void) {"Yes", -1}, }; - return rb->set_option("Vertical Scrollbar", &new_prefs.vertical_scrollbar, INT, - names, 2, NULL); + return rb->set_option("Vertical Scrollbar", &new_prefs.vertical_scrollbar, + sizeof(new_prefs.vertical_scrollbar), names, 2, NULL); } #endif @@ -96,8 +96,8 @@ static bool tv_vertical_scroll_mode_setting(void) {"Scroll by Line", -1}, }; - return rb->set_option("Scroll Mode", &new_prefs.vertical_scroll_mode, INT, - names, 2, NULL); + return rb->set_option("Scroll Mode", &new_prefs.vertical_scroll_mode, + sizeof(new_prefs.vertical_scroll_mode), names, 2, NULL); } static bool tv_page_mode_setting(void) @@ -107,8 +107,8 @@ static bool tv_page_mode_setting(void) {"Yes", -1}, }; - return rb->set_option("Overlap Pages", &new_prefs.page_mode, INT, - names, 2, NULL); + return rb->set_option("Overlap Pages", &new_prefs.page_mode, + sizeof(new_prefs.page_mode), names, 2, NULL); } static bool tv_autoscroll_speed_setting(void) @@ -124,8 +124,8 @@ static bool tv_narrow_mode_setting(void) {"Top/Bottom Page", -1}, }; - return rb->set_option("Left/Right Key", &new_prefs.narrow_mode, INT, - names, 2, NULL); + return rb->set_option("Left/Right Key", &new_prefs.narrow_mode, + sizeof(new_prefs.narrow_mode), names, 2, NULL); } #ifdef HAVE_LCD_BITMAP @@ -171,8 +171,8 @@ static bool tv_encoding_setting(void) names[idx].voice_id = -1; } - return rb->set_option("Encoding", &new_prefs.encoding, INT, names, - sizeof(names) / sizeof(names[0]), NULL); + return rb->set_option("Encoding", &new_prefs.encoding, sizeof(new_prefs.encoding), + names, sizeof(names) / sizeof(names[0]), NULL); } static bool tv_word_wrap_setting(void) @@ -182,7 +182,7 @@ static bool tv_word_wrap_setting(void) {"Off (Chop Words)", -1}, }; - return rb->set_option("Word Wrap", &new_prefs.word_mode, INT, + return rb->set_option("Word Wrap", &new_prefs.word_mode, sizeof(new_prefs.word_mode), names, 2, NULL); } @@ -195,8 +195,8 @@ static bool tv_line_mode_setting(void) {"Reflow Lines", -1}, }; - return rb->set_option("Line Mode", &new_prefs.line_mode, INT, names, - sizeof(names) / sizeof(names[0]), NULL); + return rb->set_option("Line Mode", &new_prefs.line_mode, sizeof(new_prefs.line_mode), + names, sizeof(names) / sizeof(names[0]), NULL); } static bool tv_windows_setting(void) @@ -212,7 +212,7 @@ static bool tv_alignment_setting(void) {"Right", -1}, }; - return rb->set_option("Alignment", &new_prefs.alignment, INT, + return rb->set_option("Alignment", &new_prefs.alignment, sizeof(new_prefs.alignment), names , 2, NULL); } @@ -235,7 +235,7 @@ static bool tv_header_setting(void) names[3].voice_id = -1; } - return rb->set_option("Show Header", &new_prefs.header_mode, INT, + return rb->set_option("Show Header", &new_prefs.header_mode, sizeof(new_prefs.header_mode), names, len, NULL); } @@ -257,7 +257,7 @@ static bool tv_footer_setting(void) names[3].voice_id = -1; } - return rb->set_option("Show Footer", &new_prefs.footer_mode, INT, + return rb->set_option("Show Footer", &new_prefs.footer_mode, sizeof(new_prefs.footer_mode), names, len, NULL); } diff --git a/apps/settings.c b/apps/settings.c index ea59ff1..25c1ac1 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -1174,14 +1174,22 @@ bool set_option(const char* string, const void* variable, enum optiontype type, item.setting = &temp; if (type == BOOL) temp = *(bool*)variable? 1: 0; - else + else if (type == INT) temp = *(int*)variable; + else if (type == CHAR) + temp = *(char*)variable; + else /* type == SHORT */ + temp = *(short*)variable; if (!option_screen(&item, NULL, false, NULL)) { if (type == BOOL) *(bool*)variable = (temp == 1); - else + else if (type == INT) *(int*)variable = temp; + else if (type == CHAR) + *(char*)variable = temp; + else /* type == SHORT */ + *(short*)variable = temp; return false; } return true; diff --git a/apps/settings.h b/apps/settings.h index a324ef2..d52104f 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -265,7 +265,12 @@ void settings_apply(bool read_disk); void settings_apply_pm_range(void); void settings_display(void); -enum optiontype { INT, BOOL }; +enum optiontype { + BOOL = 0, + CHAR = 1, + SHORT = 2, + INT = 4, +}; const struct settings_list* find_setting(const void* variable, int *id); bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len);