mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-30 18:37:40 +01:00
[Summary] choose default save/open folder on Windows
[Review] GZharun [git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 462392]
This commit is contained in:
parent
e200a5d049
commit
41a72dbecf
5 changed files with 59 additions and 22 deletions
|
|
@ -1,16 +1,17 @@
|
|||
#include "OpenFileDialogProxy.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
#include <ShlObj.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
namespace ARDOUR
|
||||
{
|
||||
bool SaveFileDialog(std::string& fileName, std::string title)
|
||||
bool SaveFileDialog(std::string& fileName, std::string path, std::string title)
|
||||
{
|
||||
TCHAR szFilePathName[_MAX_PATH] = "";
|
||||
OPENFILENAME ofn = {0};
|
||||
|
|
@ -20,6 +21,10 @@ bool SaveFileDialog(std::string& fileName, std::string title)
|
|||
ofn.lpstrTitle = title.c_str();
|
||||
ofn.Flags = OFN_OVERWRITEPROMPT;
|
||||
|
||||
if( !path.empty() )
|
||||
ofn.lpstrInitialDir = path.c_str();
|
||||
|
||||
// Run dialog
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
fileName = ofn.lpstrFile;
|
||||
|
|
@ -29,7 +34,7 @@ bool SaveFileDialog(std::string& fileName, std::string title)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OpenFileDialog(std::string& fileName, std::string title)
|
||||
bool OpenFileDialog(std::string& fileName, std::string path, std::string title)
|
||||
{
|
||||
TCHAR szFilePathName[_MAX_PATH] = "";
|
||||
OPENFILENAME ofn = {0};
|
||||
|
|
@ -39,6 +44,9 @@ bool OpenFileDialog(std::string& fileName, std::string title)
|
|||
ofn.lpstrTitle = title.c_str();
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
|
||||
if( !path.empty() )
|
||||
ofn.lpstrInitialDir = path.c_str();
|
||||
|
||||
if( GetOpenFileName(&ofn) )
|
||||
{
|
||||
fileName = ofn.lpstrFile;
|
||||
|
|
@ -48,4 +56,33 @@ bool OpenFileDialog(std::string& fileName, std::string title)
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
bool ChooseFolderDialog(std::string& selectedPath, std::string title)
|
||||
{
|
||||
BROWSEINFO bi;
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
|
||||
bi.lpszTitle = title.c_str();
|
||||
|
||||
OleInitialize(NULL);
|
||||
|
||||
LPITEMIDLIST pIDL = SHBrowseForFolder(&bi);
|
||||
|
||||
if (pIDL == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TCHAR *buffer = new TCHAR[MAX_PATH];
|
||||
if(!SHGetPathFromIDList(pIDL, buffer) != 0)
|
||||
{
|
||||
CoTaskMemFree(pIDL);
|
||||
return false;
|
||||
}
|
||||
selectedPath = buffer;
|
||||
|
||||
CoTaskMemFree(pIDL);
|
||||
OleUninitialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
|
@ -23,9 +23,9 @@ namespace ARDOUR
|
|||
|
||||
// OS Windows specific functions
|
||||
#ifdef _WIN32
|
||||
bool SaveFileDialog(std::string& fileName, std::string title = "Save");
|
||||
bool OpenFileDialog(std::string& fileName, std::string title = "Open");
|
||||
bool ChooseFolderDialog(std::string& fileName, std::string title = "Choose Folder");
|
||||
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 ChooseFolderDialog(std::string& selectedPath, std::string title = "Choose Folder");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ SessionDialog::on_new_session (WavesButton*)
|
|||
set_keep_above(false);
|
||||
string fileTitle;
|
||||
// Open the file save dialog, and choose the file name
|
||||
if ( ARDOUR::SaveFileDialog(fileTitle, _("Create New Session")) ) {
|
||||
if ( ARDOUR::SaveFileDialog(fileTitle, Config->get_default_open_path(), _("Create New Session")) ) {
|
||||
set_keep_above(true);
|
||||
_selected_session_full_name = fileTitle;
|
||||
for (size_t i = 0; i < MAX_RECENT_SESSION_COUNTS; i++) {
|
||||
|
|
@ -344,7 +344,7 @@ SessionDialog::on_open_saved_session (WavesButton*)
|
|||
set_keep_above(false);
|
||||
// Open the file save dialog, and choose the file name
|
||||
string fileName;
|
||||
if (OpenFileDialog(fileName, _("Select Saved Session"))) {
|
||||
if (OpenFileDialog(fileName, Config->get_default_open_path(), _("Select Saved Session"))) {
|
||||
set_keep_above(true);
|
||||
_selected_session_full_name = fileName;
|
||||
for (size_t i = 0; i < MAX_RECENT_SESSION_COUNTS; i++) {
|
||||
|
|
|
|||
|
|
@ -411,14 +411,19 @@ void TracksControlPanel::device_changed (bool show_confirm_dial/*=true*/)
|
|||
|
||||
msg.set_position (Gtk::WIN_POS_MOUSE);
|
||||
|
||||
set_keep_above(false);
|
||||
|
||||
switch (msg.run()) {
|
||||
case RESPONSE_NO:
|
||||
// set _ignore_changes flag to ignore changes in combo-box callbacks
|
||||
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
|
||||
|
||||
_device_combo.set_active_text (EngineStateController::instance()->get_current_device_name());
|
||||
set_keep_above(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
set_keep_above(true);
|
||||
}
|
||||
|
||||
if (EngineStateController::instance()->set_new_device_as_current(device_name) )
|
||||
|
|
@ -585,23 +590,18 @@ TracksControlPanel::on_brows_button (WavesButton*)
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/*set_keep_above(false);
|
||||
set_keep_above(false);
|
||||
string fileTitle;
|
||||
if ( ARDOUR::OpenFileDialog(fileTitle, _("Choose Default Path")) ) {
|
||||
if ( ARDOUR::ChooseFolderDialog(fileTitle, _("Choose Default Path")) ) {
|
||||
set_keep_above(true);
|
||||
_default_path_name = fileTitle;
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
cout<<endl<<endl<<"DEFAULT_PATH = "<<_default_path_name<<endl<<endl<<flush;
|
||||
|
||||
Gtk::Label& default_open_path (named_children ().get_label("default_open_path"));
|
||||
|
||||
if( !_default_path_name.empty() )
|
||||
_default_open_path.set_text(_default_path_name);
|
||||
else
|
||||
_default_open_path.set_text(Config->get_default_open_path());
|
||||
*/
|
||||
|
||||
return;
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ def build(bld):
|
|||
obj.source += [ 'cocoacarbon.mm', 'bundle_env_cocoa.cc' ]
|
||||
elif bld.env['build_target'] == 'mingw':
|
||||
obj.source += [ 'bundle_env_mingw.cc' ]
|
||||
obj.lib = 'comdlg32'
|
||||
obj.lib = 'comdlg32 Shell32'
|
||||
else:
|
||||
obj.source += [ 'bundle_env_linux.cc' ]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue