ide, installer: (#718) New Project/Open Dialog: Defaulting to HOME rather than workin...
authorJerome St-Louis <jerome@ecere.com>
Tue, 11 Mar 2014 05:21:59 +0000 (01:21 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 11 Mar 2014 05:26:49 +0000 (01:26 -0400)
- On Windows, the installer would set up these to point to the Samples folder on first run,
  but on Linux or if samples were opted out the current working directory could be very confusing.
- We should avoid using the current working directory as much as possible, as the IDE might be started
  from any directory at the command line. I believe the only remaining place where the cwd is used
  is for the Find in Files dialog default 'Search in' directory. The cwd is also changed and then
  restored when invoking the debugger or compiler.

ide/src/dialogs/NewProjectDialog.ec
ide/src/ide.ec
installer/src/installer.ec

index 023b9bb..b271bd1 100644 (file)
@@ -293,7 +293,7 @@ class NewProjectDialog : Window
       //replacing this: NotifyUpdate = EditBoxUpdate;
       okBtn.disabled = !(text[0] && projectName.contents[0]);
 
-      GetWorkingDir(location, sizeof(location) - 1);
+      strcpy(location, ideSettings.ideProjectFileDialogLocation);
       PathCatSlash(location, text);
 
       GetLastDirectory(path, lastPart);
@@ -316,10 +316,7 @@ class NewProjectDialog : Window
    {
       char location[MAX_LOCATION];
 
-      if(ideSettings.ideProjectFileDialogLocation)
-         strcpy(location, ideSettings.ideProjectFileDialogLocation);
-      else
-         GetWorkingDir(location, sizeof(location) - 1);
+      strcpy(location, ideSettings.ideProjectFileDialogLocation);
 
       locationEditBox.path = location;
       strcpy(path, location);
index 7c13505..7db615d 100644 (file)
@@ -3638,6 +3638,46 @@ class IDEApp : GuiApplication
       }
       */
 
+      // Default to home directory if no directory yet set up
+      if(!ideSettings.ideProjectFileDialogLocation[0])
+      {
+         bool found = false;
+         char location[MAX_LOCATION];
+         char * home = getenv("HOME");
+         char * homeDrive = getenv("HOMEDRIVE");
+         char * homePath = getenv("HOMEPATH");
+         char * userProfile = getenv("USERPROFILE");
+         char * systemDrive = getenv("SystemDrive");
+         if(home && FileExists(home).isDirectory)
+         {
+            strcpy(location, home);
+            found = true;
+         }
+         if(!found && homeDrive && homePath)
+         {
+            strcpy(location, homeDrive);
+            PathCat(location, homePath);
+            if(FileExists(location).isDirectory)
+               found = true;
+         }
+         if(!found && FileExists(userProfile).isDirectory)
+         {
+            strcpy(location, userProfile);
+            found = true;
+         }
+         if(!found && FileExists(systemDrive).isDirectory)
+         {
+            strcpy(location, systemDrive);
+            found = true;
+         }
+         if(found)
+         {
+            ideSettings.ideProjectFileDialogLocation = location;
+            if(!ideSettings.ideFileDialogLocation[0])
+               ideSettings.ideFileDialogLocation = location;
+         }
+      }
+
       if(!LoadIncludeFile())
          PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
 
index f183eb1..100e806 100644 (file)
@@ -1234,8 +1234,7 @@ class InstallThread : Thread
 
             if(components[samples].selected)
                components[samples].GetFullPath(path, false);
-            else
-               components[coreSDK].GetFullPath(path, false);
+            // IDE will now default to HOME for the default project/files locations
 
             if(!settings.ideProjectFileDialogLocation[0])
                settings.ideProjectFileDialogLocation = path;