[Mac] Add app.dock.getBadge() API.
This commit is contained in:
parent
b1f88d680b
commit
ea1f81aa52
5 changed files with 16 additions and 1 deletions
|
@ -169,6 +169,12 @@ v8::Handle<v8::Value> App::DockSetBadgeText(const v8::Arguments& args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::DockGetBadgeText(const v8::Arguments& args) {
|
||||
std::string text(Browser::Get()->DockGetBadgeText());
|
||||
return v8::String::New(text.data(), text.size());
|
||||
}
|
||||
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// static
|
||||
|
@ -194,6 +200,7 @@ void App::Initialize(v8::Handle<v8::Object> target) {
|
|||
NODE_SET_METHOD(target, "dockBounce", DockBounce);
|
||||
NODE_SET_METHOD(target, "dockCancelBounce", DockCancelBounce);
|
||||
NODE_SET_METHOD(target, "dockSetBadgeText", DockSetBadgeText);
|
||||
NODE_SET_METHOD(target, "dockGetBadgeText", DockGetBadgeText);
|
||||
#endif // defined(OS_MACOSX)
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class App : public EventEmitter,
|
|||
static v8::Handle<v8::Value> DockBounce(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockCancelBounce(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockSetBadgeText(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DockGetBadgeText(const v8::Arguments& args);
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
|
|
|
@ -18,6 +18,7 @@ if process.platform is 'darwin'
|
|||
bounce: (type = 'informational') -> bindings.dockBounce type
|
||||
cancelBounce: bindings.dockCancelBounce
|
||||
setBadge: bindings.dockSetBadgeText
|
||||
getBadge: bindings.dockGetBadgeText
|
||||
|
||||
# Only one App object pemitted.
|
||||
module.exports = app
|
||||
|
|
|
@ -42,8 +42,9 @@ class Browser : public WindowListObserver {
|
|||
int DockBounce(BounceType type);
|
||||
void DockCancelBounce(int request_id);
|
||||
|
||||
// Set dock's badge text.
|
||||
// Set/Get dock's badge text.
|
||||
void DockSetBadgeText(const std::string& label);
|
||||
std::string DockGetBadgeText();
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// Tell the application to open a file.
|
||||
|
|
|
@ -42,4 +42,9 @@ void Browser::DockSetBadgeText(const std::string& label) {
|
|||
[tile setBadgeLabel:base::SysUTF8ToNSString(label)];
|
||||
}
|
||||
|
||||
std::string Browser::DockGetBadgeText() {
|
||||
NSDockTile *tile = [[AtomApplication sharedApplication] dockTile];
|
||||
return base::SysNSStringToUTF8([tile badgeLabel]);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
Loading…
Reference in a new issue