2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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"
|
|
|
|
#include "BOINCGUIApp.h"
|
2004-11-02 04:44:24 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
2004-10-24 05:40:12 +00:00
|
|
|
#include "DlgAbout.h"
|
|
|
|
#include "Events.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
#include "res/boinc.xpm"
|
|
|
|
|
2004-11-02 10:14:41 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CTaskBarIcon, wxTaskBarIconEx)
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-11-02 10:14:41 +00:00
|
|
|
BEGIN_EVENT_TABLE (CTaskBarIcon, wxTaskBarIconEx)
|
2005-03-31 23:54:12 +00:00
|
|
|
EVT_IDLE(CTaskBarIcon::OnIdle)
|
|
|
|
EVT_CLOSE(CTaskBarIcon::OnClose)
|
|
|
|
EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_OPEN, CTaskBarIcon::OnOpen)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_MENU_RANGE(ID_TB_ACTIVITYRUNALWAYS, ID_TB_ACTIVITYSUSPEND, CTaskBarIcon::OnActivitySelection)
|
|
|
|
EVT_MENU_RANGE(ID_TB_NETWORKRUNALWAYS, ID_TB_NETWORKSUSPEND, CTaskBarIcon::OnNetworkSelection)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_ABOUT, CTaskBarIcon::OnAbout)
|
2004-10-23 23:40:11 +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
|
2004-10-23 07:13:18 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
|
|
|
|
|
|
|
CTaskBarIcon::CTaskBarIcon() :
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
2005-04-07 07:04:50 +00:00
|
|
|
wxTaskBarIcon(DOCK)
|
2005-03-25 12:23:30 +00:00
|
|
|
#else
|
2005-04-07 07:04:50 +00:00
|
|
|
wxTaskBarIconEx(wxT("BOINCManagerSystray"))
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2005-04-07 07:04:50 +00:00
|
|
|
m_iconTaskBarIcon = wxIcon(boinc_xpm);
|
|
|
|
m_dtLastHoverDetected = wxDateTime((time_t)0);
|
|
|
|
m_dtLastBalloonDisplayed = wxDateTime((time_t)0);
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifndef __WXMAC__
|
2005-04-07 07:04:50 +00:00
|
|
|
SetIcon(m_iconTaskBarIcon, _("BOINC Manager"));
|
2005-03-25 12:23:30 +00:00
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
ResetTaskBar();
|
|
|
|
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pFrame) {
|
2005-03-31 23:54:12 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
pFrame->Close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnClose - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
2005-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pFrame);
|
2004-10-24 05:40:12 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pFrame) {
|
2004-10-24 05:40:12 +00:00
|
|
|
pFrame->Show();
|
2005-05-07 12:37:01 +00:00
|
|
|
#ifndef __WXMAC__
|
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();
|
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
|
|
|
}
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnActivitySelection(wxCommandEvent& event) {
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-24 05:40:12 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
switch(event.GetId()) {
|
|
|
|
case ID_TB_ACTIVITYRUNALWAYS:
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_ALWAYS);
|
2005-04-07 07:04:50 +00:00
|
|
|
break;
|
|
|
|
case ID_TB_ACTIVITYSUSPEND:
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_NEVER);
|
2005-04-07 07:04:50 +00:00
|
|
|
break;
|
|
|
|
case ID_TB_ACTIVITYRUNBASEDONPREPERENCES:
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_AUTO);
|
2005-04-07 07:04:50 +00:00
|
|
|
break;
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnNetworkSelection(wxCommandEvent& event) {
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2005-03-29 23:51:43 +00:00
|
|
|
wxInt32 iCurrentNetworkMode = -1;
|
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));
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
switch(event.GetId()) {
|
|
|
|
case ID_TB_NETWORKSUSPEND:
|
|
|
|
pDoc->GetNetworkRunMode(iCurrentNetworkMode);
|
|
|
|
|
2005-05-29 07:12:00 +00:00
|
|
|
if (iCurrentNetworkMode == RUN_MODE_ALWAYS)
|
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_NEVER);
|
2005-04-07 07:04:50 +00:00
|
|
|
else
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_ALWAYS);
|
2005-04-07 07:04:50 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case ID_TB_NETWORKRUNALWAYS:
|
|
|
|
case ID_TB_NETWORKRUNBASEDONPREPERENCES:
|
|
|
|
default:
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_ALWAYS);
|
2005-04-07 07:04:50 +00:00
|
|
|
break;
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CDlgAbout* pDlg = new CDlgAbout(NULL);
|
2005-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pDlg);
|
2004-10-24 05:40:12 +00:00
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
if (pDlg) {
|
2004-10-24 05:40:12 +00:00
|
|
|
pDlg->Destroy();
|
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
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
wxCloseEvent eventClose;
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
OnClose(eventClose);
|
2005-02-09 01:14:14 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (eventClose.GetSkipped()) event.Skip();
|
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
|
|
|
#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"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& event) {
|
2004-11-04 05:34:51 +00:00
|
|
|
wxTimeSpan ts(wxDateTime::Now() - m_dtLastHoverDetected);
|
2005-04-07 07:04:50 +00:00
|
|
|
if (ts.GetSeconds() >= 10)
|
2004-11-04 05:34:51 +00:00
|
|
|
m_dtLastHoverDetected = wxDateTime::Now();
|
|
|
|
|
|
|
|
wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected);
|
|
|
|
wxTimeSpan tsLastBalloon(wxDateTime::Now() - m_dtLastBalloonDisplayed);
|
2005-04-07 07:04:50 +00:00
|
|
|
if ((tsLastHover.GetSeconds() >= 2) && (tsLastBalloon.GetSeconds() >= 10)) {
|
2004-11-04 05:34:51 +00:00
|
|
|
m_dtLastBalloonDisplayed = wxDateTime::Now();
|
2004-10-23 23:40:11 +00:00
|
|
|
|
|
|
|
wxString strTitle = wxGetApp().GetAppName();
|
2004-11-04 05:34:51 +00:00
|
|
|
wxString strMachineName = wxEmptyString;
|
2004-10-23 23:40:11 +00:00
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
wxString strBuffer = wxEmptyString;
|
|
|
|
wxString strProjectName = wxEmptyString;
|
|
|
|
float fProgress = 0;
|
|
|
|
bool bIsActive = false;
|
|
|
|
bool bIsExecuting = false;
|
|
|
|
bool bIsDownloaded = false;
|
|
|
|
wxInt32 iResultCount = 0;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-23 23:40:11 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetConnectedComputerName(strMachineName);
|
2005-04-08 16:58:55 +00:00
|
|
|
if (strMachineName.empty()) {
|
2004-11-04 05:34:51 +00:00
|
|
|
strTitle = strTitle + wxT(" - (localhost)");
|
2005-04-08 16:58:55 +00:00
|
|
|
} else {
|
2004-11-04 05:34:51 +00:00
|
|
|
strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")");
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-11-04 05:34:51 +00:00
|
|
|
|
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
iResultCount = pDoc->results.results.size();
|
2005-04-07 07:04:50 +00:00
|
|
|
for (iIndex = 0; iIndex < iResultCount; iIndex++) {
|
2005-06-13 08:47:51 +00:00
|
|
|
RESULT* result = wxGetApp().GetDocument()->result(iIndex);
|
|
|
|
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);
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!(bIsActive) || !(bIsDownloaded) || !(bIsExecuting)) continue;
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
if (result) {
|
|
|
|
state_result = pDoc->state.lookup_result(result->project_url, result->name);
|
|
|
|
if (state_result) {
|
|
|
|
state_result->project->get_name(project_name);
|
|
|
|
strProjectName = wxString(project_name.c_str());
|
|
|
|
}
|
|
|
|
fProgress = result->fraction_done;
|
|
|
|
}
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
strBuffer.Printf(wxT("%s: %.2f%%\n"), strProjectName.c_str(), fProgress * 100);
|
2004-10-23 23:40:11 +00:00
|
|
|
strMessage += strBuffer;
|
|
|
|
}
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
SetBalloon(m_iconTaskBarIcon, strTitle, strMessage);
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif // __WXMSW__
|
|
|
|
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-11-03 21:06:12 +00:00
|
|
|
#ifdef __WXMSW__
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnContextMenu(wxTaskBarIconExEvent& event) {
|
2004-11-03 21:06:12 +00:00
|
|
|
CreateContextMenu();
|
|
|
|
}
|
2005-03-25 12:23:30 +00:00
|
|
|
#else
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnContextMenu(wxTaskBarIconEvent& event) {
|
2005-03-25 12:23:30 +00:00
|
|
|
CreateContextMenu();
|
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
#endif
|
2004-11-03 21:06:12 +00:00
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnRButtonDown(wxTaskBarIconEvent& event) {
|
|
|
|
if (!IsBalloonsSupported()) {
|
2004-11-23 07:45:11 +00:00
|
|
|
m_bButtonPressed = true;
|
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnRButtonUp(wxTaskBarIconEvent& event) {
|
|
|
|
if (!IsBalloonsSupported()) {
|
|
|
|
if (m_bButtonPressed) {
|
2004-11-23 07:45:11 +00:00
|
|
|
CreateContextMenu();
|
|
|
|
m_bButtonPressed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::ResetTaskBar() {
|
2004-11-03 21:06:12 +00:00
|
|
|
#ifdef __WXMSW___
|
2005-04-07 07:04:50 +00:00
|
|
|
SetBalloon(m_iconTaskBarIcon, wxT(""), wxT(""));
|
2004-11-03 21:06:12 +00:00
|
|
|
#else
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifndef __WXMAC__
|
2005-04-07 07:04:50 +00:00
|
|
|
SetIcon(m_iconTaskBarIcon, wxT(""));
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-11-03 21:06:12 +00:00
|
|
|
#endif
|
|
|
|
|
2004-11-04 05:34:51 +00:00
|
|
|
m_dtLastBalloonDisplayed = wxDateTime::Now();
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::CreateContextMenu() {
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 07:43:33 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenu *menu = BuildContextMenu();
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
// These should be in Windows Task Bar Menu but not in Mac's Dock menu
|
|
|
|
menu->AppendSeparator();
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Append(wxID_EXIT, _("E&xit"), wxEmptyString);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
PopupMenu(menu);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxMenu *CTaskBarIcon::BuildContextMenu() {
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenu* menu = new wxMenu;
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(menu);
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenuItem* menuItem = NULL;
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
|
|
|
font.SetWeight(wxBOLD);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
menuItem = new wxMenuItem(menu, wxID_OPEN, _("&Open BOINC Manager..."), wxEmptyString);
|
|
|
|
menuItem->SetFont(font);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Append(menuItem);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Append(wxID_OPEN, _("&Open BOINC Manager..."), wxEmptyString);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
|
|
|
#endif
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->AppendRadioItem(ID_TB_ACTIVITYRUNALWAYS, _("&Run always"), wxEmptyString);
|
|
|
|
menu->AppendRadioItem(ID_TB_ACTIVITYRUNBASEDONPREPERENCES, _("Run based on &preferences"), wxEmptyString);
|
|
|
|
menu->AppendRadioItem(ID_TB_ACTIVITYSUSPEND, _("&Suspend"), wxEmptyString);
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->AppendCheckItem(ID_TB_NETWORKSUSPEND, _("&Disable BOINC network access"), wxEmptyString);
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Append(wxID_ABOUT, _("&About BOINC Manager..."), wxEmptyString);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
|
|
|
AdjustMenuItems(menu);
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::AdjustMenuItems(wxMenu* menu) {
|
2005-03-25 12:23:30 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxInt32 iActivityMode = -1;
|
|
|
|
wxInt32 iNetworkMode = -1;
|
|
|
|
|
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
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetActivityRunMode(iActivityMode);
|
|
|
|
switch(iActivityMode) {
|
2005-05-29 07:12:00 +00:00
|
|
|
case RUN_MODE_ALWAYS:
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_ACTIVITYRUNALWAYS, true);
|
|
|
|
break;
|
2005-05-29 07:12:00 +00:00
|
|
|
case RUN_MODE_NEVER:
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_ACTIVITYSUSPEND, true);
|
|
|
|
break;
|
2005-05-29 07:12:00 +00:00
|
|
|
case RUN_MODE_AUTO:
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_ACTIVITYRUNBASEDONPREPERENCES, true);
|
|
|
|
break;
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetNetworkRunMode(iNetworkMode);
|
2005-05-29 07:12:00 +00:00
|
|
|
if (RUN_MODE_NEVER == iNetworkMode) {
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_NETWORKSUSPEND, true);
|
2005-04-08 16:58:55 +00:00
|
|
|
} else {
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_NETWORKSUSPEND, false);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_531575eeaa = "$Id$";
|