summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer
diff options
context:
space:
mode:
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 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
217static bool tv_font_setting(void) 217static 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