diff --git a/gtk2_ardour/OpenFileDialog.cc b/gtk2_ardour/OpenFileDialog.cc deleted file mode 100644 index b35b8d34dd..0000000000 --- a/gtk2_ardour/OpenFileDialog.cc +++ /dev/null @@ -1,113 +0,0 @@ -#include "OpenFileDialogProxy.h" - -#include -#include -#include - -#include - -#include - -#include "glibmm/miscutils.h" - -using namespace std; -namespace ARDOUR -{ -bool SaveFileDialog(std::string& fileName, std::string path, std::string title) -{ - TCHAR szFilePathName[_MAX_PATH] = ""; - OPENFILENAME ofn = {0}; - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.lpstrFile = szFilePathName; // This will hold the file name - ofn.nMaxFile = _MAX_PATH; - ofn.lpstrTitle = title.c_str(); - ofn.Flags = OFN_OVERWRITEPROMPT; - - // 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(); - else - { - path = Glib::get_home_dir(); - ofn.lpstrInitialDir = path.c_str(); - } - - // Run dialog - if(GetSaveFileName(&ofn)) - { - fileName = ofn.lpstrFile; - return true; - } - - return false; -} - -bool OpenFileDialog(std::string& fileName, std::string path, std::string title) -{ - TCHAR szFilePathName[_MAX_PATH] = ""; - OPENFILENAME ofn = {0}; - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.lpstrFile = szFilePathName; // This will hold the file name - ofn.nMaxFile = _MAX_PATH; - ofn.lpstrTitle = title.c_str(); - ofn.Flags = OFN_PATHMUSTEXIST; - - // 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(); - else - { - path = Glib::get_home_dir(); - ofn.lpstrInitialDir = path.c_str(); - } - - if( GetOpenFileName(&ofn) ) - { - fileName = ofn.lpstrFile; - return true; - } - - return false; -} - -bool ChooseFolderDialog(std::string& selectedPath, std::string path, std::string title) -{ - BROWSEINFO bi; - memset(&bi, 0, sizeof(bi)); - - bi.lpszTitle = title.c_str(); - bi.ulFlags = BIF_NEWDIALOGSTYLE; - - 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 \ No newline at end of file diff --git a/gtk2_ardour/OpenFileDialog.h b/gtk2_ardour/OpenFileDialog.h deleted file mode 100644 index fd595dc40c..0000000000 --- a/gtk2_ardour/OpenFileDialog.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// OpenFileDialog.h -// Tracks -// -// Created by User on 5/8/14. -// -// - -#import -#import "OpenFileDialogProxy.h" - -// An Objective-C class that needs to be accessed from C++ -@interface FileDialog : NSObject -{ - -} - -// The Objective-C member function you want to call from C++ -+ (NSString*) ClassSaveFileDialog:(NSString *) title withArg2:(NSString *)path; -+ (NSString*) ClassOpenFileDialog:(NSString *) title withArg2:(NSString *)path; -+ (NSString*) ClassChooseFolderDialog:(NSString *) title withArg2:(NSString *)path; - -@end - - diff --git a/gtk2_ardour/OpenFileDialog.mm b/gtk2_ardour/OpenFileDialog.mm deleted file mode 100644 index 7c9448a17d..0000000000 --- a/gtk2_ardour/OpenFileDialog.mm +++ /dev/null @@ -1,168 +0,0 @@ -// -// OpenFileDialog.m -// Tracks -// -// Created by User on 5/8/14. -// -// - -#import "OpenFileDialog.h" -#import - -#include - -#include - -using namespace std; - -@implementation FileDialog - -namespace ARDOUR -{ - // ====== C "trampoline" functions to invoke Objective-C method ====== // - string OpenFileDialog(std::string path, string title) - { - NSString *nsTitle = [NSString stringWithUTF8String:title.c_str()]; - - //NP: we should find some gentle way to do this - NSString *nsDefaultPath = [NSString stringWithUTF8String:path.c_str()]; - // Call the Objective-C method using Objective-C syntax - NSString *nsPath = [FileDialog ClassOpenFileDialog:nsTitle withArg2:nsDefaultPath]; - string stdPath = [nsPath UTF8String]; - - return stdPath; - } - - string SaveFileDialog(std::string path, string title) - { - NSString *nsTitle = [NSString stringWithUTF8String:title.c_str()]; - - //NP: we should find some gentle way to do this - NSString *nsDefaultPath = [NSString stringWithUTF8String:path.c_str()]; - // Call the Objective-C method using Objective-C syntax - NSString *nsPath = [FileDialog ClassSaveFileDialog:nsTitle withArg2:nsDefaultPath]; - string stdPath = [nsPath UTF8String]; - - return stdPath; - } - - string ChooseFolderDialog(std::string path, string title) - { - NSString *nsTitle = [NSString stringWithUTF8String:title.c_str()]; - - //NP: we should find some gentle way to do this - NSString *nsDefaultPath = [NSString stringWithUTF8String:path.c_str()]; - // Call the Objective-C method using Objective-C syntax - NSString *nsPath = [FileDialog ClassChooseFolderDialog:nsTitle withArg2:nsDefaultPath]; - - string stdPath = [nsPath UTF8String]; - - return stdPath; - } -}// namespace ARDOUR - -// ====== Objective-C functions called from C++ functions ====== // - -// On open saved session -+ (NSString*) ClassOpenFileDialog:(NSString *)title withArg2:(NSString *)path -{ - // Create a File Open Dialog class. - NSOpenPanel* openDlg = [NSOpenPanel openPanel]; - - // Set array of file types - NSArray *fileTypesArray; - fileTypesArray = [NSArray arrayWithObjects:@"ardour", nil]; - - [openDlg setCanChooseFiles:YES]; - [openDlg setAllowedFileTypes:fileTypesArray]; - [openDlg setAllowsMultipleSelection:FALSE]; - [openDlg setTitle:title]; - - NSFileManager *fm = [[NSFileManager alloc] init]; - BOOL isDir; - BOOL exists = [fm fileExistsAtPath:path isDirectory:&isDir]; - - if(!exists) - path = NSHomeDirectory(); - - [openDlg setDirectoryURL : [NSURL fileURLWithPath:path]]; - - // Display the dialog box. If the OK pressed, - // process the files. - if ( [openDlg runModal] == NSOKButton ) - { - // Gets first selected file - NSArray *files = [openDlg URLs]; - NSURL *saveURL = [files objectAtIndex:0]; - NSString *filePath = [saveURL path]; - - return filePath; - } - - return @""; -} - -// On create new session -+ (NSString*) ClassSaveFileDialog:(NSString *)title withArg2:(NSString *)path -{ - // Create a File Open Dialog class. - NSSavePanel* saveDlg = [NSSavePanel savePanel]; - [saveDlg setTitle:title]; - - NSFileManager *fm = [[NSFileManager alloc] init]; - BOOL isDir; - BOOL exists = [fm fileExistsAtPath:path isDirectory:&isDir]; - - if(!exists) - path = NSHomeDirectory(); - - [saveDlg setDirectoryURL : [NSURL fileURLWithPath:path]]; - - // Display the dialog box. If the OK pressed, - // process the files. - if ( [saveDlg runModal] == NSOKButton ) - { - // Gets list of all files selected - NSURL *saveURL = [saveDlg URL]; - NSString *filePath = [saveURL path]; - - return filePath; - } - - return @""; -} - -+ (NSString*) ClassChooseFolderDialog:(NSString *)title withArg2:(NSString *)path -{ - // Create a File Open Dialog class. - NSOpenPanel* openDlg = [NSOpenPanel openPanel]; - - [openDlg setCanChooseDirectories:YES]; - [openDlg setAllowsMultipleSelection:FALSE]; - [openDlg setTitle:title]; - - NSFileManager *fm = [[NSFileManager alloc] init]; - BOOL isDir; - BOOL exists = [fm fileExistsAtPath:path isDirectory:&isDir]; - - if(!exists) - path = NSHomeDirectory(); - - [openDlg setDirectoryURL : [NSURL fileURLWithPath:path]]; - - // Display the dialog box. If the OK pressed, - // process the files. - if ( [openDlg runModal] == NSOKButton ) - { - // Gets first selected file - NSArray *files = [openDlg URLs]; - NSURL *saveURL = [files objectAtIndex:0]; - NSString *filePath = [saveURL path]; - - return filePath; - } - - return @""; -} - -@end diff --git a/gtk2_ardour/OpenFileDialogProxy.h b/gtk2_ardour/OpenFileDialogProxy.h deleted file mode 100644 index c1da67ac7c..0000000000 --- a/gtk2_ardour/OpenFileDialogProxy.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// OpenFileDialogProxy.h -// Tracks -// -// Created by User on 5/12/14. -// -// - -#ifndef Tracks_OpenFileDialogProxy_h -#define Tracks_OpenFileDialogProxy_h - -#include - -namespace ARDOUR -{ - // This is the C "trampoline" function that will be used - // to invoke a specific Objective-C method FROM C++ - #ifdef __APPLE__ - std::string SaveFileDialog(std::string path = "", std::string title = "Save"); - std::string OpenFileDialog(std::string path = "", std::string title = "Open"); - std::string ChooseFolderDialog(std::string path = "", std::string title = "Choose Folder"); - #endif - - // OS Windows specific functions - #ifdef _WIN32 - 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 path = "", std::string title = "Choose Folder"); - #endif -} -#endif