mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 697546 - Add a scriptable way to set a dock badge text. r=smichaud,josh
This commit is contained in:
parent
ccd90b443d
commit
be615f9108
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user