explorer: better internal GoToLocation code.
[ede] / explorer / src / ExplorerWindow.ec
index a2968e9..c557372 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;
       }
    };
@@ -326,7 +326,7 @@ class ExplorerWindow : Window
       {
          char p[MAX_LOCATION];
          node.GetPath(p);
-         view.path = node.path;
+         GoToLocation(node.path, false, true);
          return true;
       }
    };
@@ -472,34 +472,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)
    {