explorer: fixed opening nodes that specify a path
[ede] / explorer / src / ExplorerWindow.ec
index a235a05..fa7bf4c 100644 (file)
@@ -129,7 +129,7 @@ class ExplorerWindow : Window
             {
                char * home = getenv("HOME");
                if(home && home[0] && FileExists(home).isDirectory)
-                  view.path = home;
+                  GoToLocation(home, false, false);
                break;
             }
             case goUp:
@@ -142,7 +142,7 @@ class ExplorerWindow : Window
                   newPath[0] = '/';
                   newPath[1] = 0;
                }
-               view.path = newPath;
+               GoToLocation(newPath, false, false);
                delete newPath;
                break;
             }
@@ -234,7 +234,7 @@ class ExplorerWindow : Window
 
       bool NotifyModified(PathBox pathBox)
       {
-         view.path = pathBox.path;
+         GoToLocation(pathBox.path, false, false);
          return true;
       }
    };
@@ -320,12 +320,13 @@ class ExplorerWindow : Window
 
       treeBranches = true;
       foldersOnly = true;
+      autoLoad = false;
 
       bool NotifyNodeSelect(FileSystemBox box, FileSystemNode node)
       {
          char p[MAX_LOCATION];
          node.GetPath(p);
-         view.path = node.path;
+         GoToLocation(node.path, false, true);
          return true;
       }
    };
@@ -350,25 +351,29 @@ class ExplorerWindow : Window
       locationBox = addressBar;
       navigateFolders = true;
       multiSelect = true;
+      autoLoad = false;
 
       bool NotifyNodeOpen(FileSystemBox box, FileSystemNode node)
       {
          if(node.type.isFile)
          {
+            char path[MAX_LOCATION];
          #ifndef __WIN32__
             char command[MAX_LOCATION];
+            node.GetPath(path);
             /*_FileType t = node.type;
             if(t == ewsFile || t == epjFile ||
                   t == ecFile || t == ehFile ||
                   t == cppFile || t == hppFile ||
                   t == cFile || t == hFile ||
                   t == textFile || t == webFile)*/
-               sprintf(command, "ide %s", node.path);
+               sprintf(command, "ide %s", path);
             /*else
-               sprintf(command, "%s", node.path);*/
+               sprintf(command, "%s", path);*/
             Execute(command);
          #else
-            ShellOpen(node.path);
+            node.GetPath(path);
+            ShellOpen(path);
          #endif
          }
          else if(node.type.isFolder && tree.visible)
@@ -470,34 +475,13 @@ class ExplorerWindow : Window
       lastViewId = viewId;
    }*/
 
-   /*void GoToLocation(char * location)
+   void GoToLocation(char * location, bool viewIsAtLocation, bool treeIsAtLocation)
    {
-      int c;
-      char * temp;
-      char step[MAX_LOCATION];
-      
-      StringArray steps { growingFactor = 4 };
-      ExplorerFileBranch last = null;
-      
-      temp = CopyString(location);
-      while(strlen(temp))
-      {
-         GetLastDirectory(temp, step);
-         StripLastDirectory(temp, temp);
-         steps.Add(CopyString(step));
-      }
-      
-      for(c = steps._count - 1; c >= 0; c--)
-      {
-         last = tree.Find(steps._[c], last);
-         if(!last)
-            break;
-         tree.Select(last);
-      }
-      
-      delete temp;
-      delete steps;
-   }*/
+      if(!viewIsAtLocation)
+         view.path = location;
+      if(tree.visible && !treeIsAtLocation)
+         tree.SelectLocation(location);
+   }
 
    /*void SearchLocation(char * location)
    {