byte auifav_add(const char *path) { if (!path) return 0; if (auifav_isfav(path)) return 0; char *o = aarray_get(aui_cfg_array, "favorites"); char *q = NULL; int n = strlen(path) + 1; if (o != NULL) n += strlen(o) + 1; q = malloc(n); if (o != NULL) snprintf(q, n, "%s;%s", o, path); else snprintf(q, n, "%s", path); aarray_set(aui_cfg_array, "favorites", q); free(q); aui_cfg_savechange(); return 1; }
byte auifav_del(const char *path) { if (!path) return 0; if (!auifav_isfav(path)) return 0; char *o = aarray_get(aui_cfg_array, "favorites"); if (o == NULL) return 0; int n = 0; int wl = strlen(o) + 1; char *w = malloc(wl); w[0] = 0; char *buf = strdup(o); char *tok = strtok(buf, ";"); while (tok) { if (strcmp(path, tok) != 0) { if (n > 0) { char *tw = strdup(w); snprintf(w, wl, "%s;%s", tw, tok); free(tw); } else { snprintf(w, wl, "%s", tok); } n++; } tok = strtok(NULL, ";"); } free(buf); aarray_set(aui_cfg_array, "favorites", w); free(w); aui_cfg_savechange(); return 1; }
//* //* SHOW MENU //* byte auia_menu(AUI_VARSP v) { byte common_cmd = 0; byte cstate = *v->state; if ((cstate == 1) || (cstate == 2)) { AWMENUITEM mi[5]; int cp = 0; if (cstate == 1) { aw_menuset(mi, cp++, "tools.unselect", 19); } aw_menuset(mi, cp++, "tools.delete", 4); aw_menuset(mi, cp++, "settings", 17); aw_menuset(mi, cp++, "about", 9); aw_menuset(mi, cp++, "exit", 0); byte ret = aw_menu(v->hWin, NULL, mi, cp); if ((cstate == 2) && (ret > 0)) { ret++; } if (ret == 5) { common_cmd = 1; } else if (ret == 3) { common_cmd = 2; } else if (ret == 4) { common_cmd = 3; } else if (ret == 2) { //-- Delete auia_setclipboard(v, 3); return auia_do_delete(v); } else if (ret == 1) { afbox_setcheckall(v->hFile, 0); } } else { int cp = 0; AWMENUITEM mi[7]; if (cstate == 3) { aw_menuset(mi, cp++, "tools.newfolder", 11); } byte isonfav = auifav_isfav(v->path); if (isonfav) { aw_menuset(mi, cp++, "tools.favorite.del", 8); } else { aw_menuset(mi, cp++, "tools.favorite.add", 7); } aw_menuset(mi, cp++, (auic()->showhidden ? "tools.hiddenfile" : "tools.hiddenfile.show"), 18); aw_menuset(mi, cp++, "tools.terminal", 40); aw_menuset(mi, cp++, "settings", 17); aw_menuset(mi, cp++, "about", 9); aw_menuset(mi, cp++, "exit", 0); byte ret = aw_menu(v->hWin, NULL, mi, cp); if ((cstate != 3) && (ret > 0)) { ret++; } if (ret == 7) { /* EXIT */ common_cmd = 1; } else if (ret == 6) { /* ABOUT */ common_cmd = 3; } else if (ret == 4) { /* TERMINAL */ common_cmd = 4; } else if (ret == 5) { /* SETTING */ common_cmd = 2; } else if (ret == 3) { auic()->showhidden = (auic()->showhidden ? 0 : 1); aui_cfg_save(); v->reshow = 1; return 0; } else if (ret == 2) { //-- Add Remove Favorite if (isonfav) { auifav_del(v->path); } else { auifav_add(v->path); } } else if (ret == 1) { //-- Show New Folder return auia_newfolder(v); } } //-- Common command if (common_cmd == 1) { //-- Exit AWMENUITEM mi[2]; aw_menuset(mi, 0, "yes", 33); aw_menuset(mi, 1, "no", 0); byte ovr = aw_multiconfirm_ex(v->hWin, alang_get("exit"), alang_get("exit.message"), aui_icons(39), mi, 2, 1); if (ovr == 0) { return 0; } } else if (common_cmd == 2) { //-- Settings v->reshow = 2; return 0; } else if (common_cmd == 3) { //-- About auido_about_dialog(v->hWin); } else if (common_cmd == 4) { //-- Terminal v->reshow = 6; return 0; } return 1; }
byte auia_hold(AUI_VARSP v) { char * fl = afbox_getselectedfile(v->hFile); byte dtype = afbox_dtype(v->hFile); if (fl != NULL) { AWMENUITEM mi[6]; int cp = 0; byte onfav = 0; byte isonfav = 0; if ((dtype == 4) || (dtype == 24)) { isonfav = auifav_isfav(fl); if (isonfav) { aw_menuset(mi, cp++, "tools.favorite.del", 8); } else { aw_menuset(mi, cp++, "tools.favorite.add", 7); } onfav = 1; } aw_menuset(mi, cp++, "tools.rename", 15); aw_menuset(mi, cp++, "tools.copy", 2); aw_menuset(mi, cp++, "tools.cut", 3); aw_menuset(mi, cp++, "tools.delete", 4); aw_menuset(mi, cp++, "tools.chmod", 1); byte ret = aw_menu(v->hWin, fl, mi, cp); if ((!onfav) && (ret > 0)) { ret++; } if (ret == 2) { //-- Rename return auia_hold_rename(v, fl); } else if (ret == 6) { //-- Rename return auia_hold_perm(v, fl); } else if ((ret == 3) || (ret == 4)) { //-- Copy / cut ag_setbusy(); auic_init(ret - 2, 1, v->path); auic_add(fl); *v->state = aui_tbstate(v, 3, *v->state); afbox_changeboxtype(v->hFile, 1); aui_changetitle(v, alang_get("paste.location")); afbox_setcheckall(v->hFile, 0); } else if (ret == 5) { //-- Copy / cut ag_setbusy(); auic_init(3, 1, v->path); auic_add(fl); return auia_do_delete(v); } else if (ret == 1) { //-- Add Remove Favorite char * full_fl = NULL; aui_setpath(&full_fl, v->path, fl, 1); if (full_fl != NULL) { if (isonfav) { auifav_del(full_fl); } else { auifav_add(full_fl); } LOGS("Add To Favorite: %s\n", full_fl); free(full_fl); } } } return 1; }