diff options
author | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-12-09 10:32:05 +0000 |
---|---|---|
committer | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-12-09 10:32:05 +0000 |
commit | 7607259ea4f725637ee5a5502167ca0d05eb9628 (patch) | |
tree | 52a97fecf5356a6305383a2c9e63872e1f97c6ff /libmenu/menu_filesel.c | |
parent | af4390363511dfb77bc0d9c802e8798d42a814c4 (diff) | |
download | mpv-7607259ea4f725637ee5a5502167ca0d05eb9628.tar.bz2 mpv-7607259ea4f725637ee5a5502167ca0d05eb9628.tar.xz |
Combine common code for dealing with file action and dir action.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25328 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmenu/menu_filesel.c')
-rw-r--r-- | libmenu/menu_filesel.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c index e81b49ef7f..1480c5de0d 100644 --- a/libmenu/menu_filesel.c +++ b/libmenu/menu_filesel.c @@ -302,24 +302,14 @@ static int open_dir(menu_t* menu,char* args) { 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 @@ static void read_cmd(menu_t* menu,int cmd) { 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; |