Ticket #1116: 0001-Fix-Linux-notifications-to-use-libnotify-0.7.patch

File 0001-Fix-Linux-notifications-to-use-libnotify-0.7.patch, 5.2 KB (added by MattArsenault, 13 years ago)
  • clientgui/gtk/taskbarex.cpp

    From 6ec5ec5089f01593b75484c62ffea8c27617654e Mon Sep 17 00:00:00 2001
    From: Matt Arsenault <arsenm2@rpi.edu>
    Date: Wed, 22 Jun 2011 18:15:08 -0400
    Subject: [PATCH 1/6] Fix Linux notifications to use libnotify 0.7
    
    ---
     clientgui/gtk/taskbarex.cpp |   68 ++++++++++++++----------------------------
     1 files changed, 23 insertions(+), 45 deletions(-)
    
    diff --git a/clientgui/gtk/taskbarex.cpp b/clientgui/gtk/taskbarex.cpp
    index b87b06d..4255817 100644
    a b  
    1313#pragma implementation "taskbarex.h"
    1414#endif
    1515
    16 #include "stdwx.h"
    17 
    18 #ifndef __GTK_H__
    1916#define GSocket GlibGSocket
    2017#include <gtk/gtk.h>
    2118#undef GSocket
    22 #endif
    2319
    24 #ifndef _LIBNOTIFY_NOTIFY_H_
    25 #include <libnotify/notify.h>
    26 #endif
    2720
     21#include "stdwx.h"
     22
     23#include <libnotify/notify.h>
    2824#include <glib/gtypes.h>
    2925#include <glib-object.h>
    3026
     
    3329#include "BOINCTaskBar.h"
    3430
    3531
    36 GtkStatusIcon*      g_pStatusIcon;
    37 NotifyNotification* g_pNotification;
     32static GtkStatusIcon*      g_pStatusIcon = NULL;
     33static NotifyNotification* g_pNotification = NULL;
    3834
    3935
    4036//-----------------------------------------------------------------------------
    4137
    4238extern "C" {
    43 
    4439    static void
    4540    status_icon_activate(GtkStatusIcon*, wxTaskBarIconEx* taskBarIcon)
    4641    {
    extern "C" { 
    5853    }
    5954
    6055    static void
    61     statis_icon_notification_actions(NotifyNotification* notification, gchar *action, wxTaskBarIconEx* taskBarIcon)
     56    status_icon_notification_actions(NotifyNotification* notification, gchar *action, wxTaskBarIconEx* taskBarIcon)
    6257    {
    6358        if (strcmp(action, "default") == 0) {
    6459            taskBarIcon->FireUserClickedEvent();
    extern "C" { 
    6661    }
    6762
    6863    static void
    69     statis_icon_notification_closed(NotifyNotification* notification, wxTaskBarIconEx* taskBarIcon)
     64    status_icon_notification_closed(NotifyNotification* notification, wxTaskBarIconEx* taskBarIcon)
    7065    {
    7166        if (taskBarIcon->IsUserClicked()) {
    7267            wxTaskBarIconExEvent eventUserClicked(wxEVT_TASKBAR_BALLOON_USERCLICK, taskBarIcon);
    extern "C" { 
    7873
    7974        taskBarIcon->ClearEvents();
    8075    }
    81 
    8276}
    8377
    8478
    8579//-----------------------------------------------------------------------------
    8680
    8781
    88 wxChar* wxTaskBarExWindow      = (wxChar*) wxT("wxTaskBarExWindow");
     82static wxChar* wxTaskBarExWindow      = (wxChar*) wxT("wxTaskBarExWindow");
    8983
    9084
    9185DEFINE_EVENT_TYPE( wxEVT_TASKBAR_CREATED )
    wxTaskBarIconEx::wxTaskBarIconEx() 
    110104    m_iTaskbarID = 1;
    111105    g_pStatusIcon = NULL;
    112106    g_pNotification = NULL;
    113 
    114107    notify_init((const char*)wxString(wxTaskBarExWindow).mb_str());
    115108}
    116109
    wxTaskBarIconEx::wxTaskBarIconEx( wxChar* szWindowTitle, wxInt32 iTaskbarID ) 
    125118    notify_init((const char*)wxString(szWindowTitle).mb_str());
    126119}
    127120
    128 wxTaskBarIconEx::~wxTaskBarIconEx()
     121static void exitNotificationAndIcons(wxWindow* m_pWnd)
    129122{
    130     m_bUserClicked = false;
    131 
    132123    if (m_pWnd)
    133124    {
    134125        m_pWnd->PopEventHandler();
    wxTaskBarIconEx::~wxTaskBarIconEx() 
    145136    if (g_pNotification)
    146137    {
    147138        notify_notification_close(g_pNotification, NULL);
    148         notify_uninit();
    149139        g_pNotification = NULL;
    150140    }
    151141}
    152142
     143wxTaskBarIconEx::~wxTaskBarIconEx()
     144{
     145    m_bUserClicked = false;
     146    exitNotificationAndIcons(m_pWnd);
     147
     148}
     149
    153150bool wxTaskBarIconEx::IsIconInstalled() const {
    154     return g_pStatusIcon;
     151    return (g_pStatusIcon != NULL);
    155152}
    156153
    157154void wxTaskBarIconEx::ClearEvents() {
    bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const 
    226223
    227224    if (!g_pNotification)
    228225    {
    229         g_pNotification = 
    230             notify_notification_new_with_status_icon(
     226        g_pNotification =
     227            notify_notification_new(
    231228                title.mb_str(),
    232229                message.mb_str(),
    233                 desired_icon,
    234                 g_pStatusIcon
     230                gtk_status_icon_get_icon_name(g_pStatusIcon)
    235231        );
    236232
    237233        g_signal_connect(
    238234            g_pNotification,
    239235            "closed",
    240             G_CALLBACK(statis_icon_notification_closed),
     236            G_CALLBACK(status_icon_notification_closed),
    241237            this
    242238        );
    243239
    bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const 
    245241            g_pNotification,
    246242            "default",
    247243            "Do Default Action",
    248             NOTIFY_ACTION_CALLBACK(statis_icon_notification_actions),
     244            NOTIFY_ACTION_CALLBACK(status_icon_notification_actions),
    249245            this,
    250246            NULL
    251247        );
    bool wxTaskBarIconEx::RemoveIcon() 
    278274    if (!IsOK())
    279275        return false;
    280276
    281     if (m_pWnd)
    282     {
    283         m_pWnd->PopEventHandler();
    284         m_pWnd->Destroy();
    285         m_pWnd = NULL;
    286     }
    287 
    288     if (g_pStatusIcon)
    289     {
    290         g_object_unref(g_pStatusIcon);
    291         g_pStatusIcon = NULL;
    292     }
    293 
    294     if (g_pNotification)
    295     {
    296         notify_notification_close(g_pNotification, NULL);
    297         g_pNotification = NULL;
    298     }
    299 
     277    exitNotificationAndIcons(m_pWnd);
    300278    return true;
    301279}
    302280