From eb0caf8201ed2b5507401a7127624b64ca2f51fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Tue, 21 Dec 2010 20:21:05 +0100 Subject: Make dock get the number of pending messages (instead of a generic message). diff --git a/SwifTools/Dock/Dock.h b/SwifTools/Dock/Dock.h index a1c652d..2dd312c 100644 --- a/SwifTools/Dock/Dock.h +++ b/SwifTools/Dock/Dock.h @@ -13,6 +13,6 @@ namespace Swift { public: virtual ~Dock(); - virtual void setMessage(const String& message) = 0; + virtual void setNumberOfPendingMessages(int i) = 0; }; } diff --git a/SwifTools/Dock/MacOSXDock.h b/SwifTools/Dock/MacOSXDock.h index e9667a6..511a652 100644 --- a/SwifTools/Dock/MacOSXDock.h +++ b/SwifTools/Dock/MacOSXDock.h @@ -16,6 +16,6 @@ namespace Swift { public: MacOSXDock(CocoaApplication* application); - void setMessage(const String& label); + virtual void setNumberOfPendingMessages(int i); }; } diff --git a/SwifTools/Dock/MacOSXDock.mm b/SwifTools/Dock/MacOSXDock.mm index d2a06b3..0438353 100644 --- a/SwifTools/Dock/MacOSXDock.mm +++ b/SwifTools/Dock/MacOSXDock.mm @@ -2,6 +2,7 @@ #include #include +#include #include "Swiften/Base/String.h" @@ -10,7 +11,8 @@ namespace Swift { MacOSXDock::MacOSXDock(CocoaApplication*) { } -void MacOSXDock::setMessage(const String& label) { +void MacOSXDock::setNumberOfPendingMessages(int i) { + String label(i > 0 ? boost::lexical_cast(i) : ""); NSString *labelString = [[NSString alloc] initWithUTF8String: label.getUTF8Data()]; [[NSApp dockTile] setBadgeLabel: labelString]; [labelString release]; diff --git a/SwifTools/Dock/NullDock.h b/SwifTools/Dock/NullDock.h index f2d27b7..1dbb892 100644 --- a/SwifTools/Dock/NullDock.h +++ b/SwifTools/Dock/NullDock.h @@ -13,7 +13,7 @@ namespace Swift { public: NullDock() {} - virtual void setMessage(const String&) { + virtual void setNumberOfPendingMessages(int i) { } }; } diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 9499e17..6e57a8f 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -261,7 +261,7 @@ void MainController::handleConnected() { } void MainController::handleEventQueueLengthChange(int count) { - dock_->setMessage(count == 0 ? "" : boost::lexical_cast(count).c_str()); + dock_->setNumberOfPendingMessages(count); } void MainController::reconnectAfterError() { -- cgit v0.10.2-6-g49f6