Ticket #9: taskbar.2008.06.16.patch
File taskbar.2008.06.16.patch, 8.8 KB (added by , 16 years ago) |
---|
-
clientgui/BOINCTaskBar.cpp
144 144 145 145 // Which icon should be displayed? 146 146 if (!pDoc->IsConnected()) { 147 SetIcon(m_iconTaskBarDisconnected , wxEmptyString);147 SetIcon(m_iconTaskBarDisconnected); 148 148 } else { 149 149 if (RUN_MODE_NEVER == status.task_mode) { 150 SetIcon(m_iconTaskBarSnooze , wxEmptyString);150 SetIcon(m_iconTaskBarSnooze); 151 151 } else { 152 SetIcon(m_iconTaskBarNormal , wxEmptyString);152 SetIcon(m_iconTaskBarNormal); 153 153 } 154 154 } 155 155 … … 289 289 wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function End")); 290 290 } 291 291 292 292 // Note: tooltip must not have a trailing linebreak. 293 293 void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(event)) { 294 294 295 295 wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected); … … 297 297 m_dtLastHoverDetected = wxDateTime::Now(); 298 298 299 299 CMainDocument* pDoc = wxGetApp().GetDocument(); 300 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); 301 wxString strTitle = wxEmptyString; 300 302 wxString strMachineName = wxEmptyString; 301 303 wxString strMessage = wxEmptyString; 302 304 wxString strBuffer = wxEmptyString; 303 305 wxString strProjectName = wxEmptyString; 304 306 float fProgress = 0; 305 bool bIsActive = false;306 bool bIsExecuting = false;307 bool bIsDownloaded = false;308 wxInt32 iResultCount = 0;309 wxInt32 iIndex = 0;310 wxIcon iconIcon = wxNullIcon;311 307 CC_STATUS status; 312 308 313 309 wxASSERT(pDoc); 310 wxASSERT(pSkinAdvanced); 314 311 wxASSERT(wxDynamicCast(pDoc, CMainDocument)); 312 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); 315 313 314 // Construct tooltip title. 315 strTitle = pSkinAdvanced->GetApplicationName(); 316 316 317 if (pDoc->IsConnected()) { 317 iconIcon = m_iconTaskBarNormal;318 pDoc->GetConnectedComputerName(strMachineName); 318 319 320 // Only show machine name if connected to remote machine. 321 if (!pDoc->IsComputerNameLocal(strMachineName)) { 322 strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")"); 323 } 324 325 strMessage += strTitle; 326 319 327 pDoc->GetCoreClientStatus(status); 320 328 if (status.task_suspend_reason && !(status.task_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) { 321 329 strBuffer.Printf( 322 _(" Computation is suspended.\n")330 _("\nComputation is suspended.") 323 331 ); 324 332 strMessage += strBuffer; 325 333 } 326 334 327 335 if (status.network_suspend_reason && !(status.network_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) { 328 336 strBuffer.Printf( 329 _(" Network activity is suspended.\n")337 _("\nNetwork activity is suspended.") 330 338 ); 331 339 strMessage += strBuffer; 332 340 } 333 341 334 if (strMessage.Length() > 0) { 335 strMessage += wxT("\n"); 336 } 342 std::vector<RESULT*> tasks = GetRunningTasks(pDoc); 337 343 338 iResultCount = pDoc->GetWorkCount(); 339 for (iIndex = 0; iIndex < iResultCount; iIndex++) { 340 RESULT* result = pDoc->result(iIndex); 341 RESULT* state_result = NULL; 342 std::string project_name; 344 if (tasks.size() == 0) { 345 strMessage += _("\nNo running tasks."); 346 } else if (tasks.size() < 3) { 343 347 344 bIsDownloaded = (result->state == RESULT_FILES_DOWNLOADED); 345 bIsActive = result->active_task; 346 bIsExecuting = (result->scheduler_state == CPU_SCHED_SCHEDULED); 347 if (!(bIsActive) || !(bIsDownloaded) || !(bIsExecuting)) continue; 348 // Limit list of running tasks to 2, to avoid overflow. 349 std::vector<RESULT*>::iterator i = tasks.begin(); 350 while (i != tasks.end()) { 351 RESULT* task = *i; 352 std::string project_name; 348 353 349 if (result) {350 state_result = pDoc->state.lookup_result(result->project_url, result->name);351 if (state_result) {352 state_result->project->get_name(project_name);353 strProjectName = wxString(project_name.c_str());354 if (task) { 355 RESULT* state_result = pDoc->state.lookup_result(task->project_url, task->name); 356 if (state_result) { 357 state_result->project->get_name(project_name); 358 } 354 359 } 355 fProgress = floor(result->fraction_done*10000)/100; 360 fProgress = floor(task->fraction_done*10000)/100; 361 362 strBuffer.Printf(wxT("\n%s: %.2f%%"), project_name.c_str(), fProgress ); 363 strMessage += strBuffer; 364 i++; 356 365 } 357 358 strBuffer.Printf(_(" %s: %.2f%% completed\n"), strProjectName.c_str(), fProgress);366 } else { 367 strBuffer.Printf(_("\n%d running tasks."), tasks.size()); 359 368 strMessage += strBuffer; 360 369 } 370 361 371 } else if (pDoc->IsReconnecting()) { 362 372 strBuffer.Printf( 363 _(" Reconnecting to client.\n")373 _("\nReconnecting to client.") 364 374 ); 365 375 strMessage += strBuffer; 366 376 } else { 367 377 strBuffer.Printf( 368 _(" Not connected to a client.\n")378 _("\nNot connected to a client.") 369 379 ); 370 iconIcon = m_iconTaskBarDisconnected;371 380 strMessage += strBuffer; 372 381 } 373 382 374 SetIcon(iconIcon, strMessage); 383 // Update the text without affecting the icon: 384 SetTooltip(strMessage); 375 385 } 376 386 } 377 387 378 388 389 std::vector<RESULT*> CTaskBarIcon::GetRunningTasks(CMainDocument* pDoc) { 390 391 std::vector<RESULT*> results; 392 bool bIsActive, bIsExecuting, bIsDownloaded; 393 394 int iResultCount = pDoc->GetWorkCount(); 395 396 for (int iIndex = 0; iIndex < iResultCount; iIndex++) { 397 RESULT* result = pDoc->result(iIndex); 398 399 if (result) { 400 bIsDownloaded = (result->state == RESULT_FILES_DOWNLOADED); 401 bIsActive = result->active_task; 402 bIsExecuting = (result->scheduler_state == CPU_SCHED_SCHEDULED); 403 if (bIsActive && bIsDownloaded && bIsExecuting) { 404 results.push_back(result); 405 } 406 } 407 } 408 return results; 409 } 410 411 379 412 void CTaskBarIcon::OnContextMenu(wxTaskBarIconExEvent& WXUNUSED(event)) { 380 413 DisplayContextMenu(); 381 414 } -
clientgui/BOINCTaskBar.h
24 24 #pragma interface "BOINCTaskBar.cpp" 25 25 #endif 26 26 27 #include "MainDocument.h" 27 28 28 29 #ifdef __WXMSW__ 29 30 #include "msw/taskbarex.h" … … 89 90 void ResetTaskBar(); 90 91 91 92 void DisplayContextMenu(); 93 std::vector<RESULT*> GetRunningTasks(CMainDocument* pDoc); 92 94 93 95 DECLARE_EVENT_TABLE() 94 96 -
clientgui/msw/taskbarex.cpp
172 172 return m_iconAdded; 173 173 } 174 174 175 bool wxTaskBarIconEx::SetTooltip(const wxString tip) 176 { 177 if (!IsOK()) 178 return false; 179 180 memset(¬ifyData, 0, sizeof(notifyData)); 181 notifyData.cbSize = sizeof(notifyData); 182 notifyData.hWnd = (HWND) m_hWnd; 183 notifyData.uID = 99; 184 notifyData.uCallbackMessage = sm_taskbarMsg; 185 notifyData.uFlags = NIF_TIP; 186 notifyData.uVersion = NOTIFYICON_VERSION; 187 188 lstrcpyn(notifyData.szTip, WXSTRINGCAST tip, sizeof(notifyData.szTip)); 189 190 UpdateIcon(); 191 return m_iconAdded; 192 } 193 175 194 bool wxTaskBarIconEx::RemoveIcon() 176 195 { 177 196 if (!m_iconAdded) -
clientgui/msw/taskbarex.h
57 57 unsigned int iconballoon = NIIF_INFO 58 58 ); 59 59 60 bool SetTooltip(const wxString tip); 60 61 bool RemoveIcon(); 61 62 void UpdateIcon(); 62 63