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"
|
2010-03-02 13:09:06 +00:00
|
|
|
#include "DlgEventLog.h"
|
2004-10-24 05:40:12 +00:00
|
|
|
#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"
|
2010-04-05 08:49:43 +00:00
|
|
|
|
|
|
|
#define MIN_IDLE_TIME_FOR_NOTIFICATION 45
|
2010-04-01 11:09:33 +00:00
|
|
|
// How long to bounce Dock icon on Mac
|
2011-03-04 02:15:32 +00:00
|
|
|
#define MAX_NOTIFICATION_DURATION 5
|
2010-07-23 15:25:39 +00:00
|
|
|
#endif
|
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)
|
2009-12-18 22:44:10 +00:00
|
|
|
|
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)
|
2010-02-09 02:47:38 +00:00
|
|
|
#ifndef __WXMAC__
|
2010-02-05 20:24:28 +00:00
|
|
|
EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown)
|
|
|
|
EVT_TASKBAR_RIGHT_UP(CTaskBarIcon::OnRButtonUp)
|
2010-02-11 04:12:16 +00:00
|
|
|
EVT_TASKBAR_CONTEXT_USERCLICK(CTaskBarIcon::OnNotificationClick)
|
2012-10-19 19:36:46 +00:00
|
|
|
EVT_TASKBAR_BALLOON_USERTIMEOUT(CTaskBarIcon::OnNotificationTimeout)
|
2010-02-09 02:47:38 +00:00
|
|
|
#endif
|
2010-02-05 22:29:06 +00:00
|
|
|
EVT_MENU(ID_OPENBOINCMANAGER, 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)
|
2009-12-11 00:08:28 +00:00
|
|
|
EVT_MENU(ID_TB_SUSPEND_GPU, CTaskBarIcon::OnSuspendResumeGPU)
|
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)
|
2010-10-18 19:21:46 +00:00
|
|
|
EVT_TASKBAR_APPRESTORE(CTaskBarIcon::OnAppRestore)
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2009-12-18 22:44:10 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
END_EVENT_TABLE()
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
|
2014-02-14 21:05:42 +00:00
|
|
|
CTaskBarIcon::CTaskBarIcon(wxString title, wxIconBundle* icon, wxIconBundle* iconDisconnected, wxIconBundle* iconSnooze
|
2010-04-01 11:09:33 +00:00
|
|
|
#ifdef __WXMAC__
|
2013-08-23 12:02:06 +00:00
|
|
|
, wxTaskBarIconType iconType
|
|
|
|
#endif
|
|
|
|
) :
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxTaskBarIcon(iconType)
|
2010-02-06 07:43:09 +00:00
|
|
|
#else
|
2009-12-18 22:44:10 +00:00
|
|
|
wxTaskBarIconEx(wxT("BOINCManagerSystray"), 1)
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2014-02-19 15:19:24 +00:00
|
|
|
m_iconTaskBarNormal = icon->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
|
|
|
m_iconTaskBarDisconnected = iconDisconnected->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
|
|
|
m_iconTaskBarSnooze = iconSnooze->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeGPUMenuItem = NULL;
|
2010-02-11 05:57:36 +00:00
|
|
|
|
2007-05-10 15:41:10 +00:00
|
|
|
m_bTaskbarInitiatedShutdown = false;
|
2006-07-05 21:35:59 +00:00
|
|
|
|
|
|
|
m_bMouseButtonPressed = false;
|
2010-03-29 17:20:12 +00:00
|
|
|
|
|
|
|
m_dtLastNotificationAlertExecuted = wxDateTime((time_t)0);
|
2011-03-07 16:06:26 +00:00
|
|
|
m_iLastNotificationUnreadMessageCount = 0;
|
2010-04-01 11:09:33 +00:00
|
|
|
#ifdef __WXMAC__
|
2013-08-23 12:02:06 +00:00
|
|
|
m_iconType = iconType;
|
2010-04-01 11:09:33 +00:00
|
|
|
m_pNotificationRequest = NULL;
|
|
|
|
#endif
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-07 17:41:34 +00:00
|
|
|
void CTaskBarIcon::OnClose(wxCloseEvent& ) {
|
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
|
|
|
|
2010-03-29 17:20:12 +00:00
|
|
|
CDlgEventLog* pEventLog = wxGetApp().GetEventLog();
|
|
|
|
if (pEventLog) {
|
2010-08-05 16:42:55 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CTaskBarIcon::OnClose - Closing Event Log"));
|
2010-07-22 10:59:26 +00:00
|
|
|
pEventLog->Destroy();
|
2010-03-02 13:09:06 +00:00
|
|
|
}
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pFrame) {
|
2010-08-05 16:42:55 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CTaskBarIcon::OnClose - Closing Current Frame"));
|
2005-03-31 23:54:12 +00:00
|
|
|
pFrame->Close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-03-29 17:20:12 +00:00
|
|
|
UpdateTaskbarStatus();
|
|
|
|
UpdateNoticeStatus();
|
2010-02-11 05:01:07 +00:00
|
|
|
|
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"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-18 22:44:10 +00:00
|
|
|
void CTaskBarIcon::OnNotificationClick(wxTaskBarIconExEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationClick - Function Begin"));
|
|
|
|
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2009-12-18 22:44:10 +00:00
|
|
|
wxGetApp().ShowNotifications();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2009-12-18 22:44:10 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationClick - Function End"));
|
|
|
|
}
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
|
2010-07-22 20:55:39 +00:00
|
|
|
void CTaskBarIcon::OnNotificationTimeout(wxTaskBarIconExEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationTimeout - Function Begin"));
|
|
|
|
|
|
|
|
ResetTaskBar();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnNotificationTimeout - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-18 22:44:10 +00:00
|
|
|
void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnOpen - Function Begin"));
|
2005-03-31 23:54:12 +00:00
|
|
|
|
2009-12-18 22:44:10 +00:00
|
|
|
ResetTaskBar();
|
|
|
|
wxGetApp().ShowInterface();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnOpen - Function End"));
|
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();
|
|
|
|
ACCT_MGR_INFO ami;
|
|
|
|
wxString url;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
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);
|
2009-12-19 05:16:41 +00:00
|
|
|
wxLaunchDefaultBrowser(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;
|
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);
|
2012-01-27 13:02:35 +00:00
|
|
|
if (status.task_mode_perm == RUN_MODE_NEVER) {
|
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
|
|
|
|
} else if (status.task_mode_perm != status.task_mode) {
|
2006-12-21 17:05:58 +00:00
|
|
|
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-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
|
|
|
}
|
|
|
|
|
2009-12-11 00:08:28 +00:00
|
|
|
void CTaskBarIcon::OnSuspendResumeGPU(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspendResumeGPU - Function Begin"));
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CC_STATUS status;
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2009-12-11 00:08:28 +00:00
|
|
|
ResetTaskBar();
|
|
|
|
pDoc->GetCoreClientStatus(status);
|
2012-01-27 13:02:35 +00:00
|
|
|
if (status.gpu_mode_perm == RUN_MODE_NEVER) {
|
|
|
|
pDoc->SetGPURunMode(RUN_MODE_RESTORE, 0);
|
|
|
|
} else if (status.gpu_mode_perm != status.gpu_mode) {
|
2009-12-11 00:08:28 +00:00
|
|
|
pDoc->SetGPURunMode(RUN_MODE_RESTORE, 0);
|
|
|
|
} else {
|
|
|
|
pDoc->SetGPURunMode(RUN_MODE_NEVER, 3600);
|
|
|
|
}
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspendResumeGPU - Function End"));
|
|
|
|
}
|
2009-12-18 22:44:10 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
|
2012-02-17 13:59:57 +00:00
|
|
|
bool bWasVisible = wxGetApp().IsApplicationVisible();
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
bool bEventLogWasShown = false;
|
2005-07-06 05:16:53 +00:00
|
|
|
|
2012-02-17 13:59:57 +00:00
|
|
|
CDlgEventLog* eventLog = wxGetApp().GetEventLog();
|
|
|
|
if (eventLog) {
|
|
|
|
bEventLogWasShown = eventLog->IsShown();
|
|
|
|
if (bEventLogWasShown && !bWasVisible) eventLog->Show(false);
|
|
|
|
}
|
2014-03-13 13:39:00 +00:00
|
|
|
|
2013-08-27 01:28:04 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
if (pFrame) {
|
2013-08-28 05:38:00 +00:00
|
|
|
if (!bWasVisible) {
|
2014-03-13 13:39:00 +00:00
|
|
|
// We really do need to hide the frame here
|
|
|
|
// See comment in CBOINCGUIApp::OnFinishInit()
|
|
|
|
pFrame->wxFrame::Show(false);
|
2013-08-27 01:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-17 13:59:57 +00:00
|
|
|
#endif
|
|
|
|
|
- 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
|
|
|
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);
|
2013-08-28 05:38:00 +00:00
|
|
|
wxGetApp().SetAboutDialogIsOpen(true);
|
2006-11-22 09:51:59 +00:00
|
|
|
dlg.ShowModal();
|
2013-08-28 05:38:00 +00:00
|
|
|
wxGetApp().SetAboutDialogIsOpen(false);
|
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
|
|
|
}
|
2014-03-13 13:39:00 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// See comment in CBOINCGUIApp::OnFinishInit()
|
|
|
|
pFrame->wxWindow::Show(true);
|
|
|
|
#endif
|
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
|
|
|
|
2015-06-10 07:38:31 +00:00
|
|
|
if (wxGetApp().ConfirmExit()) {
|
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
|
|
|
|
2010-02-09 02:47:38 +00:00
|
|
|
#ifndef __WXMAC__
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnRButtonDown(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2010-02-10 20:08:20 +00:00
|
|
|
m_bMouseButtonPressed = true;
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnRButtonUp(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2010-02-10 20:08:20 +00:00
|
|
|
if (m_bMouseButtonPressed) {
|
|
|
|
DisplayContextMenu();
|
|
|
|
m_bMouseButtonPressed = false;
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-09 02:47:38 +00:00
|
|
|
#endif // #ifndef __WXMAC__
|
2010-02-05 20:27:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
2011-03-07 15:19:39 +00:00
|
|
|
|
2010-02-05 20:27:17 +00:00
|
|
|
void CTaskBarIcon::OnShutdown(wxTaskBarIconExEvent& event) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function Begin"));
|
|
|
|
|
|
|
|
wxCloseEvent eventClose;
|
|
|
|
OnClose(eventClose);
|
|
|
|
if (eventClose.GetSkipped()) event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function End"));
|
|
|
|
}
|
2011-03-07 15:19:39 +00:00
|
|
|
|
|
|
|
void CTaskBarIcon::OnAppRestore(wxTaskBarIconExEvent&) {
|
2010-10-18 19:21:46 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnAppRestore - Function Begin"));
|
|
|
|
|
|
|
|
ResetTaskBar();
|
|
|
|
wxGetApp().ShowInterface();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnAppRestore - Function End"));
|
|
|
|
}
|
2011-03-07 15:19:39 +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));
|
|
|
|
|
2014-02-19 15:19:24 +00:00
|
|
|
m_iconTaskBarNormal = pSkinAdvanced->GetApplicationIcon()->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
|
|
|
m_iconTaskBarDisconnected = pSkinAdvanced->GetApplicationDisconnectedIcon()->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
|
|
|
m_iconTaskBarSnooze = pSkinAdvanced->GetApplicationSnoozeIcon()->GetIcon(GetBestIconSize(), wxIconBundle::FALLBACK_NEAREST_LARGER);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-19 15:19:24 +00:00
|
|
|
wxSize CTaskBarIcon::GetBestIconSize() {
|
|
|
|
wxSize size;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
size = wxSize(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X), wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y));
|
|
|
|
#else
|
|
|
|
size = wxSize(16, 16);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-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.
|
2010-02-09 02:47:38 +00:00
|
|
|
bool CTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& ) {
|
2006-07-25 04:35:06 +00:00
|
|
|
wxIcon macIcon;
|
|
|
|
bool result;
|
|
|
|
OSStatus err = noErr ;
|
2006-07-31 11:52:45 +00:00
|
|
|
int w, h, x, y;
|
2006-07-25 04:35:06 +00:00
|
|
|
|
2013-08-23 12:02:06 +00:00
|
|
|
if (m_iconType != wxTBI_DOCK) {
|
|
|
|
result = wxGetApp().GetMacDockIcon()->SetIcon(icon);
|
|
|
|
return (result && wxTaskBarIcon::SetIcon(icon));
|
|
|
|
}
|
|
|
|
|
2010-02-12 00:55:37 +00:00
|
|
|
if (icon.IsSameAs(m_iconCurrentIcon))
|
2006-07-25 04:35:06 +00:00
|
|
|
return true;
|
|
|
|
|
2010-02-12 00:55:37 +00:00
|
|
|
m_iconCurrentIcon = icon;
|
2006-07-25 04:35:06 +00:00
|
|
|
|
|
|
|
RestoreApplicationDockTileImage(); // Remove any previous badge
|
2007-01-18 10:01:35 +00:00
|
|
|
|
|
|
|
if (m_iconTaskBarDisconnected.IsSameAs(icon))
|
|
|
|
macIcon = macdisconnectbadge;
|
|
|
|
else if (m_iconTaskBarSnooze.IsSameAs(icon))
|
|
|
|
macIcon = macsnoozebadge;
|
|
|
|
else
|
2013-08-23 12:02:06 +00:00
|
|
|
return true;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-16 19:56:34 +00:00
|
|
|
CGImageRef pImage = (CGImageRef) bmp.CreateCGImage();
|
2006-07-31 11:52:45 +00:00
|
|
|
|
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);
|
|
|
|
|
2013-08-23 12:02:06 +00:00
|
|
|
return true;
|
2006-07-06 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
2010-04-01 11:09:33 +00:00
|
|
|
|
|
|
|
// wxTopLevel::RequestUserAttention() doesn't have an API to cancel
|
|
|
|
// after a timeout, so we must call Notification Manager directly on Mac
|
|
|
|
void CTaskBarIcon::MacRequestUserAttention()
|
|
|
|
{
|
2017-02-25 12:56:36 +00:00
|
|
|
m_pNotificationRequest = (NMRecPtr)malloc(sizeof(NMRec));
|
|
|
|
bzero(m_pNotificationRequest, sizeof(NMRec));
|
2010-04-01 11:09:33 +00:00
|
|
|
m_pNotificationRequest->qType = nmType ;
|
|
|
|
m_pNotificationRequest->nmMark = 1;
|
|
|
|
|
|
|
|
NMInstall(m_pNotificationRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTaskBarIcon::MacCancelUserAttentionRequest()
|
|
|
|
{
|
|
|
|
if (m_pNotificationRequest) {
|
|
|
|
NMRemove(m_pNotificationRequest);
|
2017-02-25 12:56:36 +00:00
|
|
|
free(m_pNotificationRequest);
|
2010-04-01 11:09:33 +00:00
|
|
|
m_pNotificationRequest = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
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()
|
2014-10-02 10:04:39 +00:00
|
|
|
if (!pDoc->WaitingForRPC()) {
|
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
// Account managers have a different menu arrangement
|
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
|
|
|
is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
|
|
|
|
}
|
2008-10-14 12:35:48 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
);
|
2010-02-05 22:29:06 +00:00
|
|
|
pMenu->Append(ID_OPENBOINCMANAGER, menuName, wxEmptyString);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
pMenu->AppendSeparator();
|
|
|
|
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeMenuItem = pMenu->AppendCheckItem(ID_TB_SUSPEND, _("Snooze"), wxEmptyString);
|
2013-01-19 19:16:44 +00:00
|
|
|
if (pDoc->state.have_gpu()) {
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeGPUMenuItem = pMenu->AppendCheckItem(ID_TB_SUSPEND_GPU, _("Snooze GPU"), wxEmptyString);
|
2009-12-10 23:26:35 +00:00
|
|
|
}
|
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
|
|
|
|
2013-08-23 12:02:06 +00:00
|
|
|
#ifdef __WXMAC__
|
2006-11-22 09:51:59 +00:00
|
|
|
// These should be in Windows Task Bar Menu but not in Mac's Dock menu
|
2013-08-23 12:02:06 +00:00
|
|
|
if (m_iconType != wxTBI_DOCK)
|
2006-02-17 19:18:24 +00:00
|
|
|
#endif
|
2013-08-23 12:02:06 +00:00
|
|
|
{
|
|
|
|
pMenu->AppendSeparator();
|
|
|
|
pMenu->Append(wxID_EXIT, _("E&xit"), wxEmptyString);
|
|
|
|
}
|
2006-02-17 19:18:24 +00:00
|
|
|
|
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;
|
2015-04-08 05:48:59 +00:00
|
|
|
bool enableSnoozeItems = 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
|
|
|
}
|
2015-04-08 05:48:59 +00:00
|
|
|
|
|
|
|
enableSnoozeItems = (!is_dialog_detected) && pDoc->IsConnected();
|
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);
|
2013-11-05 13:47:27 +00:00
|
|
|
pMenu->Remove(pMenuItem);
|
2006-11-22 09:51:59 +00:00
|
|
|
|
2013-11-05 13:47:27 +00:00
|
|
|
font = pMenuItem->GetFont();
|
|
|
|
font.SetPointSize(8);
|
|
|
|
if (pMenuItem->GetId() != ID_OPENBOINCMANAGER) {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
|
|
|
} else {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
2006-11-22 09:51:59 +00:00
|
|
|
}
|
2013-11-05 13:47:27 +00:00
|
|
|
pMenuItem->SetFont(font);
|
|
|
|
|
|
|
|
pMenu->Insert(loc, pMenuItem);
|
2006-11-22 09:51:59 +00:00
|
|
|
}
|
|
|
|
#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);
|
2009-12-10 23:26:35 +00:00
|
|
|
switch (status.task_mode) {
|
|
|
|
case RUN_MODE_NEVER:
|
|
|
|
switch (status.task_mode_perm) {
|
|
|
|
case RUN_MODE_NEVER:
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeMenuItem->SetItemLabel(_("Resume"));
|
|
|
|
m_SnoozeMenuItem->Check(false);
|
2015-04-08 05:48:59 +00:00
|
|
|
m_SnoozeMenuItem->Enable(enableSnoozeItems);
|
2009-12-10 23:26:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeMenuItem->SetItemLabel(_("Snooze"));
|
|
|
|
m_SnoozeMenuItem->Check(true);
|
2007-09-05 02:55:29 +00:00
|
|
|
}
|
2009-12-10 23:26:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeMenuItem->SetItemLabel(_("Snooze"));
|
|
|
|
m_SnoozeMenuItem->Check(false);
|
|
|
|
}
|
2015-04-08 05:48:59 +00:00
|
|
|
m_SnoozeMenuItem->Enable(enableSnoozeItems);
|
2012-01-27 13:02:35 +00:00
|
|
|
|
2013-01-19 19:16:44 +00:00
|
|
|
if (pDoc->state.have_gpu()) {
|
2012-01-27 13:02:35 +00:00
|
|
|
switch (status.gpu_mode) {
|
|
|
|
case RUN_MODE_NEVER:
|
|
|
|
switch (status.gpu_mode_perm) {
|
2009-12-10 23:26:35 +00:00
|
|
|
case RUN_MODE_NEVER:
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeGPUMenuItem->SetItemLabel(_("Resume GPU"));
|
|
|
|
m_SnoozeGPUMenuItem->Check(false);
|
2009-12-10 23:26:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-27 13:02:35 +00:00
|
|
|
m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU"));
|
|
|
|
m_SnoozeGPUMenuItem->Check(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU"));
|
|
|
|
m_SnoozeGPUMenuItem->Check(false);
|
|
|
|
break;
|
|
|
|
}
|
2013-01-19 19:16:44 +00:00
|
|
|
if (status.task_mode == RUN_MODE_NEVER) {
|
2015-11-02 09:42:26 +00:00
|
|
|
bool check_gpu_snooze = false;
|
|
|
|
if (status.task_mode_perm != RUN_MODE_NEVER) check_gpu_snooze = true;
|
|
|
|
if ((status.gpu_mode == RUN_MODE_NEVER) && (status.gpu_mode_perm != RUN_MODE_NEVER)) {
|
|
|
|
check_gpu_snooze = true;
|
|
|
|
}
|
|
|
|
m_SnoozeGPUMenuItem->Check(check_gpu_snooze);
|
2013-01-19 19:16:44 +00:00
|
|
|
m_SnoozeGPUMenuItem->Enable(false);
|
2015-11-02 09:42:26 +00:00
|
|
|
} else {
|
2015-11-01 15:14:07 +00:00
|
|
|
m_SnoozeGPUMenuItem->Enable(enableSnoozeItems);
|
|
|
|
}
|
2007-02-26 02:58:40 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-29 17:20:12 +00:00
|
|
|
|
|
|
|
void CTaskBarIcon::UpdateTaskbarStatus() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::UpdateTaskbarStatus - Function Begin"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CC_STATUS status;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
pDoc->GetCoreClientStatus(status);
|
2010-03-30 01:40:04 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__ // Mac Taskbar Icon does not support tooltips
|
|
|
|
// Which icon should be displayed?
|
|
|
|
if (!pDoc->IsConnected()) {
|
|
|
|
SetIcon(m_iconTaskBarDisconnected);
|
|
|
|
} else {
|
2013-08-10 06:23:32 +00:00
|
|
|
switch(status.task_suspend_reason) {
|
|
|
|
case SUSPEND_REASON_CPU_THROTTLE:
|
|
|
|
case 0:
|
2010-03-30 01:40:04 +00:00
|
|
|
SetIcon(m_iconTaskBarNormal);
|
2013-08-10 06:23:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetIcon(m_iconTaskBarSnooze);
|
2010-03-30 01:40:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
wxString strMachineName = wxEmptyString;
|
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
wxIcon icnIcon;
|
|
|
|
|
2010-03-29 17:20:12 +00:00
|
|
|
pDoc->GetConnectedComputerName(strMachineName);
|
|
|
|
|
|
|
|
if (!pDoc->IsComputerNameLocal(strMachineName)) {
|
|
|
|
strMessage += strMachineName;
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += wxT("\n");
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
icnIcon = m_iconTaskBarNormal;
|
2010-05-14 03:19:31 +00:00
|
|
|
bool comp_suspended = false;
|
2010-05-12 18:14:30 +00:00
|
|
|
switch(status.task_suspend_reason) {
|
|
|
|
case SUSPEND_REASON_CPU_THROTTLE:
|
|
|
|
case 0:
|
|
|
|
strMessage += _("Computing is enabled");
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-10 06:23:32 +00:00
|
|
|
icnIcon = m_iconTaskBarSnooze;
|
2010-05-12 18:23:03 +00:00
|
|
|
strMessage += _("Computing is suspended - ");
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += suspend_reason_wxstring(status.task_suspend_reason);
|
2010-05-14 03:19:31 +00:00
|
|
|
comp_suspended = true;
|
2010-05-12 18:14:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
strMessage += wxT(".\n");
|
|
|
|
|
2013-01-19 19:16:44 +00:00
|
|
|
if (!comp_suspended && pDoc->state.have_gpu()) {
|
2010-05-12 18:14:30 +00:00
|
|
|
switch(status.gpu_suspend_reason) {
|
|
|
|
case 0:
|
|
|
|
strMessage += _("GPU computing is enabled");
|
|
|
|
break;
|
|
|
|
default:
|
2010-05-12 18:23:03 +00:00
|
|
|
strMessage += _("GPU computing is suspended - ");
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += suspend_reason_wxstring(status.gpu_suspend_reason);
|
|
|
|
break;
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
2010-05-12 18:23:03 +00:00
|
|
|
strMessage += wxT(".\n");
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
2010-05-12 18:14:30 +00:00
|
|
|
|
|
|
|
switch(status.network_suspend_reason) {
|
|
|
|
case 0:
|
|
|
|
strMessage += _("Network is enabled");
|
|
|
|
break;
|
|
|
|
default:
|
2010-05-12 18:23:03 +00:00
|
|
|
strMessage += _("Network is suspended - ");
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += suspend_reason_wxstring(status.network_suspend_reason);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
strMessage += wxT(".\n");
|
2010-03-29 17:20:12 +00:00
|
|
|
} else {
|
|
|
|
icnIcon = m_iconTaskBarDisconnected;
|
|
|
|
if (pDoc->IsReconnecting()) {
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += _("Reconnecting to client.");
|
2010-03-29 17:20:12 +00:00
|
|
|
} else {
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage += _("Not connected to a client.");
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-12 18:14:30 +00:00
|
|
|
strMessage.Trim();
|
2010-03-29 17:20:12 +00:00
|
|
|
SetIcon(icnIcon, strMessage);
|
2010-03-30 01:40:04 +00:00
|
|
|
#endif
|
2010-03-29 17:20:12 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::UpdateTaskbarStatus - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::UpdateNoticeStatus() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::UpdateNoticeStatus - Function Begin"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
|
|
|
wxString strTitle;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2010-04-01 11:09:33 +00:00
|
|
|
if (!pFrame) return;
|
|
|
|
|
|
|
|
// Repeat notification for unread notices at user-selected reminder frequency
|
2010-03-29 17:20:12 +00:00
|
|
|
wxTimeSpan tsLastNotificationDisplayed = wxDateTime::Now() - m_dtLastNotificationAlertExecuted;
|
2010-04-01 11:09:33 +00:00
|
|
|
if (
|
2011-03-07 15:30:38 +00:00
|
|
|
(tsLastNotificationDisplayed.GetMinutes() >= pFrame->GetReminderFrequency())
|
2010-04-01 11:09:33 +00:00
|
|
|
&& (pFrame->GetReminderFrequency() != 0)
|
|
|
|
) {
|
2010-03-29 17:20:12 +00:00
|
|
|
|
2011-03-07 16:06:26 +00:00
|
|
|
if (pDoc->GetUnreadNoticeCount()
|
|
|
|
&& (pDoc->GetUnreadNoticeCount() != m_iLastNotificationUnreadMessageCount)
|
|
|
|
) {
|
2010-07-22 20:55:39 +00:00
|
|
|
#ifdef __WXMAC__
|
2010-04-05 08:49:43 +00:00
|
|
|
// Delay notification while user is inactive
|
|
|
|
// NOTE: This API requires OS 10.4 or later
|
|
|
|
double idleTime = CGEventSourceSecondsSinceLastEventType (
|
|
|
|
kCGEventSourceStateCombinedSessionState,
|
|
|
|
kCGAnyInputEventType
|
|
|
|
);
|
|
|
|
if (idleTime > MIN_IDLE_TIME_FOR_NOTIFICATION) return;
|
|
|
|
#endif
|
2010-03-29 17:20:12 +00:00
|
|
|
// Update cached info
|
|
|
|
m_dtLastNotificationAlertExecuted = wxDateTime::Now();
|
2011-03-07 16:06:26 +00:00
|
|
|
m_iLastNotificationUnreadMessageCount = pDoc->GetUnreadNoticeCount();
|
2010-03-30 11:39:41 +00:00
|
|
|
|
2010-03-29 17:20:12 +00:00
|
|
|
if (IsBalloonsSupported()) {
|
|
|
|
// Display balloon
|
2010-03-30 12:59:23 +00:00
|
|
|
strTitle.Printf(
|
|
|
|
_("%s Notices"),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
|
|
|
);
|
2010-03-29 17:20:12 +00:00
|
|
|
QueueBalloon(
|
|
|
|
m_iconTaskBarNormal,
|
|
|
|
strTitle,
|
2010-07-22 22:57:15 +00:00
|
|
|
_("There are new notices - click to view."),
|
2010-03-29 17:20:12 +00:00
|
|
|
BALLOONTYPE_INFO
|
|
|
|
);
|
2010-04-05 08:49:43 +00:00
|
|
|
#ifdef __WXMAC__
|
2010-03-29 17:20:12 +00:00
|
|
|
} else {
|
|
|
|
// For platforms that do not support balloons
|
2010-04-01 11:16:10 +00:00
|
|
|
// If Manager is hidden or in background, request user attention.
|
2010-04-01 11:09:33 +00:00
|
|
|
if (! (wxGetApp().IsActive())) {
|
|
|
|
MacRequestUserAttention(); // Bounce BOINC Dock icon
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
2010-04-05 10:03:39 +00:00
|
|
|
#else
|
|
|
|
pFrame->RequestUserAttention();
|
2010-04-05 10:00:57 +00:00
|
|
|
#endif
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-01 11:09:33 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
} else {
|
|
|
|
// Stop bouncing BOINC Dock icon after MAX_NOTIFICATION_DURATION seconds
|
|
|
|
if (m_pNotificationRequest) {
|
|
|
|
if (wxGetApp().IsActive() ||
|
|
|
|
(tsLastNotificationDisplayed.GetSeconds() >= MAX_NOTIFICATION_DURATION)
|
|
|
|
) {
|
|
|
|
MacCancelUserAttentionRequest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2010-03-29 17:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::UpdateNoticeStatus - Function End"));
|
|
|
|
}
|