From: Jerome St-Louis Date: Tue, 11 Mar 2014 05:21:59 +0000 (-0400) Subject: ide, installer: (#718) New Project/Open Dialog: Defaulting to HOME rather than workin... X-Git-Tag: 0.44.10PR1~553 X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=sdk;a=commitdiff_plain;h=0c8373c138838b2db2d8458625caeaef1ea93c2e ide, installer: (#718) New Project/Open Dialog: Defaulting to HOME rather than working directory - 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. --- diff --git a/ide/src/dialogs/NewProjectDialog.ec b/ide/src/dialogs/NewProjectDialog.ec index 023b9bb..b271bd1 100644 --- a/ide/src/dialogs/NewProjectDialog.ec +++ b/ide/src/dialogs/NewProjectDialog.ec @@ -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); diff --git a/ide/src/ide.ec b/ide/src/ide.ec index 7c13505..7db615d 100644 --- a/ide/src/ide.ec +++ b/ide/src/ide.ec @@ -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."); diff --git a/installer/src/installer.ec b/installer/src/installer.ec index f183eb1..100e806 100644 --- a/installer/src/installer.ec +++ b/installer/src/installer.ec @@ -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;