[SUMMARY] On OS Windows in new_session/open_session dialogs in case of not valid default_path set initial path on current user's home directory

[Reviewed] GZharun

[git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 462434]
This commit is contained in:
Nikolay Polyanovskii 2014-05-21 10:58:00 -05:00
parent 8b4bf9cf8a
commit fa94e468a7
3 changed files with 31 additions and 6 deletions

View file

@ -8,6 +8,8 @@
#include <string> #include <string>
#include "glibmm/miscutils.h"
using namespace std; using namespace std;
namespace ARDOUR namespace ARDOUR
{ {
@ -21,8 +23,19 @@ bool SaveFileDialog(std::string& fileName, std::string path, std::string title)
ofn.lpstrTitle = title.c_str(); ofn.lpstrTitle = title.c_str();
ofn.Flags = OFN_OVERWRITEPROMPT; ofn.Flags = OFN_OVERWRITEPROMPT;
if( !path.empty() ) // Check on valid path
WIN32_FIND_DATA FindFileData;
HANDLE handle = FindFirstFile(path.c_str(), &FindFileData) ;
int found = (handle != INVALID_HANDLE_VALUE);
// if path is valid
if( found )
ofn.lpstrInitialDir = path.c_str(); ofn.lpstrInitialDir = path.c_str();
else
{
path = Glib::get_home_dir();
ofn.lpstrInitialDir = path.c_str();
}
// Run dialog // Run dialog
if(GetSaveFileName(&ofn)) if(GetSaveFileName(&ofn))
@ -44,8 +57,19 @@ bool OpenFileDialog(std::string& fileName, std::string path, std::string title)
ofn.lpstrTitle = title.c_str(); ofn.lpstrTitle = title.c_str();
ofn.Flags = OFN_PATHMUSTEXIST; ofn.Flags = OFN_PATHMUSTEXIST;
if( !path.empty() ) // Check on valid path
WIN32_FIND_DATA FindFileData;
HANDLE handle = FindFirstFile(path.c_str(), &FindFileData) ;
int found = (handle != INVALID_HANDLE_VALUE);
// if path is valid
if( found )
ofn.lpstrInitialDir = path.c_str(); ofn.lpstrInitialDir = path.c_str();
else
{
path = Glib::get_home_dir();
ofn.lpstrInitialDir = path.c_str();
}
if( GetOpenFileName(&ofn) ) if( GetOpenFileName(&ofn) )
{ {
@ -56,7 +80,7 @@ bool OpenFileDialog(std::string& fileName, std::string path, std::string title)
return false; return false;
} }
bool ChooseFolderDialog(std::string& selectedPath, std::string title) bool ChooseFolderDialog(std::string& selectedPath, std::string path, std::string title)
{ {
BROWSEINFO bi; BROWSEINFO bi;
memset(&bi, 0, sizeof(bi)); memset(&bi, 0, sizeof(bi));

View file

@ -25,7 +25,7 @@ namespace ARDOUR
#ifdef _WIN32 #ifdef _WIN32
bool SaveFileDialog(std::string& fileName, std::string path = "", std::string title = "Save"); bool SaveFileDialog(std::string& fileName, std::string path = "", std::string title = "Save");
bool OpenFileDialog(std::string& fileName, std::string path = "", std::string title = "Open"); bool OpenFileDialog(std::string& fileName, std::string path = "", std::string title = "Open");
bool ChooseFolderDialog(std::string& selectedPath, std::string title = "Choose Folder"); bool ChooseFolderDialog(std::string& selectedPath, std::string path = "", std::string title = "Choose Folder");
#endif #endif
} }
#endif #endif

View file

@ -592,7 +592,8 @@ TracksControlPanel::on_brows_button (WavesButton*)
#ifdef _WIN32 #ifdef _WIN32
set_keep_above(false); set_keep_above(false);
string fileTitle; string fileTitle;
if ( ARDOUR::ChooseFolderDialog(fileTitle, _("Choose Default Path")) ) { // if path was chosen in dialog
if ( ARDOUR::ChooseFolderDialog(fileTitle, Config->get_default_open_path(), _("Choose Default Path")) ) {
set_keep_above(true); set_keep_above(true);
_default_path_name = fileTitle; _default_path_name = fileTitle;
} }