static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data) { (void)data; struct shortcut *sc = get_shortcut(selected_item); if (!sc) return Icon_NOICON; if (sc->icon == Icon_NOICON) { switch (sc->type) { case SHORTCUT_FILE: return filetype_get_icon(filetype_get_attr(sc->u.path)); case SHORTCUT_BROWSER: return Icon_Folder; case SHORTCUT_SETTING: return Icon_Menu_setting; case SHORTCUT_DEBUGITEM: return Icon_Menu_functioncall; case SHORTCUT_PLAYLISTMENU: return Icon_Playlist; case SHORTCUT_SHUTDOWN: return Icon_System_menu; case SHORTCUT_TIME: return Icon_Menu_functioncall; default: break; } } return sc->icon; }
static enum themable_icons tree_get_fileicon(int selected_item, void * data) { struct tree_context * local_tc=(struct tree_context *)data; #ifdef HAVE_TAGCACHE bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB; if (id3db) { return tagtree_get_icon(&tc); } else #endif { struct entry* e = tree_get_entry_at(local_tc, selected_item); return filetype_get_icon(e->attr); } }
/* * Called when a new dir is loaded (for example when returning from other apps ...) * also completely redraws the tree */ static int update_dir(void) { bool changed = false; #ifdef HAVE_TAGCACHE bool id3db = *tc.dirfilter == SHOW_ID3DB; /* Checks for changes */ if (id3db) { if (tc.currtable != lasttable || tc.currextra != lastextra || tc.firstpos != lastfirstpos || reload_dir) { if (tagtree_load(&tc) < 0) return -1; lasttable = tc.currtable; lastextra = tc.currextra; lastfirstpos = tc.firstpos; changed = true; } } else #endif { /* if the tc.currdir has been changed, reload it ...*/ if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) { if (ft_load(&tc, NULL) < 0) return -1; strcpy(lastdir, tc.currdir); changed = true; } } /* if selected item is undefined */ if (tc.selected_item == -1) { /* use lastfile to determine the selected item */ tc.selected_item = tree_get_file_position(lastfile); /* If the file doesn't exists, select the first one (default) */ if(tc.selected_item < 0) tc.selected_item = 0; changed = true; } if (changed) { if( #ifdef HAVE_TAGCACHE !id3db && #endif tc.dirfull ) { splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL)); } } #ifdef HAVE_TAGCACHE if (id3db) { #ifdef HAVE_LCD_BITMAP if (global_settings.show_path_in_browser == SHOW_PATH_FULL || global_settings.show_path_in_browser == SHOW_PATH_CURRENT) { gui_synclist_set_title(&tree_lists, tagtree_get_title(&tc), filetype_get_icon(ATTR_DIRECTORY)); } else { /* Must clear the title as the list is reused */ gui_synclist_set_title(&tree_lists, NULL, NOICON); } #endif } else #endif { #ifdef HAVE_LCD_BITMAP if (tc.browse && tc.browse->title) { int icon = tc.browse->icon; if (icon == NOICON) icon = filetype_get_icon(ATTR_DIRECTORY); gui_synclist_set_title(&tree_lists, tc.browse->title, icon); } else if (global_settings.show_path_in_browser == SHOW_PATH_FULL) { gui_synclist_set_title(&tree_lists, tc.currdir, filetype_get_icon(ATTR_DIRECTORY)); } else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) { char *title = strrchr(tc.currdir, '/') + 1; if (*title == '\0') { /* Display "Files" for the root dir */ gui_synclist_set_title(&tree_lists, str(LANG_DIR_BROWSER), filetype_get_icon(ATTR_DIRECTORY)); } else gui_synclist_set_title(&tree_lists, title, filetype_get_icon(ATTR_DIRECTORY)); } else { /* Must clear the title as the list is reused */ gui_synclist_set_title(&tree_lists, NULL, NOICON); } #endif } gui_synclist_set_nb_items(&tree_lists, tc.filesindir); gui_synclist_set_icon_callback(&tree_lists, global_settings.show_icons?tree_get_fileicon:NULL); if( tc.selected_item >= tc.filesindir) tc.selected_item=tc.filesindir-1; gui_synclist_select_item(&tree_lists, tc.selected_item); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { if (*tc.dirfilter < NUM_FILTER_MODES) gui_buttonbar_set(&tree_buttonbar, str(LANG_SYSFONT_DIRBROWSE_F1), str(LANG_SYSFONT_DIRBROWSE_F2), str(LANG_SYSFONT_DIRBROWSE_F3)); else gui_buttonbar_set(&tree_buttonbar, "<<<", "", ""); gui_buttonbar_draw(&tree_buttonbar); } #endif gui_synclist_draw(&tree_lists); gui_synclist_speak_item(&tree_lists); return tc.filesindir; }
static int readline_cb(int n, char *buf, void *parameters) { (void)n; (void)parameters; struct shortcut **param = (struct shortcut**)parameters; struct shortcut* sc = *param; char *name, *value; if (!strcasecmp(skip_whitespace(buf), "[shortcut]")) { if (sc && verify_shortcut(sc)) shortcut_count++; sc = get_shortcut(shortcut_count); if (!sc) return 1; init_shortcut(sc); *param = sc; } else if (sc && settings_parseline(buf, &name, &value)) { if (!strcmp(name, "type")) { int t = 0; for (t=0; t<SHORTCUT_TYPE_COUNT && sc->type == SHORTCUT_UNDEFINED; t++) if (!strcmp(value, type_strings[t])) sc->type = t; } else if (!strcmp(name, "name")) { strlcpy(sc->name, value, MAX_SHORTCUT_NAME); } else if (!strcmp(name, "data")) { switch (sc->type) { case SHORTCUT_UNDEFINED: case SHORTCUT_TYPE_COUNT: *param = NULL; break; case SHORTCUT_BROWSER: case SHORTCUT_FILE: case SHORTCUT_DEBUGITEM: case SHORTCUT_PLAYLISTMENU: strlcpy(sc->u.path, value, MAX_PATH); break; case SHORTCUT_SETTING: sc->u.setting = find_setting_by_cfgname(value, NULL); break; case SHORTCUT_TIME: #if CONFIG_RTC sc->u.timedata.talktime = false; if (!strcasecmp(value, "talk")) sc->u.timedata.talktime = true; else #endif if (!strncasecmp(value, "sleep ", strlen("sleep "))) sc->u.timedata.sleep_timeout = atoi(&value[strlen("sleep ")]); else sc->type = SHORTCUT_UNDEFINED; /* error */ break; case SHORTCUT_SEPARATOR: case SHORTCUT_SHUTDOWN: break; } } else if (!strcmp(name, "icon")) { if (!strcmp(value, "filetype") && sc->type != SHORTCUT_SETTING && sc->u.path[0]) { sc->icon = filetype_get_icon(filetype_get_attr(sc->u.path)); } else { sc->icon = atoi(value); } } else if (!strcmp(name, "talkclip")) { strlcpy(sc->talk_clip, value, MAX_PATH); } } return 0; }