From 2d2fb26e2503ab3d6e604bc118ac8475f4b42ca1 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Tue, 8 Oct 2024 08:41:00 +0200 Subject: [PATCH] =?UTF-8?q?Add=20"Close=20and=20select=20files=E2=80=A6"?= =?UTF-8?q?=20menu=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to "Select files…" but automatically closes the current window. Fixes #24 --- source/CommandIDs.h | 1 + source/DiffWindow.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/source/CommandIDs.h b/source/CommandIDs.h index ce0a4ad..e799eb0 100644 --- a/source/CommandIDs.h +++ b/source/CommandIDs.h @@ -15,6 +15,7 @@ enum { MSG_FILE_OPEN = 'mOpn', + MSG_FILE_NEW = 'mNew', MSG_FILE_RELOAD = 'mRld', MSG_FILE_QUIT = 'mQit', MSG_FILE_DROPPED = 'mDrp', diff --git a/source/DiffWindow.cpp b/source/DiffWindow.cpp index 6f4a117..e0ef967 100644 --- a/source/DiffWindow.cpp +++ b/source/DiffWindow.cpp @@ -135,6 +135,12 @@ DiffWindow::MessageReceived(BMessage* message) } } break; + case MSG_FILE_NEW: + { + message->what = MSG_FILE_OPEN; + message->AddMessenger("killme", BMessenger(this)); + } // intentional fall-tru + case MSG_FILE_OPEN: { message->AddRect("window_frame", Frame()); @@ -204,6 +210,11 @@ DiffWindow::_CreateMainMenu(BMenuBar* menuBar) menuItem->SetTarget(this); fileMenu->AddItem(menuItem); + menuItem = new BMenuItem(B_TRANSLATE("Close and select files" B_UTF8_ELLIPSIS), + new BMessage(MSG_FILE_NEW), 'N'); + menuItem->SetTarget(this); + fileMenu->AddItem(menuItem); + menuItem = new BMenuItem(B_TRANSLATE("Switch files"), new BMessage(MSG_FILE_SWITCH), B_TAB); menuItem->SetTarget(this); fileMenu->AddItem(menuItem);