2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2004-11-02 04:44:24 +00:00
|
|
|
#pragma implementation "BOINCTaskBar.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
2004-11-02 04:44:24 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
2008-11-04 16:51:31 +00:00
|
|
|
#include "BOINCClientManager.h"
|
2004-10-24 05:40:12 +00:00
|
|
|
#include "DlgAbout.h"
|
|
|
|
#include "Events.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2006-07-25 04:35:06 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
#include "res/macsnoozebadge.xpm"
|
|
|
|
#include "res/macdisconnectbadge.xpm"
|
2006-07-31 11:52:45 +00:00
|
|
|
#include "res/macbadgemask.xpm"
|
2006-07-25 04:35:06 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2006-10-30 03:41:32 +00:00
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_TASKBAR_RELOADSKIN)
|
2008-10-14 03:28:34 +00:00
|
|
|
DEFINE_EVENT_TYPE(wxEVT_TASKBAR_REFRESH)
|
2006-10-30 03:41:32 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
BEGIN_EVENT_TABLE(CTaskBarIcon, wxTaskBarIconEx)
|
2005-03-31 23:54:12 +00:00
|
|
|
EVT_IDLE(CTaskBarIcon::OnIdle)
|
|
|
|
EVT_CLOSE(CTaskBarIcon::OnClose)
|
2008-10-14 03:28:34 +00:00
|
|
|
EVT_TASKBAR_REFRESH(CTaskBarIcon::OnRefresh)
|
2006-11-22 09:51:59 +00:00
|
|
|
EVT_TASKBAR_RELOADSKIN(CTaskBarIcon::OnReloadSkin)
|
2005-03-31 23:54:12 +00:00
|
|
|
EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_OPEN, CTaskBarIcon::OnOpen)
|
2006-02-02 19:53:16 +00:00
|
|
|
EVT_MENU(ID_OPENWEBSITE, CTaskBarIcon::OnOpenWebsite)
|
2006-11-22 09:51:59 +00:00
|
|
|
EVT_MENU(ID_TB_SUSPEND, CTaskBarIcon::OnSuspendResume)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_ABOUT, CTaskBarIcon::OnAbout)
|
2006-11-23 00:52:21 +00:00
|
|
|
EVT_MENU(wxID_EXIT, CTaskBarIcon::OnExit)
|
2005-02-09 01:14:14 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
EVT_TASKBAR_SHUTDOWN(CTaskBarIcon::OnShutdown)
|
2004-10-25 10:20:43 +00:00
|
|
|
EVT_TASKBAR_MOVE(CTaskBarIcon::OnMouseMove)
|
2004-11-03 21:06:12 +00:00
|
|
|
EVT_TASKBAR_CONTEXT_MENU(CTaskBarIcon::OnContextMenu)
|
2004-11-23 07:45:11 +00:00
|
|
|
EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown)
|
|
|
|
EVT_TASKBAR_RIGHT_UP(CTaskBarIcon::OnRButtonUp)
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2006-11-22 09:51:59 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// wxMac-2.6.3 "helpfully" converts wxID_ABOUT to kHICommandAbout, wxID_EXIT to kHICommandQuit,
|
|
|
|
// wxID_PREFERENCES to kHICommandPreferences
|
|
|
|
EVT_MENU(kHICommandAbout, CTaskBarIcon::OnAbout)
|
|
|
|
#endif
|
|
|
|
END_EVENT_TABLE()
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
|
2006-07-05 21:35:59 +00:00
|
|
|
CTaskBarIcon::CTaskBarIcon(wxString title, wxIcon* icon, wxIcon* iconDisconnected, wxIcon* iconSnooze) :
|
2005-08-02 22:15:46 +00:00
|
|
|
#if defined(__WXMAC__)
|
2005-04-07 07:04:50 +00:00
|
|
|
wxTaskBarIcon(DOCK)
|
2005-08-02 22:15:46 +00:00
|
|
|
#elif defined(__WXMSW__)
|
2005-04-07 07:04:50 +00:00
|
|
|
wxTaskBarIconEx(wxT("BOINCManagerSystray"))
|
2005-08-02 22:15:46 +00:00
|
|
|
#else
|
|
|
|
wxTaskBarIcon()
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2006-07-05 21:35:59 +00:00
|
|
|
m_iconTaskBarNormal = *icon;
|
|
|
|
m_iconTaskBarDisconnected = *iconDisconnected;
|
|
|
|
m_iconTaskBarSnooze = *iconSnooze;
|
|
|
|
m_strDefaultTitle = title;
|
2007-05-10 15:41:10 +00:00
|
|
|
m_bTaskbarInitiatedShutdown = false;
|
2006-07-05 21:35:59 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
m_dtLastHoverDetected = wxDateTime((time_t)0);
|
2006-07-05 21:35:59 +00:00
|
|
|
|
|
|
|
m_bMouseButtonPressed = false;
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
CTaskBarIcon::~CTaskBarIcon() {
|
2004-10-23 07:13:18 +00:00
|
|
|
RemoveIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnIdle(wxIdleEvent& event) {
|
2005-03-31 23:54:12 +00:00
|
|
|
wxGetApp().UpdateSystemIdleDetection();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnClose(wxCloseEvent& event) {
|
2005-03-31 23:54:12 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnClose - Function Begin"));
|
|
|
|
|
2007-05-21 16:07:10 +00:00
|
|
|
RemoveIcon();
|
2007-05-10 15:41:10 +00:00
|
|
|
m_bTaskbarInitiatedShutdown = true;
|
2005-03-31 23:54:12 +00:00
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pFrame) {
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2005-03-31 23:54:12 +00:00
|
|
|
pFrame->Close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnClose - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-14 03:28:34 +00:00
|
|
|
void CTaskBarIcon::OnRefresh(CTaskbarEvent& WXUNUSED(event)) {
|
2006-07-05 21:35:59 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnRefresh - Function Begin"));
|
2006-02-21 21:38:55 +00:00
|
|
|
|
2008-10-14 12:35:48 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-08-31 19:24:38 +00:00
|
|
|
CC_STATUS status;
|
2006-02-21 21:38:55 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2006-07-05 21:35:59 +00:00
|
|
|
// What is the current status of the client?
|
2006-08-31 19:24:38 +00:00
|
|
|
pDoc->GetCoreClientStatus(status);
|
2006-07-05 21:35:59 +00:00
|
|
|
|
|
|
|
// Which icon should be displayed?
|
|
|
|
if (!pDoc->IsConnected()) {
|
2008-06-23 18:47:51 +00:00
|
|
|
SetIcon(m_iconTaskBarDisconnected);
|
2006-07-05 21:35:59 +00:00
|
|
|
} else {
|
2007-11-16 09:28:02 +00:00
|
|
|
if (RUN_MODE_NEVER == status.task_mode) {
|
2008-06-23 18:47:51 +00:00
|
|
|
SetIcon(m_iconTaskBarSnooze);
|
2006-07-05 21:35:59 +00:00
|
|
|
} else {
|
2008-06-23 18:47:51 +00:00
|
|
|
SetIcon(m_iconTaskBarNormal);
|
2006-07-05 21:35:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnRefresh - Function End"));
|
2006-02-21 21:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnLButtonDClick(wxTaskBarIconEvent& event) {
|
2005-03-31 23:54:12 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnLButtonDClick - Function Begin"));
|
|
|
|
|
|
|
|
wxCommandEvent eventCommand;
|
2005-04-07 07:04:50 +00:00
|
|
|
OnOpen(eventCommand);
|
|
|
|
if (eventCommand.GetSkipped()) event.Skip();
|
2005-03-31 23:54:12 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnLButtonDClick - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) {
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2005-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pFrame);
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pFrame) {
|
2004-10-24 05:40:12 +00:00
|
|
|
pFrame->Show();
|
2006-11-22 09:51:59 +00:00
|
|
|
|
2009-01-16 06:41:52 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
if (pFrame->IsIconized()) {
|
|
|
|
pFrame->Iconize(false);
|
|
|
|
}
|
|
|
|
#else
|
2005-04-30 00:23:54 +00:00
|
|
|
if (pFrame->IsMaximized()) {
|
|
|
|
pFrame->Maximize(true);
|
|
|
|
} else {
|
|
|
|
pFrame->Maximize(false);
|
|
|
|
}
|
2005-05-07 12:37:01 +00:00
|
|
|
#endif
|
2005-02-11 00:08:01 +00:00
|
|
|
pFrame->SendSizeEvent();
|
2008-02-06 17:20:23 +00:00
|
|
|
pFrame->Update();
|
2005-03-31 23:54:12 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
2005-04-07 07:04:50 +00:00
|
|
|
::SetForegroundWindow((HWND)pFrame->GetHandle());
|
2005-03-31 23:54:12 +00:00
|
|
|
#endif
|
2005-02-11 00:08:01 +00:00
|
|
|
}
|
2009-01-16 06:41:52 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
else {
|
|
|
|
wxGetApp().ShowCurrentGUI();
|
|
|
|
}
|
|
|
|
#endif
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-02 19:53:16 +00:00
|
|
|
void CTaskBarIcon::OnOpenWebsite(wxCommandEvent& WXUNUSED(event)) {
|
2006-12-21 17:05:58 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnOpenWebsite - Function Begin"));
|
2006-02-02 19:53:16 +00:00
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-02-02 19:53:16 +00:00
|
|
|
ACCT_MGR_INFO ami;
|
|
|
|
wxString url;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(pFrame);
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-02-02 19:53:16 +00:00
|
|
|
|
2006-12-21 17:05:58 +00:00
|
|
|
ResetTaskBar();
|
2006-02-02 19:53:16 +00:00
|
|
|
|
2006-12-21 17:05:58 +00:00
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
2006-03-23 01:17:07 +00:00
|
|
|
url = wxString(ami.acct_mgr_url.c_str(), wxConvUTF8);
|
2006-02-02 19:53:16 +00:00
|
|
|
pFrame->ExecuteBrowserLink(url);
|
2006-12-21 17:05:58 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnOpenWebsite - Function End"));
|
2006-02-02 19:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
void CTaskBarIcon::OnSuspendResume(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspendResume - Function Begin"));
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-08-31 19:24:38 +00:00
|
|
|
CC_STATUS status;
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-24 05:40:12 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2006-02-22 20:12:53 +00:00
|
|
|
ResetTaskBar();
|
|
|
|
|
2006-08-31 19:24:38 +00:00
|
|
|
pDoc->GetCoreClientStatus(status);
|
2006-12-21 17:05:58 +00:00
|
|
|
if (status.task_mode_perm != status.task_mode) {
|
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
|
2006-02-22 20:12:53 +00:00
|
|
|
} else {
|
2006-11-23 19:47:35 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
2006-02-21 21:38:55 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspendResume - Function End"));
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
|
- client: include precompiled header in rr_sim.cpp so memory
leak detection will work.
- MGR: Have the BaseFrame call a function to determine if the
selection list should be saved instead of traversing
the application pointer. Each view just overrides the function
returning a true/false value. We don't have to worry about null
pointers and the like.
- MGR: BOINCGUIApp should never need to know how either the views
work or the document. Move the code that determines which
RPCs should be fired into each of the views. Have the document
look for it there.
- MGR: Reduce duplicate code for hiding and showing an application
- MGR: Move some Windows and Mac specific code into functions
and streamline the application startup and shutdown rountines.
- MGR: Move the event processing that was in BOINCGUIApp into the
BaseFrame.
- MGR: General cleanup.
- MGR: Doxygen comments.
- MGR: Cleanup some warnings.
client/
rr_sim.cpp
clientgui/
AdvancedFrame.cpp, .h
AsyncRPC.cpp, .h
BOINCBaseFrame.cpp, .h
BOINCBaseView.cpp, .h
BOINCClientManager.cpp
BOINCGUIApp.cpp, .h
BOINCTaskBar.cpp
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp, .h
ViewProjects.cpp, .h
ViewTransfers.cpp, .h
ViewWork.cpp, .h
WelcomePage.cpp
win_build/installerv2/
BOINC.ism
BOINCx64.ism
win_build/
sim.vcproj
svn path=/trunk/boinc/; revision=16357
2008-10-29 22:44:55 +00:00
|
|
|
bool bWasVisible;
|
2005-07-06 05:16:53 +00:00
|
|
|
|
- client: include precompiled header in rr_sim.cpp so memory
leak detection will work.
- MGR: Have the BaseFrame call a function to determine if the
selection list should be saved instead of traversing
the application pointer. Each view just overrides the function
returning a true/false value. We don't have to worry about null
pointers and the like.
- MGR: BOINCGUIApp should never need to know how either the views
work or the document. Move the code that determines which
RPCs should be fired into each of the views. Have the document
look for it there.
- MGR: Reduce duplicate code for hiding and showing an application
- MGR: Move some Windows and Mac specific code into functions
and streamline the application startup and shutdown rountines.
- MGR: Move the event processing that was in BOINCGUIApp into the
BaseFrame.
- MGR: General cleanup.
- MGR: Doxygen comments.
- MGR: Cleanup some warnings.
client/
rr_sim.cpp
clientgui/
AdvancedFrame.cpp, .h
AsyncRPC.cpp, .h
BOINCBaseFrame.cpp, .h
BOINCBaseView.cpp, .h
BOINCClientManager.cpp
BOINCGUIApp.cpp, .h
BOINCTaskBar.cpp
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp, .h
ViewProjects.cpp, .h
ViewTransfers.cpp, .h
ViewWork.cpp, .h
WelcomePage.cpp
win_build/installerv2/
BOINC.ism
BOINCx64.ism
win_build/
sim.vcproj
svn path=/trunk/boinc/; revision=16357
2008-10-29 22:44:55 +00:00
|
|
|
bWasVisible = wxGetApp().IsApplicationVisible();
|
|
|
|
wxGetApp().ShowApplication(true);
|
2005-07-06 05:16:53 +00:00
|
|
|
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
CDlgAbout dlg(NULL);
|
|
|
|
dlg.ShowModal();
|
2005-07-06 05:16:53 +00:00
|
|
|
|
- client: include precompiled header in rr_sim.cpp so memory
leak detection will work.
- MGR: Have the BaseFrame call a function to determine if the
selection list should be saved instead of traversing
the application pointer. Each view just overrides the function
returning a true/false value. We don't have to worry about null
pointers and the like.
- MGR: BOINCGUIApp should never need to know how either the views
work or the document. Move the code that determines which
RPCs should be fired into each of the views. Have the document
look for it there.
- MGR: Reduce duplicate code for hiding and showing an application
- MGR: Move some Windows and Mac specific code into functions
and streamline the application startup and shutdown rountines.
- MGR: Move the event processing that was in BOINCGUIApp into the
BaseFrame.
- MGR: General cleanup.
- MGR: Doxygen comments.
- MGR: Cleanup some warnings.
client/
rr_sim.cpp
clientgui/
AdvancedFrame.cpp, .h
AsyncRPC.cpp, .h
BOINCBaseFrame.cpp, .h
BOINCBaseView.cpp, .h
BOINCClientManager.cpp
BOINCGUIApp.cpp, .h
BOINCTaskBar.cpp
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp, .h
ViewProjects.cpp, .h
ViewTransfers.cpp, .h
ViewWork.cpp, .h
WelcomePage.cpp
win_build/installerv2/
BOINC.ism
BOINCx64.ism
win_build/
sim.vcproj
svn path=/trunk/boinc/; revision=16357
2008-10-29 22:44:55 +00:00
|
|
|
if (!bWasVisible) {
|
|
|
|
wxGetApp().ShowApplication(false);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnExit(wxCommandEvent& event) {
|
2005-02-09 01:14:14 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnExit - Function Begin"));
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2007-06-24 09:24:52 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
if (wxGetApp().ConfirmExit())
|
|
|
|
#endif
|
|
|
|
{
|
2008-11-05 22:03:45 +00:00
|
|
|
#ifdef __WXMSW__
|
2008-11-06 00:08:44 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2008-11-05 16:07:12 +00:00
|
|
|
if (wxGetApp().ShouldShutdownCoreClient()) {
|
|
|
|
pDoc->m_pClientManager->EnableBOINCStartedByManager();
|
|
|
|
} else {
|
2008-11-04 16:51:31 +00:00
|
|
|
pDoc->m_pClientManager->DisableBOINCStartedByManager();
|
|
|
|
}
|
2008-11-05 22:03:45 +00:00
|
|
|
#endif
|
2008-11-04 16:51:31 +00:00
|
|
|
|
2006-11-03 15:18:19 +00:00
|
|
|
wxCloseEvent eventClose;
|
|
|
|
OnClose(eventClose);
|
|
|
|
if (eventClose.GetSkipped()) event.Skip();
|
|
|
|
}
|
2007-01-19 14:30:18 +00:00
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnExit - Function End"));
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
|
2006-11-22 11:53:17 +00:00
|
|
|
#ifdef __WXMSW__
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnShutdown(wxTaskBarIconExEvent& event) {
|
2005-02-09 01:14:14 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function Begin"));
|
|
|
|
|
|
|
|
wxCloseEvent eventClose;
|
2005-04-07 07:04:50 +00:00
|
|
|
OnClose(eventClose);
|
|
|
|
if (eventClose.GetSkipped()) event.Skip();
|
2005-02-09 01:14:14 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-23 18:47:51 +00:00
|
|
|
// Note: tooltip must not have a trailing linebreak.
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2004-11-04 05:34:51 +00:00
|
|
|
|
|
|
|
wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected);
|
2007-11-15 15:59:59 +00:00
|
|
|
if (tsLastHover.GetSeconds() >= 2) {
|
|
|
|
m_dtLastHoverDetected = wxDateTime::Now();
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2008-10-14 12:35:48 +00:00
|
|
|
wxString strMachineName = wxEmptyString;
|
2006-08-31 19:24:38 +00:00
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
wxString strProjectName = wxEmptyString;
|
2008-06-25 18:11:28 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
|
|
|
wxString strActiveTaskBuffer = wxEmptyString;
|
2006-08-31 19:24:38 +00:00
|
|
|
float fProgress = 0;
|
|
|
|
bool bIsActive = false;
|
|
|
|
bool bIsExecuting = false;
|
|
|
|
bool bIsDownloaded = false;
|
|
|
|
wxInt32 iResultCount = 0;
|
2008-06-25 18:11:28 +00:00
|
|
|
wxInt32 iActiveTaskCount = 0;
|
2006-08-31 19:24:38 +00:00
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
CC_STATUS status;
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2008-09-19 07:55:38 +00:00
|
|
|
if (!pDoc) return;
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
if (pDoc->IsConnected()) {
|
2008-06-25 18:11:28 +00:00
|
|
|
pDoc->GetConnectedComputerName(strMachineName);
|
|
|
|
|
|
|
|
// Only show machine name if connected to remote machine.
|
|
|
|
if (!pDoc->IsComputerNameLocal(strMachineName)) {
|
|
|
|
strMessage += strMachineName;
|
|
|
|
}
|
2004-11-04 05:34:51 +00:00
|
|
|
|
2006-08-31 19:24:38 +00:00
|
|
|
pDoc->GetCoreClientStatus(status);
|
2006-11-20 21:59:03 +00:00
|
|
|
if (status.task_suspend_reason && !(status.task_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) {
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
2008-06-25 18:11:28 +00:00
|
|
|
_("Computation is suspended.")
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2008-06-25 18:11:28 +00:00
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2005-11-27 01:28:56 +00:00
|
|
|
}
|
2005-09-09 08:47:33 +00:00
|
|
|
|
2006-11-20 21:59:03 +00:00
|
|
|
if (status.network_suspend_reason && !(status.network_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) {
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
2008-06-25 18:11:28 +00:00
|
|
|
_("Network activity is suspended.")
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2008-06-25 18:11:28 +00:00
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2005-11-27 01:28:56 +00:00
|
|
|
}
|
2005-09-09 08:47:33 +00:00
|
|
|
|
2007-01-19 17:52:48 +00:00
|
|
|
iResultCount = pDoc->GetWorkCount();
|
2005-11-27 01:28:56 +00:00
|
|
|
for (iIndex = 0; iIndex < iResultCount; iIndex++) {
|
2006-10-20 15:00:14 +00:00
|
|
|
RESULT* result = pDoc->result(iIndex);
|
2005-11-27 01:28:56 +00:00
|
|
|
RESULT* state_result = NULL;
|
|
|
|
std::string project_name;
|
|
|
|
|
|
|
|
bIsDownloaded = (result->state == RESULT_FILES_DOWNLOADED);
|
|
|
|
bIsActive = result->active_task;
|
|
|
|
bIsExecuting = (result->scheduler_state == CPU_SCHED_SCHEDULED);
|
|
|
|
if (!(bIsActive) || !(bIsDownloaded) || !(bIsExecuting)) continue;
|
|
|
|
|
2008-06-25 18:11:28 +00:00
|
|
|
// Increment the active task counter
|
|
|
|
iActiveTaskCount++;
|
|
|
|
|
|
|
|
// If we have more then two active tasks then we'll just be displaying
|
|
|
|
// the total number of active tasks anyway, so just look at the rest
|
|
|
|
// of the result records.
|
|
|
|
if (iActiveTaskCount > 2) continue;
|
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
if (result) {
|
2009-01-13 22:46:58 +00:00
|
|
|
state_result = pDoc->state.lookup_result(result->project_url, result->name);
|
2005-11-27 01:28:56 +00:00
|
|
|
if (state_result) {
|
|
|
|
state_result->project->get_name(project_name);
|
2009-04-23 03:40:49 +00:00
|
|
|
strProjectName = wxString(project_name.c_str(), wxConvUTF8);
|
2005-11-27 01:28:56 +00:00
|
|
|
}
|
2006-02-16 18:42:13 +00:00
|
|
|
fProgress = floor(result->fraction_done*10000)/100;
|
2005-06-13 08:47:51 +00:00
|
|
|
}
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2008-06-25 19:38:55 +00:00
|
|
|
strBuffer.Printf(_("%s: %.2f%% completed."), strProjectName.c_str(), fProgress );
|
2008-06-25 18:11:28 +00:00
|
|
|
if (strActiveTaskBuffer.Length() > 0) strActiveTaskBuffer += wxT("\n");
|
|
|
|
strActiveTaskBuffer += strBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iActiveTaskCount <= 2) {
|
2008-06-25 19:15:55 +00:00
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2008-06-25 18:11:28 +00:00
|
|
|
strMessage += strActiveTaskBuffer;
|
|
|
|
} else {
|
|
|
|
// More than two active tasks are running on the system, we don't have
|
|
|
|
// enough room to display them all, so just tell the user how many are
|
|
|
|
// currently running.
|
|
|
|
strBuffer.Printf(
|
2008-07-11 16:07:42 +00:00
|
|
|
_("%d tasks running."),
|
|
|
|
iActiveTaskCount
|
2008-06-25 18:11:28 +00:00
|
|
|
);
|
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2005-11-27 01:28:56 +00:00
|
|
|
strMessage += strBuffer;
|
|
|
|
}
|
2008-06-25 18:11:28 +00:00
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
} else if (pDoc->IsReconnecting()) {
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
2008-06-25 18:11:28 +00:00
|
|
|
_("Reconnecting to client.")
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2008-06-25 18:11:28 +00:00
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2005-11-27 01:28:56 +00:00
|
|
|
} else {
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
2008-06-25 18:11:28 +00:00
|
|
|
_("Not connected to a client.")
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2008-06-25 18:11:28 +00:00
|
|
|
if (strMessage.Length() > 0) strMessage += wxT("\n");
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
|
|
|
|
2008-06-23 18:47:51 +00:00
|
|
|
SetTooltip(strMessage);
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnContextMenu(wxTaskBarIconExEvent& WXUNUSED(event)) {
|
2006-11-22 09:51:59 +00:00
|
|
|
DisplayContextMenu();
|
2005-03-25 12:23:30 +00:00
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnRButtonDown(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!IsBalloonsSupported()) {
|
2006-07-05 21:35:59 +00:00
|
|
|
m_bMouseButtonPressed = true;
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnRButtonUp(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!IsBalloonsSupported()) {
|
2006-07-05 21:35:59 +00:00
|
|
|
if (m_bMouseButtonPressed) {
|
2006-11-22 09:51:59 +00:00
|
|
|
DisplayContextMenu();
|
2006-07-05 21:35:59 +00:00
|
|
|
m_bMouseButtonPressed = false;
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-22 11:53:17 +00:00
|
|
|
#endif
|
2004-11-03 21:06:12 +00:00
|
|
|
|
2006-02-22 20:12:53 +00:00
|
|
|
|
2006-11-22 21:26:21 +00:00
|
|
|
void CTaskBarIcon::OnReloadSkin(CTaskbarEvent& WXUNUSED(event)) {
|
2006-10-30 03:41:32 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
|
|
|
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
|
|
|
m_iconTaskBarNormal = *pSkinAdvanced->GetApplicationIcon();
|
|
|
|
m_iconTaskBarDisconnected = *pSkinAdvanced->GetApplicationDisconnectedIcon();
|
|
|
|
m_iconTaskBarSnooze = *pSkinAdvanced->GetApplicationSnoozeIcon();
|
2006-10-30 15:12:12 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxGetApp().GetMacSystemMenu()->BuildMenu();
|
|
|
|
#endif
|
2006-10-30 03:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::FireReloadSkin() {
|
|
|
|
CTaskbarEvent event(wxEVT_TASKBAR_RELOADSKIN, this);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::ResetTaskBar() {
|
2008-06-23 18:47:51 +00:00
|
|
|
SetIcon(m_iconTaskBarNormal);
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
|
|
|
// The mac version of WxWidgets will delete this menu when
|
|
|
|
// done with it; we must not delete it. See the comments
|
|
|
|
// in wxTaskBarIcon::PopupMenu() and DoCreatePopupMenu()
|
|
|
|
// in WxMac/src/mac/carbon/taskbar.cpp for details
|
|
|
|
|
|
|
|
// Overridables
|
2005-04-07 07:04:50 +00:00
|
|
|
wxMenu *CTaskBarIcon::CreatePopupMenu() {
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenu *menu = BuildContextMenu();
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
|
2006-07-06 12:58:27 +00:00
|
|
|
// Override the standard wxTaskBarIcon::SetIcon() because we are only providing a
|
|
|
|
// 16x16 icon for the menubar, while the Dock needs a 128x128 icon.
|
2006-07-25 04:35:06 +00:00
|
|
|
// Rather than using an entire separate icon, overlay the Dock icon with a badge
|
|
|
|
// so we don't need additional Snooze and Disconnected icons for branding.
|
2008-06-24 01:09:09 +00:00
|
|
|
bool CTaskBarIcon::SetIcon(const wxIcon& icon) {
|
2006-07-25 04:35:06 +00:00
|
|
|
wxIcon macIcon;
|
|
|
|
bool result;
|
|
|
|
OSStatus err = noErr ;
|
|
|
|
static const wxIcon* currentIcon = NULL;
|
2006-07-31 11:52:45 +00:00
|
|
|
int w, h, x, y;
|
2006-07-25 04:35:06 +00:00
|
|
|
|
|
|
|
if (&icon == currentIcon)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
currentIcon = &icon;
|
|
|
|
|
2008-07-24 10:18:31 +00:00
|
|
|
CMacSystemMenu* sysMenu = wxGetApp().GetMacSystemMenu();
|
|
|
|
if (sysMenu == NULL) return 0;
|
|
|
|
|
|
|
|
result = sysMenu->SetIcon(icon);
|
2006-07-25 04:35:06 +00:00
|
|
|
|
|
|
|
RestoreApplicationDockTileImage(); // Remove any previous badge
|
2007-01-18 10:01:35 +00:00
|
|
|
|
|
|
|
#if wxCHECK_VERSION(2,8,0)
|
|
|
|
if (m_iconTaskBarDisconnected.IsSameAs(icon))
|
|
|
|
macIcon = macdisconnectbadge;
|
|
|
|
else if (m_iconTaskBarSnooze.IsSameAs(icon))
|
|
|
|
macIcon = macsnoozebadge;
|
|
|
|
else
|
|
|
|
return result;
|
|
|
|
#else
|
2006-07-25 04:35:06 +00:00
|
|
|
if (icon == m_iconTaskBarDisconnected)
|
|
|
|
macIcon = macdisconnectbadge;
|
|
|
|
else if (icon == m_iconTaskBarSnooze)
|
|
|
|
macIcon = macsnoozebadge;
|
|
|
|
else
|
|
|
|
return result;
|
2007-01-18 10:01:35 +00:00
|
|
|
|
|
|
|
#endif
|
2006-07-25 04:35:06 +00:00
|
|
|
|
|
|
|
// Convert the wxIcon into a wxBitmap so we can perform some
|
|
|
|
// wxBitmap operations with it
|
|
|
|
wxBitmap bmp( macIcon ) ;
|
2006-07-31 12:06:30 +00:00
|
|
|
|
|
|
|
// wxMac's XMP image format always uses 32-bit pixels but allows only
|
|
|
|
// 1-bit masks, so we use a separate XMP file for the 8-bit mask to
|
|
|
|
// allow us to do proper anti-aliasing of the badges. This code assumes
|
|
|
|
// that all badges are the same size circle and at the same position so
|
|
|
|
// that they can share a single mask.
|
2006-07-31 11:52:45 +00:00
|
|
|
wxBitmap mask_bmp( macbadgemask ) ;
|
|
|
|
h = bmp.GetHeight();
|
|
|
|
w = bmp.GetWidth();
|
2006-07-25 04:35:06 +00:00
|
|
|
|
2006-07-31 11:52:45 +00:00
|
|
|
wxASSERT(h == mask_bmp.GetHeight());
|
|
|
|
wxASSERT(w == mask_bmp.GetWidth());
|
2006-07-25 04:35:06 +00:00
|
|
|
|
2006-07-31 11:52:45 +00:00
|
|
|
unsigned char * iconBuffer = (unsigned char *)bmp.GetRawAccess();
|
|
|
|
unsigned char * maskBuffer = (unsigned char *)mask_bmp.GetRawAccess() + 1;
|
|
|
|
|
|
|
|
for (y=0; y<h; y++) {
|
|
|
|
for (x=0; x<w; x++) {
|
|
|
|
*iconBuffer = 255 - *maskBuffer;
|
|
|
|
iconBuffer += 4;
|
|
|
|
maskBuffer += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CGImageRef pImage = (CGImageRef) bmp.CGImageCreate();
|
|
|
|
|
2006-07-25 04:35:06 +00:00
|
|
|
// Actually set the dock image
|
|
|
|
err = OverlayApplicationDockTileImage(pImage);
|
|
|
|
|
|
|
|
wxASSERT(err == 0);
|
|
|
|
|
|
|
|
// Free the CGImage
|
|
|
|
if (pImage != NULL)
|
|
|
|
CGImageRelease(pImage);
|
|
|
|
|
|
|
|
return result;
|
2006-07-06 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
#endif // ! __WXMAC__
|
2006-02-17 19:18:24 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
void CTaskBarIcon::DisplayContextMenu() {
|
|
|
|
ResetTaskBar();
|
2006-02-17 19:18:24 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
wxMenu* pMenu = BuildContextMenu();
|
|
|
|
PopupMenu(pMenu);
|
|
|
|
delete pMenu;
|
2005-03-25 12:23:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxMenu *CTaskBarIcon::BuildContextMenu() {
|
2006-02-02 19:53:16 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-11-22 09:51:59 +00:00
|
|
|
wxMenu* pMenu = new wxMenu;
|
|
|
|
wxString menuName = wxEmptyString;
|
2006-02-02 19:53:16 +00:00
|
|
|
ACCT_MGR_INFO ami;
|
2006-11-22 21:26:21 +00:00
|
|
|
bool is_acct_mgr_detected = false;
|
2006-02-02 19:53:16 +00:00
|
|
|
|
2006-02-21 21:38:55 +00:00
|
|
|
wxASSERT(pMenu);
|
2006-02-02 19:53:16 +00:00
|
|
|
wxASSERT(pDoc);
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-02-02 19:53:16 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2008-10-14 12:35:48 +00:00
|
|
|
// Prevent recursive entry of CMainDocument::RequestRPC()
|
|
|
|
if (!pDoc->WaitingForRPC()) {
|
|
|
|
// Account managers have a different menu arrangement
|
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
|
|
|
is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
|
|
|
|
}
|
|
|
|
|
2006-02-02 19:53:16 +00:00
|
|
|
if (is_acct_mgr_detected) {
|
|
|
|
menuName.Printf(
|
2006-02-17 19:18:24 +00:00
|
|
|
_("Open %s Web..."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-02 19:53:16 +00:00
|
|
|
);
|
2006-02-21 21:38:55 +00:00
|
|
|
pMenu->Append(ID_OPENWEBSITE, menuName, wxEmptyString);
|
2006-02-02 19:53:16 +00:00
|
|
|
}
|
2005-12-28 12:33:18 +00:00
|
|
|
|
|
|
|
menuName.Printf(
|
2006-02-17 19:18:24 +00:00
|
|
|
_("Open %s..."),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2006-02-21 21:38:55 +00:00
|
|
|
pMenu->Append(wxID_OPEN, menuName, wxEmptyString);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
pMenu->AppendSeparator();
|
|
|
|
|
2006-02-22 20:12:53 +00:00
|
|
|
pMenu->AppendCheckItem(ID_TB_SUSPEND, _("Snooze"), wxEmptyString);
|
2005-12-28 12:33:18 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
pMenu->AppendSeparator();
|
|
|
|
|
2005-12-28 12:33:18 +00:00
|
|
|
menuName.Printf(
|
|
|
|
_("&About %s..."),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
|
|
|
|
2006-02-21 21:38:55 +00:00
|
|
|
pMenu->Append(wxID_ABOUT, menuName, wxEmptyString);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
// These should be in Windows Task Bar Menu but not in Mac's Dock menu
|
|
|
|
pMenu->AppendSeparator();
|
2006-02-17 19:18:24 +00:00
|
|
|
|
2006-11-23 00:52:21 +00:00
|
|
|
pMenu->Append(wxID_EXIT, _("E&xit"), wxEmptyString);
|
2006-02-17 19:18:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-21 21:38:55 +00:00
|
|
|
AdjustMenuItems(pMenu);
|
2006-02-17 19:18:24 +00:00
|
|
|
|
2006-02-21 21:38:55 +00:00
|
|
|
return pMenu;
|
2005-03-25 12:23:30 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
|
|
|
|
void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
|
2006-08-31 19:24:38 +00:00
|
|
|
CC_STATUS status;
|
2006-11-22 09:51:59 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxMenuItem* pMenuItem = NULL;
|
|
|
|
wxFont font = wxNullFont;
|
|
|
|
size_t loc = 0;
|
2006-11-22 11:53:17 +00:00
|
|
|
bool is_dialog_detected = false;
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2005-03-25 12:23:30 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2006-11-23 00:52:21 +00:00
|
|
|
// BOINC Manager crashes if user selects "Exit" from taskbar menu while
|
|
|
|
// a dialog is open, so we must disable the "Exit" menu item if a dialog
|
2008-08-20 16:07:06 +00:00
|
|
|
// is open.
|
2006-11-23 00:52:21 +00:00
|
|
|
// On the Mac, the user can open multiple instances of the About dialog
|
|
|
|
// by repeatedly selecting "About" menu item from the taskbar, so we
|
|
|
|
// must also disable that item. For consistency with the Mac standard,
|
|
|
|
// we disable the entire taskbar menu when a modal dialog is open.
|
2008-08-20 16:07:06 +00:00
|
|
|
if (wxGetApp().IsModalDialogDisplayed()) {
|
2006-11-22 11:53:17 +00:00
|
|
|
is_dialog_detected = true;
|
2006-11-22 18:42:22 +00:00
|
|
|
}
|
2006-11-22 11:53:17 +00:00
|
|
|
|
|
|
|
for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) {
|
|
|
|
pMenuItem = pMenu->FindItemByPosition(loc);
|
2008-10-14 03:28:34 +00:00
|
|
|
if (is_dialog_detected && (pMenuItem->GetId() != wxID_OPEN)) {
|
2006-11-23 00:52:21 +00:00
|
|
|
pMenuItem->Enable(false);
|
|
|
|
} else {
|
|
|
|
pMenuItem->Enable(!(pMenuItem->IsSeparator()));
|
2006-11-22 09:51:59 +00:00
|
|
|
}
|
2005-07-06 05:16:53 +00:00
|
|
|
}
|
2006-11-22 09:51:59 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
// Wierd things happen with menus and wxWidgets on Windows when you try
|
2006-11-22 21:26:21 +00:00
|
|
|
// to change the font and use the system default as the baseline, so
|
|
|
|
// instead of fighting the system get the original font and tweak it
|
|
|
|
// a bit. It shouldn't hurt other platforms.
|
2006-11-22 09:51:59 +00:00
|
|
|
for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) {
|
|
|
|
pMenuItem = pMenu->FindItemByPosition(loc);
|
|
|
|
if (!pMenuItem->IsSeparator() && pMenuItem->IsEnabled()) {
|
|
|
|
pMenu->Remove(pMenuItem);
|
|
|
|
|
|
|
|
font = pMenuItem->GetFont();
|
|
|
|
if (pMenuItem->GetId() != wxID_OPEN) {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
|
|
|
} else {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
|
|
|
}
|
|
|
|
pMenuItem->SetFont(font);
|
|
|
|
|
|
|
|
pMenu->Insert(loc, pMenuItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2007-02-26 02:58:40 +00:00
|
|
|
|
2008-10-14 12:35:48 +00:00
|
|
|
// Prevent recursive entry of CMainDocument::RequestRPC()
|
|
|
|
if (pDoc->WaitingForRPC()) return;
|
|
|
|
|
2007-02-26 02:58:40 +00:00
|
|
|
pDoc->GetCoreClientStatus(status);
|
|
|
|
if (RUN_MODE_NEVER == status.task_mode) {
|
2007-09-05 02:55:29 +00:00
|
|
|
if (status.task_mode_perm == status.task_mode) {
|
|
|
|
pMenu->Check(ID_TB_SUSPEND, false);
|
|
|
|
pMenu->Enable(ID_TB_SUSPEND, false);
|
|
|
|
} else {
|
|
|
|
pMenu->Check(ID_TB_SUSPEND, true);
|
2008-10-14 03:28:34 +00:00
|
|
|
if (!is_dialog_detected) {
|
2007-09-05 02:55:29 +00:00
|
|
|
pMenu->Enable(ID_TB_SUSPEND, true);
|
2008-10-14 03:28:34 +00:00
|
|
|
}
|
2007-09-05 02:55:29 +00:00
|
|
|
}
|
2007-02-26 02:58:40 +00:00
|
|
|
} else {
|
|
|
|
pMenu->Check(ID_TB_SUSPEND, false);
|
2008-10-14 03:28:34 +00:00
|
|
|
if (!is_dialog_detected) {
|
2007-09-05 02:55:29 +00:00
|
|
|
pMenu->Enable(ID_TB_SUSPEND, true);
|
2008-10-14 03:28:34 +00:00
|
|
|
}
|
2007-02-26 02:58:40 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_531575eeaa = "$Id$";
|