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
|
|
|
|
|
|
|
|
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)
|
2006-02-02 19:53:16 +00:00
|
|
|
EVT_MENU(ID_OPENWEBSITE, CTaskBarIcon::OnOpenWebsite)
|
2006-02-14 22:50:32 +00:00
|
|
|
EVT_MENU(ID_TB_ACTIVITYSUSPEND, CTaskBarIcon::OnActivitySelection)
|
|
|
|
EVT_MENU(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 ()
|
|
|
|
|
|
|
|
|
2005-12-28 12:33:18 +00:00
|
|
|
CTaskBarIcon::CTaskBarIcon(wxString title, wxIcon* icon) :
|
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
|
|
|
{
|
2005-12-28 12:33:18 +00:00
|
|
|
m_iconTaskBarIcon = *icon;
|
2005-04-07 07:04:50 +00:00
|
|
|
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-12-28 12:33:18 +00:00
|
|
|
SetIcon(m_iconTaskBarIcon, title);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-02 19:53:16 +00:00
|
|
|
void CTaskBarIcon::OnOpenWebsite(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
ResetTaskBar();
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
ACCT_MGR_INFO ami;
|
|
|
|
wxString url;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
|
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
|
|
|
|
|
|
|
url = ami.acct_mgr_url.c_str();
|
|
|
|
|
|
|
|
pFrame->ExecuteBrowserLink(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
2006-02-14 22:50:32 +00:00
|
|
|
if (event.IsChecked()) {
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_NEVER);
|
2006-02-14 22:50:32 +00:00
|
|
|
} else {
|
2005-05-29 07:12:00 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_AUTO);
|
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-04-08 16:58:55 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-24 05:40:12 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2006-02-14 22:50:32 +00:00
|
|
|
if (event.IsChecked()) {
|
2005-07-14 22:59:11 +00:00
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_NEVER);
|
2006-02-14 22:50:32 +00:00
|
|
|
} else {
|
2005-07-14 22:59:11 +00:00
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_AUTO);
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
|
2005-07-06 05:16:53 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
|
|
|
|
GetCurrentProcess(&psn);
|
|
|
|
bool wasVisible = IsProcessVisible(&psn);
|
|
|
|
SetFrontProcess(&psn); // Shows process if hidden
|
|
|
|
#endif
|
|
|
|
|
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-07-06 05:16:53 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
if (! wasVisible)
|
|
|
|
ShowHideProcess(&psn, false);
|
|
|
|
#endif
|
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-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(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
|
|
|
|
2005-12-28 12:33:18 +00:00
|
|
|
wxString strTitle = wxGetApp().GetBrand()->GetApplicationName();
|
2005-09-09 08:47:33 +00:00
|
|
|
wxString strMachineName = wxEmptyString;
|
|
|
|
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;
|
|
|
|
bool bActivitiesSuspended = false;
|
|
|
|
bool bNetworkSuspended = false;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-23 23:40:11 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
pDoc->GetConnectedComputerName(strMachineName);
|
2004-11-04 05:34:51 +00:00
|
|
|
strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")");
|
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
pDoc->GetActivityState(bActivitiesSuspended, bNetworkSuspended);
|
|
|
|
if (bActivitiesSuspended) {
|
2005-12-28 12:33:18 +00:00
|
|
|
// 1st %s is the previous instance of the message
|
|
|
|
// 2nd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
|
|
|
_("%s is currently suspended...\n"),
|
2005-12-28 12:33:18 +00:00
|
|
|
wxGetApp().GetBrand()->GetProjectName().c_str()
|
|
|
|
);
|
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
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
if (bNetworkSuspended) {
|
2005-12-28 12:33:18 +00:00
|
|
|
// 1st %s is the previous instance of the message
|
|
|
|
// 2nd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
|
|
|
_("%s networking is currently suspended...\n"),
|
2005-12-28 12:33:18 +00:00
|
|
|
wxGetApp().GetBrand()->GetProjectName().c_str()
|
|
|
|
);
|
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
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
if (strMessage.Length() > 0) {
|
|
|
|
strMessage += wxT("\n");
|
|
|
|
}
|
2004-11-04 05:34:51 +00:00
|
|
|
|
2005-11-27 01:28:56 +00:00
|
|
|
iResultCount = pDoc->results.results.size();
|
|
|
|
for (iIndex = 0; iIndex < iResultCount; iIndex++) {
|
|
|
|
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);
|
|
|
|
if (!(bIsActive) || !(bIsDownloaded) || !(bIsExecuting)) continue;
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
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
|
|
|
|
2006-02-16 18:42:13 +00:00
|
|
|
strBuffer.Printf(wxT("%s: %.2f%%\n"), strProjectName.c_str(), fProgress );
|
2005-11-27 01:28:56 +00:00
|
|
|
strMessage += strBuffer;
|
|
|
|
}
|
|
|
|
} else if (pDoc->IsReconnecting()) {
|
2005-12-28 12:33:18 +00:00
|
|
|
// 1st %s is the previous instance of the message
|
|
|
|
// 2nd %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
// 3rd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
|
|
|
_("%s is currently reconnecting to a %s client...\n"),
|
2005-12-28 12:33:18 +00:00
|
|
|
wxGetApp().GetBrand()->GetApplicationName().c_str(),
|
|
|
|
wxGetApp().GetBrand()->GetProjectName().c_str()
|
|
|
|
);
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2005-11-27 01:28:56 +00:00
|
|
|
} else {
|
2005-12-28 12:33:18 +00:00
|
|
|
// 1st %s is the previous instance of the message
|
|
|
|
// 2nd %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
// 3rd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
2006-02-13 20:33:47 +00:00
|
|
|
strBuffer.Printf(
|
|
|
|
_("%s is not currently connected to a %s client...\n"),
|
2005-12-28 12:33:18 +00:00
|
|
|
wxGetApp().GetBrand()->GetApplicationName().c_str(),
|
|
|
|
wxGetApp().GetBrand()->GetProjectName().c_str()
|
|
|
|
);
|
2006-02-13 20:33:47 +00:00
|
|
|
strMessage += strBuffer;
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2006-02-18 15:56:16 +00:00
|
|
|
#ifndef __WXMAC__
|
2004-11-03 21:06:12 +00:00
|
|
|
#ifdef __WXMSW__
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnContextMenu(wxTaskBarIconExEvent& WXUNUSED(event)) {
|
2004-11-03 21:06:12 +00:00
|
|
|
CreateContextMenu();
|
|
|
|
}
|
2005-03-25 12:23:30 +00:00
|
|
|
#else
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnContextMenu(wxTaskBarIconEvent& WXUNUSED(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
|
|
|
|
|
|
|
|
2006-02-18 15:56:16 +00:00
|
|
|
#ifdef __WXMSW__
|
2005-07-07 22:26:49 +00:00
|
|
|
void CTaskBarIcon::OnRButtonDown(wxTaskBarIconEvent& WXUNUSED(event)) {
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!IsBalloonsSupported()) {
|
2004-11-23 07:45:11 +00:00
|
|
|
m_bButtonPressed = true;
|
|
|
|
}
|
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()) {
|
|
|
|
if (m_bButtonPressed) {
|
2004-11-23 07:45:11 +00:00
|
|
|
CreateContextMenu();
|
|
|
|
m_bButtonPressed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-18 15:56:16 +00:00
|
|
|
#endif
|
|
|
|
#endif // !__WXMAC__
|
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;
|
|
|
|
}
|
|
|
|
|
2006-02-18 03:01:32 +00:00
|
|
|
#else // ! __WXMAC__
|
2005-03-25 12:23:30 +00:00
|
|
|
|
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
|
|
|
|
2006-02-17 19:18:24 +00:00
|
|
|
wxMenu* menu = BuildContextMenu();
|
|
|
|
wxMenuItem* menuItem = NULL;
|
|
|
|
wxFont font = wxNullFont;
|
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
|
|
|
|
2006-02-17 19:18:24 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
menuItem = menu->FindItem(wxID_EXIT);
|
|
|
|
menu->Remove(menuItem);
|
|
|
|
|
|
|
|
font = menuItem->GetFont();
|
|
|
|
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
|
|
|
menuItem->SetFont(font);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2006-02-17 19:18:24 +00:00
|
|
|
menu->Append(menuItem);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PopupMenu(menu);
|
2005-03-25 12:23:30 +00:00
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
2006-02-18 03:01:32 +00:00
|
|
|
#endif // ! __WXMAC__
|
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();
|
|
|
|
ACCT_MGR_INFO ami;
|
|
|
|
bool is_acct_mgr_detected = false;
|
|
|
|
wxMenu* menu = new wxMenu;
|
2006-02-17 19:18:24 +00:00
|
|
|
wxString menuName = wxEmptyString;
|
|
|
|
wxFont font = wxNullFont;
|
2006-02-18 03:01:32 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
wxMenuItem* menuItem = NULL;
|
2006-02-17 19:18:24 +00:00
|
|
|
size_t loc = 0;
|
2006-02-18 03:01:32 +00:00
|
|
|
#endif
|
2006-02-02 19:53:16 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(menu);
|
2006-02-02 19:53:16 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2006-02-02 19:53:16 +00:00
|
|
|
// Account managers have a different menu arrangement
|
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
|
|
|
is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
|
|
|
|
|
|
|
|
if (is_acct_mgr_detected) {
|
|
|
|
menuName.Printf(
|
2006-02-17 19:18:24 +00:00
|
|
|
_("Open %s Web..."),
|
2006-02-02 19:53:16 +00:00
|
|
|
wxGetApp().GetBrand()->GetProjectName().c_str()
|
|
|
|
);
|
|
|
|
menu->Append(ID_OPENWEBSITE, menuName, wxEmptyString);
|
|
|
|
}
|
2005-12-28 12:33:18 +00:00
|
|
|
|
|
|
|
menuName.Printf(
|
2006-02-17 19:18:24 +00:00
|
|
|
_("Open %s..."),
|
2005-12-28 12:33:18 +00:00
|
|
|
wxGetApp().GetBrand()->GetApplicationName().c_str()
|
|
|
|
);
|
|
|
|
menu->Append(wxID_OPEN, menuName, wxEmptyString);
|
2004-10-25 20:58:06 +00:00
|
|
|
|
2006-02-14 22:50:32 +00:00
|
|
|
menu->AppendCheckItem(ID_TB_ACTIVITYSUSPEND, _("&Suspend activities"), wxEmptyString);
|
|
|
|
menu->AppendCheckItem(ID_TB_NETWORKSUSPEND, _("Suspend &network activities"), wxEmptyString);
|
2005-12-28 12:33:18 +00:00
|
|
|
|
|
|
|
menuName.Printf(
|
|
|
|
_("&About %s..."),
|
|
|
|
wxGetApp().GetBrand()->GetApplicationName().c_str()
|
|
|
|
);
|
|
|
|
|
|
|
|
menu->Append(wxID_ABOUT, menuName, wxEmptyString);
|
2005-03-25 12:23:30 +00:00
|
|
|
|
2006-02-17 19:18:24 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
for (loc = 0; loc < menu->GetMenuItemCount(); loc++) {
|
|
|
|
menuItem = menu->FindItemByPosition(loc);
|
|
|
|
menu->Remove(menuItem);
|
|
|
|
|
|
|
|
font = menuItem->GetFont();
|
|
|
|
if (menuItem->GetId() != wxID_OPEN) {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
|
|
|
} else {
|
|
|
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
|
|
|
}
|
|
|
|
menuItem->SetFont(font);
|
|
|
|
|
|
|
|
menu->Insert(loc, menuItem);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (is_acct_mgr_detected) {
|
|
|
|
menu->InsertSeparator(4);
|
|
|
|
menu->InsertSeparator(2);
|
|
|
|
} else {
|
|
|
|
menu->InsertSeparator(3);
|
|
|
|
menu->InsertSeparator(1);
|
|
|
|
}
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
AdjustMenuItems(menu);
|
2006-02-17 19:18:24 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
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();
|
2006-02-14 22:50:32 +00:00
|
|
|
wxInt32 iMode = -1;
|
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-02-14 22:50:32 +00:00
|
|
|
pDoc->GetActivityRunMode(iMode);
|
|
|
|
if (RUN_MODE_NEVER == iMode) {
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_ACTIVITYSUSPEND, true);
|
2006-02-14 22:50:32 +00:00
|
|
|
} else {
|
|
|
|
menu->Check(ID_TB_ACTIVITYSUSPEND, false);
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2006-02-14 22:50:32 +00:00
|
|
|
pDoc->GetNetworkRunMode(iMode);
|
|
|
|
if (RUN_MODE_NEVER == iMode) {
|
2005-04-07 07:04:50 +00:00
|
|
|
menu->Check(ID_TB_NETWORKSUSPEND, true);
|
2006-02-14 22:50:32 +00:00
|
|
|
} else {
|
|
|
|
menu->Check(ID_TB_NETWORKSUSPEND, false);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2006-02-14 22:50:32 +00:00
|
|
|
|
2005-07-06 05:16:53 +00:00
|
|
|
#ifdef __WXMAC__
|
2005-07-06 06:41:27 +00:00
|
|
|
// WindowRef win = ActiveNonFloatingWindow();
|
|
|
|
WindowRef win = FrontWindow();
|
2005-07-06 05:16:53 +00:00
|
|
|
WindowModality modality = kWindowModalityNone;
|
|
|
|
wxMenuItem *item;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
GetWindowModality(win, &modality, NULL);
|
|
|
|
for (i = 0; i <menu->GetMenuItemCount() ; i++) {
|
|
|
|
item = menu->FindItemByPosition(i);
|
|
|
|
if (modality == kWindowModalityAppModal)
|
|
|
|
item->Enable(false);
|
|
|
|
else
|
|
|
|
item->Enable(!(item->IsSeparator()));
|
|
|
|
}
|
|
|
|
#endif // __WXMAC__
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_531575eeaa = "$Id$";
|