[MPlayer-cvslog] r25328 - trunk/libmenu/menu_filesel.c

ulion subversion at mplayerhq.hu
Sun Dec 9 11:32:06 CET 2007


Author: ulion
Date: Sun Dec  9 11:32:05 2007
New Revision: 25328

Log:
Combine common code for dealing with file action and dir action.


Modified:
   trunk/libmenu/menu_filesel.c

Modified: trunk/libmenu/menu_filesel.c
==============================================================================
--- trunk/libmenu/menu_filesel.c	(original)
+++ trunk/libmenu/menu_filesel.c	Sun Dec  9 11:32:05 2007
@@ -302,24 +302,14 @@ static int open_dir(menu_t* menu,char* a
 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 cm
 	  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;



More information about the MPlayer-cvslog mailing list