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
|
|
| 13 | 13 | #pragma implementation "taskbarex.h" |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | | #include "stdwx.h" |
| 17 | | |
| 18 | | #ifndef __GTK_H__ |
| 19 | 16 | #define GSocket GlibGSocket |
| 20 | 17 | #include <gtk/gtk.h> |
| 21 | 18 | #undef GSocket |
| 22 | | #endif |
| 23 | 19 | |
| 24 | | #ifndef _LIBNOTIFY_NOTIFY_H_ |
| 25 | | #include <libnotify/notify.h> |
| 26 | | #endif |
| 27 | 20 | |
| | 21 | #include "stdwx.h" |
| | 22 | |
| | 23 | #include <libnotify/notify.h> |
| 28 | 24 | #include <glib/gtypes.h> |
| 29 | 25 | #include <glib-object.h> |
| 30 | 26 | |
| … |
… |
|
| 33 | 29 | #include "BOINCTaskBar.h" |
| 34 | 30 | |
| 35 | 31 | |
| 36 | | GtkStatusIcon* g_pStatusIcon; |
| 37 | | NotifyNotification* g_pNotification; |
| | 32 | static GtkStatusIcon* g_pStatusIcon = NULL; |
| | 33 | static NotifyNotification* g_pNotification = NULL; |
| 38 | 34 | |
| 39 | 35 | |
| 40 | 36 | //----------------------------------------------------------------------------- |
| 41 | 37 | |
| 42 | 38 | extern "C" { |
| 43 | | |
| 44 | 39 | static void |
| 45 | 40 | status_icon_activate(GtkStatusIcon*, wxTaskBarIconEx* taskBarIcon) |
| 46 | 41 | { |
| … |
… |
extern "C" { |
| 58 | 53 | } |
| 59 | 54 | |
| 60 | 55 | static void |
| 61 | | statis_icon_notification_actions(NotifyNotification* notification, gchar *action, wxTaskBarIconEx* taskBarIcon) |
| | 56 | status_icon_notification_actions(NotifyNotification* notification, gchar *action, wxTaskBarIconEx* taskBarIcon) |
| 62 | 57 | { |
| 63 | 58 | if (strcmp(action, "default") == 0) { |
| 64 | 59 | taskBarIcon->FireUserClickedEvent(); |
| … |
… |
extern "C" { |
| 66 | 61 | } |
| 67 | 62 | |
| 68 | 63 | static void |
| 69 | | statis_icon_notification_closed(NotifyNotification* notification, wxTaskBarIconEx* taskBarIcon) |
| | 64 | status_icon_notification_closed(NotifyNotification* notification, wxTaskBarIconEx* taskBarIcon) |
| 70 | 65 | { |
| 71 | 66 | if (taskBarIcon->IsUserClicked()) { |
| 72 | 67 | wxTaskBarIconExEvent eventUserClicked(wxEVT_TASKBAR_BALLOON_USERCLICK, taskBarIcon); |
| … |
… |
extern "C" { |
| 78 | 73 | |
| 79 | 74 | taskBarIcon->ClearEvents(); |
| 80 | 75 | } |
| 81 | | |
| 82 | 76 | } |
| 83 | 77 | |
| 84 | 78 | |
| 85 | 79 | //----------------------------------------------------------------------------- |
| 86 | 80 | |
| 87 | 81 | |
| 88 | | wxChar* wxTaskBarExWindow = (wxChar*) wxT("wxTaskBarExWindow"); |
| | 82 | static wxChar* wxTaskBarExWindow = (wxChar*) wxT("wxTaskBarExWindow"); |
| 89 | 83 | |
| 90 | 84 | |
| 91 | 85 | DEFINE_EVENT_TYPE( wxEVT_TASKBAR_CREATED ) |
| … |
… |
wxTaskBarIconEx::wxTaskBarIconEx() |
| 110 | 104 | m_iTaskbarID = 1; |
| 111 | 105 | g_pStatusIcon = NULL; |
| 112 | 106 | g_pNotification = NULL; |
| 113 | | |
| 114 | 107 | notify_init((const char*)wxString(wxTaskBarExWindow).mb_str()); |
| 115 | 108 | } |
| 116 | 109 | |
| … |
… |
wxTaskBarIconEx::wxTaskBarIconEx( wxChar* szWindowTitle, wxInt32 iTaskbarID ) |
| 125 | 118 | notify_init((const char*)wxString(szWindowTitle).mb_str()); |
| 126 | 119 | } |
| 127 | 120 | |
| 128 | | wxTaskBarIconEx::~wxTaskBarIconEx() |
| | 121 | static void exitNotificationAndIcons(wxWindow* m_pWnd) |
| 129 | 122 | { |
| 130 | | m_bUserClicked = false; |
| 131 | | |
| 132 | 123 | if (m_pWnd) |
| 133 | 124 | { |
| 134 | 125 | m_pWnd->PopEventHandler(); |
| … |
… |
wxTaskBarIconEx::~wxTaskBarIconEx() |
| 145 | 136 | if (g_pNotification) |
| 146 | 137 | { |
| 147 | 138 | notify_notification_close(g_pNotification, NULL); |
| 148 | | notify_uninit(); |
| 149 | 139 | g_pNotification = NULL; |
| 150 | 140 | } |
| 151 | 141 | } |
| 152 | 142 | |
| | 143 | wxTaskBarIconEx::~wxTaskBarIconEx() |
| | 144 | { |
| | 145 | m_bUserClicked = false; |
| | 146 | exitNotificationAndIcons(m_pWnd); |
| | 147 | |
| | 148 | } |
| | 149 | |
| 153 | 150 | bool wxTaskBarIconEx::IsIconInstalled() const { |
| 154 | | return g_pStatusIcon; |
| | 151 | return (g_pStatusIcon != NULL); |
| 155 | 152 | } |
| 156 | 153 | |
| 157 | 154 | void wxTaskBarIconEx::ClearEvents() { |
| … |
… |
bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const |
| 226 | 223 | |
| 227 | 224 | if (!g_pNotification) |
| 228 | 225 | { |
| 229 | | g_pNotification = |
| 230 | | notify_notification_new_with_status_icon( |
| | 226 | g_pNotification = |
| | 227 | notify_notification_new( |
| 231 | 228 | title.mb_str(), |
| 232 | 229 | message.mb_str(), |
| 233 | | desired_icon, |
| 234 | | g_pStatusIcon |
| | 230 | gtk_status_icon_get_icon_name(g_pStatusIcon) |
| 235 | 231 | ); |
| 236 | 232 | |
| 237 | 233 | g_signal_connect( |
| 238 | 234 | g_pNotification, |
| 239 | 235 | "closed", |
| 240 | | G_CALLBACK(statis_icon_notification_closed), |
| | 236 | G_CALLBACK(status_icon_notification_closed), |
| 241 | 237 | this |
| 242 | 238 | ); |
| 243 | 239 | |
| … |
… |
bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const |
| 245 | 241 | g_pNotification, |
| 246 | 242 | "default", |
| 247 | 243 | "Do Default Action", |
| 248 | | NOTIFY_ACTION_CALLBACK(statis_icon_notification_actions), |
| | 244 | NOTIFY_ACTION_CALLBACK(status_icon_notification_actions), |
| 249 | 245 | this, |
| 250 | 246 | NULL |
| 251 | 247 | ); |
| … |
… |
bool wxTaskBarIconEx::RemoveIcon() |
| 278 | 274 | if (!IsOK()) |
| 279 | 275 | return false; |
| 280 | 276 | |
| 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); |
| 300 | 278 | return true; |
| 301 | 279 | } |
| 302 | 280 | |