Bug 697546 - Add a scriptable way to set a dock badge text. r=smichaud,josh

This commit is contained in:
Florian Quèze 2011-12-05 10:57:45 +01:00
parent ccd90b443d
commit be615f9108
3 changed files with 31 additions and 1 deletions

View File

@ -42,7 +42,7 @@ interface nsIStandaloneNativeMenu;
* Allow applications to interface with the Mac OS X Dock.
*/
[scriptable, uuid(CBC8A835-0733-470B-A51D-B7EBBFA88689)]
[scriptable, uuid(8BE66B0C-5F71-4B74-98CF-6C2551B999B1)]
interface nsIMacDockSupport : nsISupports
{
/**
@ -60,4 +60,9 @@ interface nsIMacDockSupport : nsISupports
* application activates regardless.
*/
void activateApplication(in boolean aIgnoreOtherApplications);
/**
* Text used to badge the dock tile.
*/
attribute AString badgeText;
};

View File

@ -38,6 +38,7 @@
#include "nsIMacDockSupport.h"
#include "nsIStandaloneNativeMenu.h"
#include "nsCOMPtr.h"
#include "nsString.h"
class nsMacDockSupport : public nsIMacDockSupport
{
@ -50,4 +51,5 @@ public:
protected:
nsCOMPtr<nsIStandaloneNativeMenu> mDockMenu;
nsString mBadgeText;
};

View File

@ -71,3 +71,26 @@ nsMacDockSupport::ActivateApplication(bool aIgnoreOtherApplications)
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP
nsMacDockSupport::SetBadgeText(const nsAString& aBadgeText)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
NSDockTile *tile = [[NSApplication sharedApplication] dockTile];
mBadgeText = aBadgeText;
if (aBadgeText.IsEmpty())
[tile setBadgeLabel: nil];
else
[tile setBadgeLabel:[NSString stringWithCharacters:mBadgeText.get() length:mBadgeText.Length()]];
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP
nsMacDockSupport::GetBadgeText(nsAString& aBadgeText)
{
aBadgeText = mBadgeText;
return NS_OK;
}