Ticket #9: taskbar.2008.06.16.patch

File taskbar.2008.06.16.patch, 8.8 kB (added by Didactylos, 1 year ago)

Updated to current.

  • clientgui/BOINCTaskBar.cpp

    old new  
    144144 
    145145    // Which icon should be displayed? 
    146146    if (!pDoc->IsConnected()) { 
    147         SetIcon(m_iconTaskBarDisconnected, wxEmptyString); 
     147        SetIcon(m_iconTaskBarDisconnected); 
    148148    } else { 
    149149        if (RUN_MODE_NEVER == status.task_mode) { 
    150             SetIcon(m_iconTaskBarSnooze, wxEmptyString); 
     150            SetIcon(m_iconTaskBarSnooze); 
    151151        } else { 
    152             SetIcon(m_iconTaskBarNormal, wxEmptyString); 
     152            SetIcon(m_iconTaskBarNormal); 
    153153        } 
    154154    } 
    155155 
     
    289289    wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function End")); 
    290290} 
    291291 
    292  
     292// Note: tooltip must not have a trailing linebreak. 
    293293void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(event)) { 
    294294 
    295295    wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected); 
     
    297297        m_dtLastHoverDetected = wxDateTime::Now(); 
    298298 
    299299        CMainDocument* pDoc                 = wxGetApp().GetDocument(); 
     300        CSkinAdvanced* pSkinAdvanced        = wxGetApp().GetSkinManager()->GetAdvanced(); 
     301        wxString       strTitle             = wxEmptyString; 
    300302        wxString       strMachineName       = wxEmptyString; 
    301303        wxString       strMessage           = wxEmptyString; 
    302304        wxString       strBuffer            = wxEmptyString; 
    303305        wxString       strProjectName       = wxEmptyString; 
    304306        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; 
    311307        CC_STATUS      status; 
    312308 
    313309        wxASSERT(pDoc); 
     310        wxASSERT(pSkinAdvanced); 
    314311        wxASSERT(wxDynamicCast(pDoc, CMainDocument)); 
     312        wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); 
    315313 
     314        // Construct tooltip title. 
     315        strTitle = pSkinAdvanced->GetApplicationName(); 
     316 
    316317        if (pDoc->IsConnected()) { 
    317             iconIcon = m_iconTaskBarNormal
     318            pDoc->GetConnectedComputerName(strMachineName)
    318319 
     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 
    319327            pDoc->GetCoreClientStatus(status); 
    320328            if (status.task_suspend_reason && !(status.task_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) { 
    321329                strBuffer.Printf( 
    322                     _("Computation is suspended.\n") 
     330                    _("\nComputation is suspended.") 
    323331                ); 
    324332                strMessage += strBuffer; 
    325333            } 
    326334 
    327335            if (status.network_suspend_reason && !(status.network_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) { 
    328336                strBuffer.Printf( 
    329                     _("Network activity is suspended.\n") 
     337                    _("\nNetwork activity is suspended.") 
    330338                ); 
    331339                strMessage += strBuffer; 
    332340            } 
    333341 
    334             if (strMessage.Length() > 0) { 
    335                 strMessage += wxT("\n"); 
    336             } 
     342            std::vector<RESULT*> tasks = GetRunningTasks(pDoc); 
    337343 
    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) { 
    343347 
    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; 
    348353 
    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                        } 
    354359                    } 
    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++; 
    356365                } 
    357  
    358                 strBuffer.Printf(_("%s: %.2f%% completed\n"), strProjectName.c_str(), fProgress ); 
     366            } else { 
     367                strBuffer.Printf(_("\n%d running tasks."), tasks.size()); 
    359368                strMessage += strBuffer; 
    360369            } 
     370 
    361371        } else if (pDoc->IsReconnecting()) { 
    362372            strBuffer.Printf( 
    363                 _("Reconnecting to client.\n") 
     373                _("\nReconnecting to client.") 
    364374            ); 
    365375            strMessage += strBuffer; 
    366376        } else { 
    367377            strBuffer.Printf( 
    368                 _("Not connected to a client.\n") 
     378                _("\nNot connected to a client.") 
    369379            ); 
    370             iconIcon = m_iconTaskBarDisconnected; 
    371380            strMessage += strBuffer; 
    372381        } 
    373382 
    374         SetIcon(iconIcon, strMessage); 
     383        // Update the text without affecting the icon: 
     384        SetTooltip(strMessage); 
    375385    } 
    376386} 
    377387 
    378388 
     389std::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 
    379412void CTaskBarIcon::OnContextMenu(wxTaskBarIconExEvent& WXUNUSED(event)) { 
    380413    DisplayContextMenu(); 
    381414} 
  • clientgui/BOINCTaskBar.h

    old new  
    2424#pragma interface "BOINCTaskBar.cpp" 
    2525#endif 
    2626 
     27#include "MainDocument.h" 
    2728 
    2829#ifdef __WXMSW__ 
    2930#include "msw/taskbarex.h" 
     
    8990    void       ResetTaskBar(); 
    9091 
    9192    void       DisplayContextMenu(); 
     93    std::vector<RESULT*> GetRunningTasks(CMainDocument* pDoc); 
    9294     
    9395    DECLARE_EVENT_TABLE() 
    9496 
  • clientgui/msw/taskbarex.cpp

    old new  
    172172    return m_iconAdded; 
    173173} 
    174174 
     175bool wxTaskBarIconEx::SetTooltip(const wxString tip) 
     176{ 
     177        if (!IsOK()) 
     178            return false; 
     179 
     180    memset(&notifyData, 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 
    175194bool wxTaskBarIconEx::RemoveIcon() 
    176195{ 
    177196    if (!m_iconAdded) 
  • clientgui/msw/taskbarex.h

    old new  
    5757        unsigned int iconballoon = NIIF_INFO 
    5858    ); 
    5959 
     60    bool SetTooltip(const wxString tip); 
    6061    bool RemoveIcon(); 
    6162    void UpdateIcon(); 
    6263 

If this page is incomplete or incorrect, please edit it or add it to the wiki to-do list. To do this, you must be logged in; click Login or Register above.