Mercurial > mplayer.hg
changeset 25300:b1638a8b9dc6
Combine common code for dealing with file action and dir action.
author | ulion |
---|---|
date | Sun, 09 Dec 2007 10:32:05 +0000 |
parents | 0335de28ee01 |
children | 456207bc0bd2 |
files | libmenu/menu_filesel.c |
diffstat | 1 files changed, 8 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libmenu/menu_filesel.c Sun Dec 09 07:50:37 2007 +0000 +++ b/libmenu/menu_filesel.c Sun Dec 09 10:32:05 2007 +0000 @@ -302,24 +302,14 @@ static char *action; static void read_cmd(menu_t* menu,int cmd) { - mp_cmd_t* c = NULL; 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) { - if(mpriv->dir_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(mpriv->dir_action,filename); - c = mp_input_parse_cmd(str); - if(str != mpriv->dir_action) - free(str); - } else { // Default action : open this dirctory ourself + 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) { @@ -343,22 +333,23 @@ menu->cl = 1; } free(p); - } - } else { // Files + } else { // File and directory dealt with action string. + mp_cmd_t* c; 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(mpriv->file_action,filename); + str = replace_path(action, filename); c = mp_input_parse_cmd(str); - if(str != mpriv->file_action) + if (str != action) free(str); - } if(c) { mp_input_queue_cmd(c); if(mpriv->auto_close) menu->cl = 1; } + } } break; case MENU_CMD_ACTION: { int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1;