summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2011-01-17 12:40:21 +0000
committerTeruaki Kawashima <teru@rockbox.org>2011-01-17 12:40:21 +0000
commit1c14d29370cfc35d5c89d2256edf00f914e0bc20 (patch)
tree1721ab488af125559b8be06710d744494044bb54 /apps/plugins/text_viewer
parent05f6f3419aec991307e7c81e0738e0496a21d89b (diff)
downloadrockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.zip
rockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.tar.gz
rockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.tar.bz2
rockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.tar.xz
FS#11822: use rockbox_browse() in plugins to select file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29069 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer')
-rw-r--r--apps/plugins/text_viewer/tv_menu.c59
1 files changed, 17 insertions, 42 deletions
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index 9be8312..9e79698 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -216,53 +216,28 @@ static bool tv_statusbar_setting(void)
static bool tv_font_setting(void)
{
- int count = 0;
- int i = 0;
- int new_font = 0;
- int old_font;
- bool res;
- unsigned char font_path[MAX_PATH];
-
- struct tree_context *tree;
- struct tree_context backup;
- struct entry *dc;
- int dirfilter = SHOW_FONT;
-
- tree = rb->tree_get_context();
- backup = *tree;
- dc = tree->dircache;
- rb->strlcat(backup.currdir, "/", MAX_PATH);
- rb->strlcat(backup.currdir, dc[tree->selected_item].name, MAX_PATH);
- tree->dirfilter = &dirfilter;
- tree->browse = NULL;
- rb->snprintf(font_path, MAX_PATH, "%s/", FONT_DIR);
- rb->set_current_file(font_path);
- count = tree->filesindir;
-
- struct opt_items names[count];
-
- for (i = 0; i < count; i++)
- {
- char *p = rb->strrchr(dc[i].name, '.');
- if (p) *p = 0;
- if (!rb->strcmp(dc[i].name, new_prefs.font_name))
- new_font = i;
+ struct browse_context browse;
+ char font[MAX_PATH], name[MAX_FILENAME+10];
- names[i].string = dc[i].name;
- names[i].voice_id = -1;
- }
+ rb->snprintf(name, sizeof(name), "%s.fnt", new_prefs.font_name);
+ rb->browse_context_init(&browse, SHOW_FONT,
+ BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU,
+ "Font", Icon_Menu_setting, FONT_DIR, name);
- old_font = new_font;
+ browse.buf = font;
+ browse.bufsize = sizeof(font);
- res = rb->set_option("Select Font", &new_font, INT,
- names, count, NULL);
+ rb->rockbox_browse(&browse);
- if (new_font != old_font)
- rb->strlcpy(new_prefs.font_name, names[new_font].string, MAX_PATH);
+ 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);
+ }
- *tree = backup;
- rb->set_current_file(backup.currdir);
- return res;
+ return false;
}
#endif