From 5e71c7b1e5b0572e1ac8f089dce2bf4a9cf695fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 16 Apr 2009 19:32:11 +0000 Subject: [PATCH] Patch by Obaro Ogbo (nastee) with small changes by myself: * Added "Close All in Workspace" menu item in the Window menu. The shortcut is 'Q', which is usually the Quit shortcut. Since Tracker prevents quitting via this shortcut, overriding it like this is ok, this was also discussed in the ticket #2833. I've tested that the existing functionality is not disturbed (ie Quit in the Settings panel still works, as does quitting Tracker via "hey Tracker quit"). I did not add the "Close All" menu item, since that feature is already available via DeskBar and when pressing the shift key before opening the Window menu. * I did change the additional short cut. As with "Clean Up" versus "Cleanup Up All", it's now consistently the shift key, which you have to press. Note to Obaro: The only other change was that one can set the target of the menu item to be "be_app", that way one avoids dispatching the message in the window. Thanks a lot for your work, Obaro! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30205 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/Commands.h | 1 + src/kits/tracker/ContainerWindow.cpp | 19 +++++++++++++------ src/kits/tracker/Tracker.cpp | 23 ++++++++++++++++++++++- src/kits/tracker/Tracker.h | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/kits/tracker/Commands.h b/src/kits/tracker/Commands.h index 698118b249..91aac36756 100644 --- a/src/kits/tracker/Commands.h +++ b/src/kits/tracker/Commands.h @@ -50,6 +50,7 @@ const uint32 kOpenSelection = 'Tosl'; const uint32 kOpenSelectionWith = 'Tosu'; const uint32 kCloseAllWindows = 'Tall'; const uint32 kCloseWindowAndChildren = 'Tcwc'; +const uint32 kCloseAllInWorkspace = 'Tciw'; // end external app messages diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 0ef1dd9f2e..9eb51e92eb 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -1784,9 +1784,9 @@ BContainerWindow::SetCloseItem(BMenu *menu) && (item = menu->FindItem(kCloseAllWindows)) == NULL) return; - if (modifiers() & B_OPTION_KEY) { + if (modifiers() & B_SHIFT_KEY) { item->SetLabel("Close All"); - item->SetShortcut('W', B_COMMAND_KEY | B_OPTION_KEY); + item->SetShortcut('W', B_COMMAND_KEY | B_SHIFT_KEY); item->SetTarget(be_app); item->SetMessage(new BMessage(kCloseAllWindows)); } else { @@ -1970,8 +1970,8 @@ BContainerWindow::AddWindowMenu(BMenu *menu) item->SetTarget(PoseView()); menu->AddItem(item); - item = new BMenuItem("Select"B_UTF8_ELLIPSIS, new BMessage(kShowSelectionWindow), - 'A', B_SHIFT_KEY); + item = new BMenuItem("Select"B_UTF8_ELLIPSIS, + new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY); item->SetTarget(PoseView()); menu->AddItem(item); @@ -1979,7 +1979,8 @@ BContainerWindow::AddWindowMenu(BMenu *menu) item->SetTarget(PoseView()); menu->AddItem(item); - item = new BMenuItem("Invert Selection", new BMessage(kInvertSelection), 'S'); + item = new BMenuItem("Invert Selection", new BMessage(kInvertSelection), + 'S'); item->SetTarget(PoseView()); menu->AddItem(item); @@ -1994,9 +1995,15 @@ BContainerWindow::AddWindowMenu(BMenu *menu) item->SetTarget(this); menu->AddItem(item); + item = new BMenuItem("Close All in Workspace", + new BMessage(kCloseAllInWorkspace), 'Q'); + item->SetTarget(be_app); + menu->AddItem(item); + menu->AddSeparatorItem(); - item = new BMenuItem("Preferences"B_UTF8_ELLIPSIS, new BMessage(kShowSettingsWindow)); + item = new BMenuItem("Preferences"B_UTF8_ELLIPSIS, + new BMessage(kShowSettingsWindow)); item->SetTarget(be_app); menu->AddItem(item); } diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index e4863987ed..36bc458d19 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -402,6 +402,10 @@ TTracker::MessageReceived(BMessage *message) CloseAllWindows(); break; + case kCloseAllInWorkspace: + CloseAllInWorkspace(); + break; + case kFindButton: (new FindWindow())->Show(); break; @@ -854,7 +858,6 @@ TTracker::ArgvReceived(int32 argc, char **argv) } } - void TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, @@ -1189,6 +1192,24 @@ TTracker::CloseWindowAndChildren(const node_ref *node) } +void +TTracker::CloseAllInWorkspace() +{ + AutoLock lock(&fWindowList); + + int32 currentWorkspace = 1 << current_workspace(); + // count from end to beginning so we can remove items safely + for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { + BWindow *window = fWindowList.ItemAt(index); + if (window->Workspaces() & currentWorkspace) + // avoid the desktop + if (!dynamic_cast(window) + && !dynamic_cast(window)) + window->PostMessage(B_QUIT_REQUESTED); + } +} + + void TTracker::CloseAllWindows() { diff --git a/src/kits/tracker/Tracker.h b/src/kits/tracker/Tracker.h index c4f5eac148..2269fb1e6f 100644 --- a/src/kits/tracker/Tracker.h +++ b/src/kits/tracker/Tracker.h @@ -192,6 +192,7 @@ class TTracker : public BApplication { void CloseAllWindows(); void CloseWindowAndChildren(const node_ref *); + void CloseAllInWorkspace(); void OpenInfoWindows(BMessage*); void MoveRefsToTrash(const BMessage *); void OpenContainerWindow(Model *, BMessage *refsList = NULL,