return v8::Undefined();
}
+#if defined(OS_MACOSX)
+
+// static
+v8::Handle<v8::Value> App::DockBounce(const v8::Arguments& args) {
+ std::string type(*v8::String::Utf8Value(args[0]));
+ int request_id = -1;
+
+ if (type == "critical")
+ request_id = Browser::Get()->DockBounce(Browser::BOUNCE_CRITICAL);
+ else if (type == "informational")
+ request_id = Browser::Get()->DockBounce(Browser::BOUNCE_INFORMATIONAL);
+ else
+ return node::ThrowTypeError("Invalid bounce type");
+
+ return v8::Integer::New(request_id);
+}
+
+// static
+v8::Handle<v8::Value> App::DockCancelBounce(const v8::Arguments& args) {
+ Browser::Get()->DockCancelBounce(args[0]->IntegerValue());
+ return v8::Undefined();
+}
+
+// static
+v8::Handle<v8::Value> App::DockSetBadgeText(const v8::Arguments& args) {
+ std::string label(*v8::String::Utf8Value(args[0]));
+ Browser::Get()->DockSetBadgeText(label);
+ return v8::Undefined();
+}
+
+#endif // defined(OS_MACOSX)
+
// static
void App::Initialize(v8::Handle<v8::Object> target) {
v8::HandleScope scope;
NODE_SET_METHOD(target, "appendSwitch", AppendSwitch);
NODE_SET_METHOD(target, "appendArgument", AppendArgument);
+
+#if defined(OS_MACOSX)
+ NODE_SET_METHOD(target, "dockBounce", DockBounce);
+ NODE_SET_METHOD(target, "dockCancelBounce", DockCancelBounce);
+ NODE_SET_METHOD(target, "dockSetBadgeText", DockSetBadgeText);
+#endif // defined(OS_MACOSX)
}
} // namespace api
static v8::Handle<v8::Value> AppendSwitch(const v8::Arguments &args);
static v8::Handle<v8::Value> AppendArgument(const v8::Arguments &args);
+#if defined(OS_MACOSX)
+ 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);
+#endif // defined(OS_MACOSX)
+
DISALLOW_COPY_AND_ASSIGN(App);
};
appendSwitch: bindings.appendSwitch,
appendArgument: bindings.appendArgument
+if process.platform is 'darwin'
+ app.dock =
+ bounce: (type = 'informational') -> bindings.dockBounce type
+ cancelBounce: bindings.dockCancelBounce
+ setBadge: bindings.dockSetBadgeText
+
# Only one App object pemitted.
module.exports = app
// Returns the version of the executable (or bundle).
std::string GetVersion();
+#if defined(OS_MACOSX)
+ // Bounce the dock icon.
+ enum BounceType {
+ BOUNCE_CRITICAL = 0,
+ BOUNCE_INFORMATIONAL = 10,
+ };
+ int DockBounce(BounceType type);
+ void DockCancelBounce(int request_id);
+
+ // Set dock's badge text.
+ void DockSetBadgeText(const std::string& label);
+#endif // defined(OS_MACOSX)
+
// Tell the application to open a file.
bool OpenFile(const std::string& file_path);
[[AtomApplication sharedApplication] replyToApplicationShouldTerminate:NO];
}
+int Browser::DockBounce(BounceType type) {
+ return [[AtomApplication sharedApplication] requestUserAttention:type];
+}
+
+void Browser::DockCancelBounce(int rid) {
+ [[AtomApplication sharedApplication] cancelUserAttentionRequest:rid];
+}
+
+void Browser::DockSetBadgeText(const std::string& label) {
+ NSDockTile *tile = [[AtomApplication sharedApplication] dockTile];
+ [tile setBadgeLabel:base::SysUTF8ToNSString(label)];
+}
+
} // namespace atom