2010-06-05 10:30:08 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Gilles Roux
|
|
|
|
* 2003 Garrett Derner
|
|
|
|
* 2010 Yoshihisa Uchida
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "lib/playback_control.h"
|
|
|
|
#include "tv_bookmark.h"
|
|
|
|
#include "tv_menu.h"
|
|
|
|
#include "tv_settings.h"
|
|
|
|
|
|
|
|
/* settings helper functions */
|
|
|
|
|
|
|
|
static struct tv_preferences new_prefs;
|
|
|
|
|
2010-06-07 11:04:09 +00:00
|
|
|
/* */
|
|
|
|
/* horizontal scroll settings menu */
|
|
|
|
/* */
|
|
|
|
|
2010-06-06 10:52:19 +00:00
|
|
|
static bool tv_horizontal_scrollbar_setting(void)
|
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Horizontal Scrollbar", &new_prefs.horizontal_scrollbar);
|
2010-06-06 10:52:19 +00:00
|
|
|
}
|
2010-06-07 11:04:09 +00:00
|
|
|
|
|
|
|
static bool tv_horizontal_scroll_mode_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"Scroll by Screen", -1},
|
|
|
|
{"Scroll by Column", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Scroll Mode", &new_prefs.horizontal_scroll_mode, INT,
|
|
|
|
names, 2, NULL);
|
|
|
|
}
|
2010-06-06 10:52:19 +00:00
|
|
|
|
2010-06-07 11:04:09 +00:00
|
|
|
MENUITEM_FUNCTION(horizontal_scrollbar_item, 0, "Scrollbar",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_horizontal_scrollbar_setting, NULL, Icon_NOICON);
|
2010-06-07 11:04:09 +00:00
|
|
|
MENUITEM_FUNCTION(horizontal_scroll_mode_item, 0, "Scroll Mode",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_horizontal_scroll_mode_setting, NULL, Icon_NOICON);
|
2010-06-07 11:04:09 +00:00
|
|
|
|
|
|
|
MAKE_MENU(horizontal_scroll_menu, "Horizontal", NULL, Icon_NOICON,
|
|
|
|
&horizontal_scrollbar_item,
|
|
|
|
&horizontal_scroll_mode_item);
|
|
|
|
|
|
|
|
/* */
|
|
|
|
/* vertical scroll settings menu */
|
|
|
|
/* */
|
|
|
|
|
2010-06-06 10:52:19 +00:00
|
|
|
static bool tv_vertical_scrollbar_setting(void)
|
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Vertical Scrollbar", &new_prefs.vertical_scrollbar);
|
2010-06-06 10:52:19 +00:00
|
|
|
}
|
|
|
|
|
2010-06-07 11:04:09 +00:00
|
|
|
static bool tv_vertical_scroll_mode_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"Scroll by Page", -1},
|
|
|
|
{"Scroll by Line", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Scroll Mode", &new_prefs.vertical_scroll_mode, INT,
|
|
|
|
names, 2, NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-29 12:23:41 +00:00
|
|
|
static bool tv_overlap_page_mode_setting(void)
|
2010-06-07 11:04:09 +00:00
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Overlap Pages", &new_prefs.overlap_page_mode);
|
2010-06-07 11:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_autoscroll_speed_setting(void)
|
|
|
|
{
|
|
|
|
return rb->set_int("Auto-scroll Speed", "", UNIT_INT,
|
|
|
|
&new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-09 11:28:43 +00:00
|
|
|
static bool tv_narrow_mode_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"Previous/Next Page", -1},
|
|
|
|
{"Top/Bottom Page", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Left/Right Key", &new_prefs.narrow_mode, INT,
|
|
|
|
names, 2, NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-07 11:04:09 +00:00
|
|
|
MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_vertical_scrollbar_setting, NULL, Icon_NOICON);
|
2010-06-07 11:04:09 +00:00
|
|
|
MENUITEM_FUNCTION(vertical_scroll_mode_item, 0, "Scroll Mode",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_vertical_scroll_mode_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(overlap_page_mode_item, 0, "Overlap Pages", tv_overlap_page_mode_setting, NULL, Icon_NOICON);
|
2010-06-07 11:04:09 +00:00
|
|
|
MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_autoscroll_speed_setting, NULL, Icon_NOICON);
|
2010-06-09 11:28:43 +00:00
|
|
|
MENUITEM_FUNCTION(narrow_mode_item, 0, "Left/Right Key (Narrow mode)",
|
2022-12-17 08:27:21 +00:00
|
|
|
tv_narrow_mode_setting, NULL, Icon_NOICON);
|
2010-06-07 11:04:09 +00:00
|
|
|
|
|
|
|
MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON,
|
|
|
|
&vertical_scrollbar_item,
|
2010-06-29 12:23:41 +00:00
|
|
|
&vertical_scroll_mode_item, &overlap_page_mode_item, &autoscroll_speed_item,
|
2010-06-09 11:28:43 +00:00
|
|
|
&narrow_mode_item);
|
2010-06-07 11:04:09 +00:00
|
|
|
|
|
|
|
/* */
|
|
|
|
/* scroll settings menu */
|
|
|
|
/* */
|
2010-06-06 10:52:19 +00:00
|
|
|
|
2010-06-07 11:04:09 +00:00
|
|
|
MAKE_MENU(scroll_menu, "Scroll Settings", NULL, Icon_NOICON,
|
|
|
|
&horizontal_scroll_menu, &vertical_scroll_menu);
|
|
|
|
|
|
|
|
/* */
|
2010-06-06 10:52:19 +00:00
|
|
|
/* main menu */
|
2010-06-07 11:04:09 +00:00
|
|
|
/* */
|
2010-06-06 10:52:19 +00:00
|
|
|
|
2010-06-05 10:30:08 +00:00
|
|
|
static bool tv_encoding_setting(void)
|
|
|
|
{
|
|
|
|
static struct opt_items names[NUM_CODEPAGES];
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < NUM_CODEPAGES; idx++)
|
|
|
|
{
|
|
|
|
names[idx].string = rb->get_codepage_name(idx);
|
|
|
|
names[idx].voice_id = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rb->set_option("Encoding", &new_prefs.encoding, INT, names,
|
|
|
|
sizeof(names) / sizeof(names[0]), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_word_wrap_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"On", -1},
|
|
|
|
{"Off (Chop Words)", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Word Wrap", &new_prefs.word_mode, INT,
|
|
|
|
names, 2, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_line_mode_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"Normal", -1},
|
|
|
|
{"Join Lines", -1},
|
|
|
|
{"Expand Lines", -1},
|
|
|
|
{"Reflow Lines", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Line Mode", &new_prefs.line_mode, INT, names,
|
|
|
|
sizeof(names) / sizeof(names[0]), NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-06 08:44:27 +00:00
|
|
|
static bool tv_windows_setting(void)
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
2010-06-06 08:44:27 +00:00
|
|
|
return rb->set_int("Screens Per Page", "", UNIT_INT,
|
|
|
|
&new_prefs.windows, NULL, 1, 1, 5, NULL);
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_alignment_setting(void)
|
|
|
|
{
|
|
|
|
static const struct opt_items names[] = {
|
|
|
|
{"Left", -1},
|
|
|
|
{"Right", -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
return rb->set_option("Alignment", &new_prefs.alignment, INT,
|
|
|
|
names , 2, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_header_setting(void)
|
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Show Header", &new_prefs.header_mode);
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_footer_setting(void)
|
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Show Footer", &new_prefs.footer_mode);
|
2010-06-26 12:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_statusbar_setting(void)
|
|
|
|
{
|
2010-06-29 12:23:41 +00:00
|
|
|
return rb->set_bool("Show Statusbar", &new_prefs.statusbar);
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tv_font_setting(void)
|
|
|
|
{
|
2011-01-17 12:40:21 +00:00
|
|
|
char font[MAX_PATH], name[MAX_FILENAME+10];
|
|
|
|
rb->snprintf(name, sizeof(name), "%s.fnt", new_prefs.font_name);
|
2010-06-05 10:30:08 +00:00
|
|
|
|
2022-11-30 15:17:54 +00:00
|
|
|
struct browse_context browse = {
|
|
|
|
.dirfilter = SHOW_FONT,
|
|
|
|
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU,
|
|
|
|
.title = "Font", /* XXX: Translate? */
|
|
|
|
.icon = Icon_Menu_setting,
|
|
|
|
.root = FONT_DIR,
|
|
|
|
.selected = name,
|
|
|
|
.buf = font,
|
|
|
|
.bufsize = sizeof(font),
|
|
|
|
};
|
2010-06-05 10:30:08 +00:00
|
|
|
|
2011-01-17 12:40:21 +00:00
|
|
|
rb->rockbox_browse(&browse);
|
2010-06-05 10:30:08 +00:00
|
|
|
|
2011-01-17 12:40:21 +00:00
|
|
|
if (browse.flags & BROWSE_SELECTED)
|
|
|
|
{
|
|
|
|
char *name = rb->strrchr(font, '/')+1;
|
|
|
|
char *p = rb->strrchr(name, '.');
|
|
|
|
if (p) *p = 0;
|
|
|
|
rb->strlcpy(new_prefs.font_name, name, MAX_PATH);
|
|
|
|
}
|
2010-06-05 10:30:08 +00:00
|
|
|
|
2011-01-17 12:40:21 +00:00
|
|
|
return false;
|
2010-06-05 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:13:02 +00:00
|
|
|
static bool tv_indent_spaces_setting(void)
|
|
|
|
{
|
|
|
|
return rb->set_int("Indent Spaces", "", UNIT_INT,
|
|
|
|
&new_prefs.indent_spaces, NULL, 1, 0, 5, NULL);
|
|
|
|
}
|
|
|
|
|
2018-04-03 17:45:22 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
static bool tv_night_mode_setting(void)
|
|
|
|
{
|
|
|
|
return rb->set_bool("Night Mode", &new_prefs.night_mode);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-12-17 08:27:21 +00:00
|
|
|
MENUITEM_FUNCTION(encoding_item, 0, "Encoding",
|
|
|
|
tv_encoding_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap",
|
|
|
|
tv_word_wrap_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(line_mode_item, 0, "Line Mode",
|
|
|
|
tv_line_mode_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(windows_item, 0, "Screens Per Page",
|
|
|
|
tv_windows_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(alignment_item, 0, "Alignment",
|
|
|
|
tv_alignment_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(header_item, 0, "Show Header",
|
|
|
|
tv_header_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(footer_item, 0, "Show Footer",
|
|
|
|
tv_footer_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(statusbar_item, 0, "Show Statusbar",
|
|
|
|
tv_statusbar_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(font_item, 0, "Font",
|
|
|
|
tv_font_setting, NULL, Icon_NOICON);
|
|
|
|
MENUITEM_FUNCTION(indent_spaces_item, 0, "Indent Spaces",
|
|
|
|
tv_indent_spaces_setting, NULL, Icon_NOICON);
|
2018-04-03 17:45:22 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2022-12-17 08:27:21 +00:00
|
|
|
MENUITEM_FUNCTION(night_mode_item, 0, "Night Mode",
|
|
|
|
tv_night_mode_setting, NULL, Icon_NOICON);
|
2018-04-03 17:45:22 +00:00
|
|
|
#endif
|
2010-06-07 11:04:09 +00:00
|
|
|
|
2010-06-05 10:30:08 +00:00
|
|
|
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
|
2010-06-06 08:44:27 +00:00
|
|
|
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
|
2010-06-05 10:30:08 +00:00
|
|
|
&alignment_item,
|
2010-06-26 12:17:01 +00:00
|
|
|
&header_item, &footer_item, &font_item, &statusbar_item,
|
2018-04-03 17:45:22 +00:00
|
|
|
&scroll_menu, &indent_spaces_item
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
, &night_mode_item
|
|
|
|
#endif
|
|
|
|
);
|
2010-06-05 10:30:08 +00:00
|
|
|
|
2010-06-20 21:53:47 +00:00
|
|
|
static unsigned tv_options_menu(void)
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
2010-06-20 21:53:47 +00:00
|
|
|
unsigned result = TV_MENU_RESULT_EXIT_MENU;
|
2010-06-05 10:30:08 +00:00
|
|
|
|
|
|
|
if (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB)
|
|
|
|
result = TV_MENU_RESULT_ATTACHED_USB;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-06-20 21:53:47 +00:00
|
|
|
unsigned tv_display_menu(void)
|
2010-06-05 10:30:08 +00:00
|
|
|
{
|
2010-06-20 21:53:47 +00:00
|
|
|
unsigned result = TV_MENU_RESULT_EXIT_MENU;
|
2010-06-05 10:30:08 +00:00
|
|
|
|
|
|
|
MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL,
|
|
|
|
"Return", "Viewer Options",
|
|
|
|
"Show Playback Menu", "Select Bookmark",
|
|
|
|
"Global Settings", "Quit");
|
|
|
|
|
|
|
|
switch (rb->do_menu(&menu, NULL, NULL, false))
|
|
|
|
{
|
|
|
|
case 0: /* return */
|
|
|
|
break;
|
|
|
|
case 1: /* change settings */
|
|
|
|
tv_copy_preferences(&new_prefs);
|
|
|
|
result = tv_options_menu();
|
2010-12-14 21:33:45 +00:00
|
|
|
if (tv_compare_preferences(&new_prefs))
|
|
|
|
preferences_changed = true;
|
2010-06-29 11:05:36 +00:00
|
|
|
if (!tv_set_preferences(&new_prefs))
|
|
|
|
result = TV_MENU_RESULT_ERROR;
|
2010-06-05 10:30:08 +00:00
|
|
|
break;
|
|
|
|
case 2: /* playback control */
|
|
|
|
playback_control(NULL);
|
|
|
|
break;
|
|
|
|
case 3: /* select bookmark */
|
|
|
|
tv_select_bookmark();
|
2010-06-10 10:57:05 +00:00
|
|
|
result = TV_MENU_RESULT_MOVE_PAGE;
|
2010-06-05 10:30:08 +00:00
|
|
|
break;
|
|
|
|
case 4: /* change global settings */
|
|
|
|
if (!tv_load_global_settings(&new_prefs))
|
|
|
|
tv_set_default_preferences(&new_prefs);
|
|
|
|
|
|
|
|
result = tv_options_menu();
|
|
|
|
tv_save_global_settings(&new_prefs);
|
|
|
|
break;
|
|
|
|
case 5: /* quit */
|
|
|
|
result = TV_MENU_RESULT_EXIT_PLUGIN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|