static void read_cmd(menu_t* menu,int cmd) { switch(cmd) { case MENU_CMD_LEFT: mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../ case MENU_CMD_RIGHT: case MENU_CMD_OK: { // Directory if(mpriv->p.current->d && !mpriv->dir_action) { // Default action : open this dirctory ourself int l = strlen(mpriv->dir); char *slash = NULL, *p = NULL; if(strcmp(mpriv->p.current->p.txt,"../") == 0) { if(l <= 1) break; mpriv->dir[l-1] = '\0'; slash = strrchr(mpriv->dir,'/'); #if HAVE_DOS_PATHS if (!slash) slash = strrchr(mpriv->dir,'\\'); #endif if(!slash) break; slash[1] = '\0'; p = strdup(mpriv->dir); } else { p = malloc(l + strlen(mpriv->p.current->p.txt) + 1); sprintf(p,"%s%s",mpriv->dir,mpriv->p.current->p.txt); } menu_list_uninit(menu,free_entry); if(!open_dir(menu,p)) { mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_CantOpenDirectory,p); menu->cl = 1; } free(p); } else { // File and directory dealt with action string. int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1; char filename[fname_len]; char *str; char *action = mpriv->p.current->d ? mpriv->dir_action:mpriv->file_action; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(str); if (str != action) free(str); } } break; case MENU_CMD_ACTION: { int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1; char filename[fname_len]; char *str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(str); if(str != action) free(str); } break; default: menu_list_read_cmd(menu,cmd); } }
static void clos(menu_t* menu) { menu_list_uninit(menu,free_entry); free(mpriv->dir); }
static void close_menu(menu_t* menu) { menu_list_uninit(menu, free_entry); }
static void read_cmd(menu_t* menu, int cmd) { list_entry_t *elem; mp_cmd_t* c; char *cmd_name; switch(cmd) { case MENU_CMD_RIGHT: case MENU_CMD_OK: { elem = mpriv->p.current; if(mpriv->level == 1) { mpriv->card = mpriv->p.current->num; mpriv->level = 2; menu_list_uninit(menu, free_entry); fill_menu(menu); } else { dvb_priv_t *dvbp = (dvb_priv_t*) mpriv->config->priv; cmd_name = malloc(25 + strlen(elem->p.txt)); if(dvbp != NULL) sprintf(cmd_name, "dvb_set_channel %d %d", elem->num, mpriv->card); else sprintf(cmd_name, "loadfile 'dvb://%d@%s'", mpriv->card+1, elem->p.txt); c = mp_input_parse_cmd(cmd_name); if(c) { if (mpriv->auto_close) mp_input_queue_cmd (mp_input_parse_cmd ("menu hide")); mp_input_queue_cmd(c); } } } break; case MENU_CMD_LEFT: case MENU_CMD_CANCEL: { elem = mpriv->p.current; menu_list_uninit(menu, free_entry); if(mpriv->config->count > 1) mpriv->level--; else mpriv->level = 0; if(mpriv->level > 0) { fill_menu(menu); break; } } default: menu_list_read_cmd(menu, cmd); } }
static void close_menu(menu_t* menu) { dvb_free_config(mpriv->config); menu_list_uninit(menu, free_entry); }
static void close_menu(menu_t* menu) { menu_list_uninit(menu,NULL); }