diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2011-01-17 12:40:21 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2011-01-17 12:40:21 +0000 |
commit | 1c14d29370cfc35d5c89d2256edf00f914e0bc20 (patch) | |
tree | 1721ab488af125559b8be06710d744494044bb54 /apps/plugins/text_viewer/tv_menu.c | |
parent | 05f6f3419aec991307e7c81e0738e0496a21d89b (diff) | |
download | rockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.tar.gz rockbox-1c14d29370cfc35d5c89d2256edf00f914e0bc20.zip |
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/tv_menu.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_menu.c | 59 |
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 9be8312732..9e796982d3 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) | |||
216 | 216 | ||
217 | static bool tv_font_setting(void) | 217 | static bool tv_font_setting(void) |
218 | { | 218 | { |
219 | int count = 0; | 219 | struct browse_context browse; |
220 | int i = 0; | 220 | char font[MAX_PATH], name[MAX_FILENAME+10]; |
221 | int new_font = 0; | ||
222 | int old_font; | ||
223 | bool res; | ||
224 | unsigned char font_path[MAX_PATH]; | ||
225 | |||
226 | struct tree_context *tree; | ||
227 | struct tree_context backup; | ||
228 | struct entry *dc; | ||
229 | int dirfilter = SHOW_FONT; | ||
230 | |||
231 | tree = rb->tree_get_context(); | ||
232 | backup = *tree; | ||
233 | dc = tree->dircache; | ||
234 | rb->strlcat(backup.currdir, "/", MAX_PATH); | ||
235 | rb->strlcat(backup.currdir, dc[tree->selected_item].name, MAX_PATH); | ||
236 | tree->dirfilter = &dirfilter; | ||
237 | tree->browse = NULL; | ||
238 | rb->snprintf(font_path, MAX_PATH, "%s/", FONT_DIR); | ||
239 | rb->set_current_file(font_path); | ||
240 | count = tree->filesindir; | ||
241 | |||
242 | struct opt_items names[count]; | ||
243 | |||
244 | for (i = 0; i < count; i++) | ||
245 | { | ||
246 | char *p = rb->strrchr(dc[i].name, '.'); | ||
247 | if (p) *p = 0; | ||
248 | if (!rb->strcmp(dc[i].name, new_prefs.font_name)) | ||
249 | new_font = i; | ||
250 | 221 | ||
251 | names[i].string = dc[i].name; | 222 | rb->snprintf(name, sizeof(name), "%s.fnt", new_prefs.font_name); |
252 | names[i].voice_id = -1; | 223 | rb->browse_context_init(&browse, SHOW_FONT, |
253 | } | 224 | BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU, |
225 | "Font", Icon_Menu_setting, FONT_DIR, name); | ||
254 | 226 | ||
255 | old_font = new_font; | 227 | browse.buf = font; |
228 | browse.bufsize = sizeof(font); | ||
256 | 229 | ||
257 | res = rb->set_option("Select Font", &new_font, INT, | 230 | rb->rockbox_browse(&browse); |
258 | names, count, NULL); | ||
259 | 231 | ||
260 | if (new_font != old_font) | 232 | if (browse.flags & BROWSE_SELECTED) |
261 | rb->strlcpy(new_prefs.font_name, names[new_font].string, MAX_PATH); | 233 | { |
234 | char *name = rb->strrchr(font, '/')+1; | ||
235 | char *p = rb->strrchr(name, '.'); | ||
236 | if (p) *p = 0; | ||
237 | rb->strlcpy(new_prefs.font_name, name, MAX_PATH); | ||
238 | } | ||
262 | 239 | ||
263 | *tree = backup; | 240 | return false; |
264 | rb->set_current_file(backup.currdir); | ||
265 | return res; | ||
266 | } | 241 | } |
267 | #endif | 242 | #endif |
268 | 243 | ||