Ticket #9: tooltip.patch

File tooltip.patch, 6.3 KB (added by Didactylos, 17 years ago)
  • BOINCTaskBar.cpp

     
    8888    m_bTaskbarInitiatedShutdown = false;
    8989
    9090    m_dtLastHoverDetected = wxDateTime((time_t)0);
    91     m_dtLastBalloonDisplayed = wxDateTime((time_t)0);
    9291
    9392    m_bMouseButtonPressed = false;
    9493
     
    303302
    304303
    305304void CTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(event)) {
    306     wxTimeSpan ts(wxDateTime::Now() - m_dtLastHoverDetected);
    307     if (ts.GetSeconds() >= 10) {
    308         m_dtLastHoverDetected = wxDateTime::Now();
    309     }
    310305
    311306    wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected);
    312     wxTimeSpan tsLastBalloon(wxDateTime::Now() - m_dtLastBalloonDisplayed);
    313     if ((tsLastHover.GetSeconds() >= 2) && (tsLastBalloon.GetSeconds() >= 10)) {
    314         m_dtLastBalloonDisplayed = wxDateTime::Now();
    315307
     308    if (tsLastHover.GetSeconds() >= 2) {
     309        m_dtLastHoverDetected = wxDateTime::Now();
     310
    316311        CMainDocument* pDoc                 = wxGetApp().GetDocument();
    317312        CSkinAdvanced* pSkinAdvanced        = wxGetApp().GetSkinManager()->GetAdvanced();
    318313        wxString       strTitle             = wxEmptyString;
     
    340335
    341336        if (pDoc->IsConnected()) {
    342337            pDoc->GetConnectedComputerName(strMachineName);
    343             if (pDoc->IsComputerNameLocal(strMachineName)) {
    344                 strMachineName = wxT("localhost");
     338            if (!pDoc->IsComputerNameLocal(strMachineName)) {
     339                strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")");
    345340            }
    346             strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")");
    347341
     342                        strMessage += strTitle;
     343
    348344            pDoc->GetCoreClientStatus(status);
    349345            if (status.task_suspend_reason && !(status.task_suspend_reason & SUSPEND_REASON_CPU_USAGE_LIMIT)) {
    350346                // 1st %s is the previous instance of the message
    351347                // 2nd %s is the project name
    352348                //    i.e. 'BOINC', 'GridRepublic'
    353349                strBuffer.Printf(
    354                     _("%s is currently suspended...\n"),
     350                    _("\n%s is currently suspended..."),
    355351                    pSkinAdvanced->GetProjectName().c_str()
    356352                );
    357353                iconIcon = m_iconTaskBarSnooze;
     
    363359                // 2nd %s is the project name
    364360                //    i.e. 'BOINC', 'GridRepublic'
    365361                strBuffer.Printf(
    366                     _("%s networking is currently suspended...\n"),
     362                    _("\n%s networking is currently suspended..."),
    367363                    pSkinAdvanced->GetProjectName().c_str()
    368364                );
    369365                strMessage += strBuffer;
    370366            }
    371367
    372             if (strMessage.Length() > 0) {
    373                 strMessage += wxT("\n");
    374             }
     368            //if (strMessage.Length() > 0) {
     369            //    strMessage += wxT("\n");
     370            //}
    375371
    376372            iResultCount = pDoc->GetWorkCount();
    377373            for (iIndex = 0; iIndex < iResultCount; iIndex++) {
     
    393389                    fProgress = floor(result->fraction_done*10000)/100;
    394390                }
    395391
    396                 strBuffer.Printf(wxT("%s: %.2f%%\n"), strProjectName.c_str(), fProgress );
     392                strBuffer.Printf(wxT("\n%s: %.2f%%"), strProjectName.c_str(), fProgress );
    397393                strMessage += strBuffer;
    398394            }
    399395        } else if (pDoc->IsReconnecting()) {
     
    403399            // 3rd %s is the project name
    404400            //    i.e. 'BOINC', 'GridRepublic'
    405401            strBuffer.Printf(
    406                 _("%s is currently reconnecting to a %s client...\n"),
     402                _("\n%s is currently reconnecting to a %s client..."),
    407403                pSkinAdvanced->GetApplicationName().c_str(),
    408404                pSkinAdvanced->GetProjectName().c_str()
    409405            );
     
    415411            // 3rd %s is the project name
    416412            //    i.e. 'BOINC', 'GridRepublic'
    417413            strBuffer.Printf(
    418                 _("%s is not currently connected to a %s client...\n"),
     414                _("\n%s is not currently connected to a %s client..."),
    419415                pSkinAdvanced->GetApplicationName().c_str(),
    420416                pSkinAdvanced->GetProjectName().c_str()
    421417            );
     
    423419            strMessage += strBuffer;
    424420        }
    425421
    426         SetBalloon(iconIcon, strTitle, strMessage);
     422        SetTooltip(strMessage);
    427423    }
    428424}
    429425
     
    480476    SetIcon(m_iconTaskBarNormal, wxT(""));
    481477#endif
    482478
    483     m_dtLastBalloonDisplayed = wxDateTime::Now();
    484479}
    485480
    486481
  • BOINCTaskBar.h

     
    8181
    8282private:
    8383    wxDateTime m_dtLastHoverDetected;
    84     wxDateTime m_dtLastBalloonDisplayed;
    8584
    8685    wxTimer*   m_pRefreshTimer;
    8786
  • msw/taskbarex.cpp

     
    186186    }
    187187}
    188188
     189bool wxTaskBarIconEx::SetTooltip(const wxString tip)
     190{
     191        if (!IsOK())
     192            return false;
     193
     194    memset(&notifyData, 0, sizeof(notifyData));
     195    notifyData.cbSize           = sizeof(notifyData);
     196    notifyData.hWnd             = (HWND) m_hWnd;
     197    notifyData.uID              = 99;
     198    notifyData.uCallbackMessage = sm_taskbarMsg;
     199    notifyData.uFlags           = NIF_TIP;
     200    notifyData.uVersion         = NOTIFYICON_VERSION;
     201
     202    lstrcpyn(notifyData.szTip, WXSTRINGCAST tip, sizeof(notifyData.szTip));
     203
     204    if (m_iconAdded)
     205        return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0);
     206    else
     207    {
     208        m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
     209        if (IsBalloonsSupported())
     210            Shell_NotifyIcon(NIM_SETVERSION, &notifyData);
     211        return m_iconAdded;
     212    }
     213}
     214
     215
    189216bool wxTaskBarIconEx::RemoveIcon(void)
    190217{
    191218    if (!m_iconAdded)
  • msw/taskbarex.h

     
    5757        unsigned int iconballoon = NIIF_INFO
    5858    );
    5959
     60        bool SetTooltip(const wxString tip);
     61
    6062    bool RemoveIcon();
    6163
    6264    bool PopupMenu(wxMenu *menu); //, int x, int y);