From 2bc6dd124be85fbac814b70af6ea855e7fa3bbfd Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 22 Nov 2006 11:53:17 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=11564 --- checkin_notes | 15 +++++++++++++++ clientgui/BOINCGUIApp.cpp | 22 +++++++++------------- clientgui/BOINCTaskBar.cpp | 22 +++++++++++++++------- clientgui/Events.h | 4 ++++ clientgui/sg_ProjectsComponent.cpp | 8 ++++---- mac_build/boinc.xcodeproj/project.pbxproj | 2 +- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/checkin_notes b/checkin_notes index 1468c1c382..ac454a7e2d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -12887,3 +12887,18 @@ Rom 22 Nov 2006 sg_ProjectsComponent.cpp, .h sg_StatImageLoader.cpp SkinManager.cpp + +Charlie 22 Nov 2006 + - MGR: Fix bugs in adjusting taskbar menu items when modal dialog open: + - Disable wxID_ABOUT item to prevent opening multiple copies of + About dialog (a problem on the Mac, not on Windows.) + - Re-enable items when modal dialog is closed. + - MGR: Fix broken messages, Pause, Resume buttons on Simple GUI. + - Mac: Fix compiler errors and warnings. + - Mac: Use new modal dialog detection logic to block Quit from Dock. + + clientgui/ + BOINCGUIApp.cpp + BOINCTaskBar.cpp + Events.h + sg_ProjectsComponent.cpp diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 0e5fe98a2c..f71f086470 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -805,11 +805,17 @@ OSErr CBOINCGUIApp::QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEven Boolean isSame; ProcessInfoRec pInfo; FSSpec fileSpec; - WindowRef win; - WindowModality modality; OSStatus anErr; - anErr = AEGetAttributePtr(appleEvt, keyAddressAttr, typeProcessSerialNumber, + // Refuse to quit if a modal dialog is open. Search for the dialog + // by ID since all of BOINC Manager's dialog IDs are 10000. + // Unfortunately, I know of no way to disable the Quit item in our Dock menu + if (wxDynamicCast(wxWindow::FindWindowById(ID_ANYDIALOG), wxDialog)) { + SysBeep(4); + return userCanceledErr; + } + + anErr = AEGetAttributePtr(appleEvt, keyAddressAttr, typeProcessSerialNumber, &senderType, &SenderPSN, sizeof(SenderPSN), &actualSize); if (anErr == noErr) { @@ -827,16 +833,6 @@ OSErr CBOINCGUIApp::QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEven anErr = GetProcessInformation(&SenderPSN, &pInfo); - // Refuse to quit if a modal dialog is open - win = FrontWindow(); - if (win) { - GetWindowModality(win, &modality, NULL); - if (modality == kWindowModalityAppModal) { - SysBeep(4); - return userCanceledErr; - } - } - // Consider a Quit command from our Dock menu as coming from this application if (pInfo.processSignature != 'dock') { s_bSkipExitConfirmation = true; // Not from our app, our dock icon or our taskbar icon diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index 9f10726931..07ef2cfb3f 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -281,6 +281,7 @@ void CTaskBarIcon::OnExit(wxCommandEvent& event) { } +#ifdef __WXMSW__ void CTaskBarIcon::OnShutdown(wxTaskBarIconExEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function Begin")); @@ -435,6 +436,7 @@ void CTaskBarIcon::OnRButtonUp(wxTaskBarIconEvent& WXUNUSED(event)) { } } } +#endif void CTaskBarIcon::OnReloadSkin(CTaskbarEvent& /*event*/) { @@ -571,7 +573,6 @@ wxMenu *CTaskBarIcon::BuildContextMenu() { wxString menuName = wxEmptyString; ACCT_MGR_INFO ami; bool is_acct_mgr_detected = false; - bool is_dialog_detected = false; wxASSERT(pMenu); wxASSERT(pDoc); @@ -629,6 +630,7 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) { wxMenuItem* pMenuItem = NULL; wxFont font = wxNullFont; size_t loc = 0; + bool is_dialog_detected = false; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); @@ -645,12 +647,18 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) { // If a dialog is detected, we cannot allow the "Exit" menu item to be // enabled. So lets search for the dialog by ID since all of BOINC // Manager's dialog IDs are 10000. - if (wxDynamicCast(wxWindow::FindWindowById(ID_ANYDIALOG), wxDialog)) { - for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) { - pMenuItem = pMenu->FindItemByPosition(loc); - if (pMenuItem->GetId() == ID_TB_EXIT) { - pMenuItem->Enable(false); - } + if (wxDynamicCast(wxWindow::FindWindowById(ID_ANYDIALOG), wxDialog)) + is_dialog_detected = true; + + for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) { + pMenuItem = pMenu->FindItemByPosition(loc); + if (pMenuItem->GetId() == ID_TB_EXIT) { + pMenuItem->Enable(!is_dialog_detected); + } + // Prevent opening multiple instances of About Dialog + // (This is a problem on the Mac but not on Windows) + if (pMenuItem->GetId() == wxID_ABOUT) { + pMenuItem->Enable(!is_dialog_detected); } } diff --git a/clientgui/Events.h b/clientgui/Events.h index 4a935f6151..38fb74ca49 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -63,7 +63,11 @@ #define ID_TB_TIMER 6800 #define ID_TB_SUSPEND 6801 +#ifdef __WXMAC__ +#define ID_TB_EXIT wxID_EXIT +#else #define ID_TB_EXIT 6802 +#endif #define ID_LIST_BASE 7000 #define ID_LIST_PROJECTSVIEW 7000 #define ID_LIST_WORKVIEW 7001 diff --git a/clientgui/sg_ProjectsComponent.cpp b/clientgui/sg_ProjectsComponent.cpp index 8409790e2c..87228feb6b 100644 --- a/clientgui/sg_ProjectsComponent.cpp +++ b/clientgui/sg_ProjectsComponent.cpp @@ -147,7 +147,7 @@ void CProjectsComponent::CreateComponent() wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages")); btnMessages = new CLinkButton( this, - -1, + ID_SIMPLE_MESSAGES, *pSkinSimple->GetMessagesLink()->GetBitmap(), wxPoint(11,86), wxSize(70,20), @@ -158,7 +158,7 @@ void CProjectsComponent::CreateComponent() wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages")); btnAlertMessages = new CLinkButton( this, - -1, + ID_SIMPLE_MESSAGES_ALERT, *(pSkinSimple->GetMessagesAlertLink()->GetBitmap()), wxPoint(11,86), wxSize(70,20), @@ -176,7 +176,7 @@ void CProjectsComponent::CreateComponent() wxToolTip *ttPause = new wxToolTip(_("Stop all activity")); btnPause = new CLinkButton( this, - -1, + ID_SIMPLE_SUSPEND, *pSkinSimple->GetSuspendLink()->GetBitmap(), wxPoint(85,86), wxSize(59,20), @@ -188,7 +188,7 @@ void CProjectsComponent::CreateComponent() wxToolTip *ttResume = new wxToolTip(_("Resume activity")); btnResume = new CLinkButton( this, - -1, + ID_SIMPLE_RESUME, *(pSkinSimple->GetResumeLink()->GetBitmap()), wxPoint(85,86), wxSize(59,20), diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 075c5cf4ef..48c25d7f78 100755 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -904,7 +904,7 @@ AA8B6B24046C366200A80164 /* ss_logic.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ss_logic.h; path = ../client/ss_logic.h; sourceTree = SOURCE_ROOT; }; AAA31C97042157A800A80164 /* shmem.C */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = shmem.C; path = ../lib/shmem.C; sourceTree = SOURCE_ROOT; }; AAA31C98042157A800A80164 /* shmem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = shmem.h; path = ../lib/shmem.h; sourceTree = SOURCE_ROOT; }; - DD095EF107D87AE900362260 /* BOINCManager.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = BOINCManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DD095EF107D87AE900362260 /* BOINCManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BOINCManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; DD0C59580816573E00CEC5D7 /* mac_saver_module.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = mac_saver_module.cpp; path = ../clientgui/mac/mac_saver_module.cpp; sourceTree = SOURCE_ROOT; }; DD0C59590816573E00CEC5D7 /* Mac_Saver_ModuleView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Mac_Saver_ModuleView.h; path = ../clientgui/mac/Mac_Saver_ModuleView.h; sourceTree = SOURCE_ROOT; }; DD0C595A0816573E00CEC5D7 /* Mac_Saver_ModuleView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = Mac_Saver_ModuleView.m; path = ../clientgui/mac/Mac_Saver_ModuleView.m; sourceTree = SOURCE_ROOT; };