Skip to content

Commit

Permalink
macOS: Start new instance option
Browse files Browse the repository at this point in the history
  • Loading branch information
allanrbo committed Oct 19, 2022
1 parent 0d53c3a commit 7c386f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)

project(filesremote VERSION 1.10 LANGUAGES CXX)
project(filesremote VERSION 1.11 LANGUAGES CXX)

SET(CMAKE_CXX_STANDARD 17)

Expand Down
24 changes: 23 additions & 1 deletion src/filemanagerframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ FileManagerFrame::FileManagerFrame(wxConfigBase *config) : wxFrame(
auto *menuBar = new wxMenuBar();
this->SetMenuBar(menuBar);

#ifdef __WXOSX__
auto *connections_menu = new wxMenu();
menuBar->Append(connections_menu, "&Connections");

connections_menu->Append(ID_START_NEW_INSTANCE, "&Start another instance\tCtrl+I",
"Start a separate instance of FilesRemote for connecting to another server");
this->Bind(wxEVT_MENU, [&](wxCommandEvent &event) {
string exePath = wxStandardPaths::Get().GetExecutablePath().ToStdString(wxMBConvUTF8());
string appBundlePath = regex_replace(exePath, regex("/Contents/MacOS/filesremote$"), "");

// This would be highly suspicious, so let's just drop it.
if (regex_search(appBundlePath, regex("\""))) {
return;
}

wxExecute(wxString::FromUTF8("/usr/bin/open -n \"" + appBundlePath + "\""), wxEXEC_ASYNC);
}, ID_START_NEW_INSTANCE);

connections_menu->Append(wxID_EXIT, "E&xit", "Quit this program");
// This item is also in the File menu, and binding is done there.
#endif

auto *file_menu = new wxMenu();
menuBar->Append(file_menu, "&File");

Expand Down Expand Up @@ -1425,7 +1447,7 @@ void FileManagerFrame::DownloadFileForEdit(string remote_path) {
#endif
string local_dir = normalize_path(local_path + "/..");
// TODO(allan): restrict permissions
// TODO(allan): handle local file creation error seperately from a connection errors
// TODO(allan): handle local file creation error separately from a connection errors
create_directories(localPathUnicode(local_dir));

this->sftp_thread_channel_->Put(SftpThreadCmdDownload{local_path, remote_path, true});
Expand Down
1 change: 1 addition & 0 deletions src/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define ID_RENAME 80
#define ID_MKDIR 90
#define ID_SUDO 100
#define ID_START_NEW_INSTANCE 110

#define ID_SFTP_THREAD_RESPONSE_CONNECTED 510
#define ID_SFTP_THREAD_RESPONSE_GET_DIR 520
Expand Down

0 comments on commit 7c386f3

Please sign in to comment.