2013-05-06 12:27:09 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/api/atom_api_menu.h"
|
2013-05-06 12:27:09 +00:00
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/ui/accelerator_util.h"
|
|
|
|
#include "atom/common/v8/node_common.h"
|
|
|
|
#include "atom/common/v8/native_type_conversions.h"
|
2013-05-14 11:26:16 +00:00
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
#define UNWRAP_MEMNU_AND_CHECK \
|
|
|
|
Menu* self = ObjectWrap::Unwrap<Menu>(args.This()); \
|
|
|
|
if (self == NULL) \
|
|
|
|
return node::ThrowError("Menu is already destroyed")
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
namespace {
|
|
|
|
|
2013-05-14 11:26:16 +00:00
|
|
|
// Call method of delegate object.
|
|
|
|
v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
|
|
|
|
v8::Handle<v8::Object> menu,
|
|
|
|
const char* method,
|
|
|
|
int command_id) {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 11:26:16 +00:00
|
|
|
|
|
|
|
v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
|
|
|
|
if (!delegate->IsObject())
|
|
|
|
return default_value;
|
|
|
|
|
|
|
|
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(
|
|
|
|
delegate->ToObject()->Get(v8::String::New(method)));
|
|
|
|
if (!function->IsFunction())
|
|
|
|
return default_value;
|
|
|
|
|
2013-05-16 07:32:37 +00:00
|
|
|
v8::Handle<v8::Value> argv = v8::Integer::New(command_id);
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
return handle_scope.Close(
|
2013-05-16 07:32:37 +00:00
|
|
|
function->Call(v8::Context::GetCurrent()->Global(), 1, &argv));
|
2013-05-14 11:26:16 +00:00
|
|
|
}
|
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
Menu::Menu(v8::Handle<v8::Object> wrapper)
|
|
|
|
: EventEmitter(wrapper),
|
|
|
|
model_(new ui::SimpleMenuModel(this)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Menu::~Menu() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Menu::IsCommandIdChecked(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 11:26:16 +00:00
|
|
|
return CallDelegate(v8::False(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-05-14 11:26:16 +00:00
|
|
|
"isCommandIdChecked",
|
|
|
|
command_id)->BooleanValue();
|
2013-05-06 12:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Menu::IsCommandIdEnabled(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 11:26:16 +00:00
|
|
|
return CallDelegate(v8::True(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-05-14 11:26:16 +00:00
|
|
|
"isCommandIdEnabled",
|
|
|
|
command_id)->BooleanValue();
|
2013-05-06 12:27:09 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 08:50:56 +00:00
|
|
|
bool Menu::IsCommandIdVisible(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 11:26:16 +00:00
|
|
|
return CallDelegate(v8::True(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-05-14 11:26:16 +00:00
|
|
|
"isCommandIdVisible",
|
|
|
|
command_id)->BooleanValue();
|
2013-05-14 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
bool Menu::GetAcceleratorForCommandId(int command_id,
|
2013-05-14 11:26:16 +00:00
|
|
|
ui::Accelerator* accelerator) {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 13:37:59 +00:00
|
|
|
v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
|
|
|
|
handle(),
|
|
|
|
"getAcceleratorForCommandId",
|
|
|
|
command_id);
|
|
|
|
if (shortcut->IsString()) {
|
2013-09-24 01:41:54 +00:00
|
|
|
std::string shortcut_str = FromV8Value(shortcut);
|
2013-05-14 13:37:59 +00:00
|
|
|
return accelerator_util::StringToAccelerator(shortcut_str, accelerator);
|
|
|
|
}
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-14 08:50:56 +00:00
|
|
|
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-14 11:26:16 +00:00
|
|
|
return CallDelegate(v8::False(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-05-14 11:26:16 +00:00
|
|
|
"isItemForCommandIdDynamic",
|
|
|
|
command_id)->BooleanValue();
|
2013-05-14 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string16 Menu::GetLabelForCommandId(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-09-23 15:00:58 +00:00
|
|
|
return FromV8Value(CallDelegate(v8::False(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-09-23 15:00:58 +00:00
|
|
|
"getLabelForCommandId",
|
|
|
|
command_id));
|
2013-05-14 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string16 Menu::GetSublabelForCommandId(int command_id) const {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-09-23 15:00:58 +00:00
|
|
|
return FromV8Value(CallDelegate(v8::False(),
|
2013-12-11 15:57:37 +00:00
|
|
|
const_cast<Menu*>(this)->handle(),
|
2013-09-23 15:00:58 +00:00
|
|
|
"getSubLabelForCommandId",
|
|
|
|
command_id));
|
2013-05-14 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
void Menu::ExecuteCommand(int command_id, int event_flags) {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-05-16 12:06:25 +00:00
|
|
|
CallDelegate(v8::False(), handle(), "executeCommand", command_id);
|
2013-05-06 12:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 12:27:09 +00:00
|
|
|
if (!args.IsConstructCall())
|
|
|
|
return node::ThrowError("Require constructor call");
|
|
|
|
|
|
|
|
Menu::Create(args.This());
|
|
|
|
}
|
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::InsertItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index, command_id;
|
|
|
|
string16 label;
|
|
|
|
if (!FromV8Arguments(args, &index, &command_id, &label))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
if (index < 0)
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->AddItem(command_id, label);
|
2013-05-06 16:03:34 +00:00
|
|
|
else
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->InsertItemAt(index, command_id, label);
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::InsertCheckItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index, command_id;
|
|
|
|
string16 label;
|
|
|
|
if (!FromV8Arguments(args, &index, &command_id, &label))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
if (index < 0)
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->AddCheckItem(command_id, label);
|
2013-05-06 16:03:34 +00:00
|
|
|
else
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->InsertCheckItemAt(index, command_id, label);
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::InsertRadioItem(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index, command_id, group_id;
|
|
|
|
string16 label;
|
|
|
|
if (!FromV8Arguments(args, &index, &command_id, &label, &group_id))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
if (index < 0)
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->AddRadioItem(command_id, label, group_id);
|
2013-05-06 16:03:34 +00:00
|
|
|
else
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->InsertRadioItemAt(index, command_id, label, group_id);
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::InsertSeparator(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index;
|
|
|
|
if (!FromV8Arguments(args, &index))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
self->model_->AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
|
else
|
|
|
|
self->model_->InsertSeparatorAt(index, ui::NORMAL_SEPARATOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::InsertSubMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index, command_id;
|
|
|
|
string16 label;
|
|
|
|
if (!FromV8Arguments(args, &index, &command_id, &label))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
Menu* submenu = ObjectWrap::Unwrap<Menu>(args[3]->ToObject());
|
|
|
|
if (!submenu)
|
|
|
|
return node::ThrowTypeError("The submenu is already destroyed");
|
|
|
|
|
|
|
|
if (index < 0)
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->AddSubMenu(command_id, label, submenu->model_.get());
|
2013-05-06 16:03:34 +00:00
|
|
|
else
|
|
|
|
self->model_->InsertSubMenuAt(
|
2013-09-24 01:41:54 +00:00
|
|
|
index, command_id, label, submenu->model_.get());
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::SetIcon(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index;
|
|
|
|
base::FilePath path;
|
|
|
|
if (!FromV8Arguments(args, &index, &path))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
// FIXME use webkit_glue's image decoder here.
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::SetSublabel(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index;
|
|
|
|
string16 label;
|
|
|
|
if (!FromV8Arguments(args, &index, &label))
|
2013-05-06 16:03:34 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->model_->SetSublabel(index, label);
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
self->model_->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-15 09:09:35 +00:00
|
|
|
void Menu::GetIndexOfCommandId(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(self->model_->GetIndexOfCommandId(index));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::GetItemCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->model_->GetItemCount());
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::GetCommandIdAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(self->model_->GetCommandIdAt(index));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::GetLabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(ToV8Value(self->model_->GetLabelAt(index)));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::GetSublabelAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(ToV8Value(self->model_->GetSublabelAt(index)));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::IsItemCheckedAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(self->model_->IsItemCheckedAt(index));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::IsEnabledAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(self->model_->IsEnabledAt(index));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::IsVisibleAt(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-06 16:03:34 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
int index = FromV8Value(args[0]);
|
|
|
|
args.GetReturnValue().Set(self->model_->IsVisibleAt(index));
|
2013-05-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 08:50:56 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::Popup(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-14 08:50:56 +00:00
|
|
|
UNWRAP_MEMNU_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
atom::NativeWindow* window;
|
|
|
|
if (!FromV8Arguments(args, &window))
|
|
|
|
return node::ThrowTypeError("Bad argument");
|
2013-05-14 08:50:56 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->Popup(window);
|
2013-05-14 08:50:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
// static
|
|
|
|
void Menu::Initialize(v8::Handle<v8::Object> target) {
|
|
|
|
v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
|
|
|
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
|
|
|
t->SetClassName(v8::String::NewSymbol("Menu"));
|
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "insertItem", InsertItem);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "insertCheckItem", InsertCheckItem);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "insertRadioItem", InsertRadioItem);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "insertSeparator", InsertSeparator);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "insertSubMenu", InsertSubMenu);
|
2013-05-14 08:50:56 +00:00
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setIcon", SetIcon);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setSublabel", SetSublabel);
|
2013-05-14 08:50:56 +00:00
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "clear", Clear);
|
2013-05-14 08:50:56 +00:00
|
|
|
|
2013-05-06 16:03:34 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getIndexOfCommandId", GetIndexOfCommandId);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getItemCount", GetItemCount);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getCommandIdAt", GetCommandIdAt);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getLabelAt", GetLabelAt);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getSublabelAt", GetSublabelAt);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isItemCheckedAt", IsItemCheckedAt);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isEnabledAt", IsEnabledAt);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isVisibleAt", IsVisibleAt);
|
|
|
|
|
2013-05-14 08:50:56 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "popup", Popup);
|
|
|
|
|
2014-02-19 13:10:09 +00:00
|
|
|
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
|
2013-10-02 13:24:21 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "attachToWindow", AttachToWindow);
|
|
|
|
#endif
|
|
|
|
|
2013-05-06 12:27:09 +00:00
|
|
|
target->Set(v8::String::NewSymbol("Menu"), t->GetFunction());
|
2013-05-16 02:54:37 +00:00
|
|
|
|
2013-05-16 12:31:58 +00:00
|
|
|
#if defined(OS_MACOSX)
|
2013-05-16 02:54:37 +00:00
|
|
|
NODE_SET_METHOD(target, "setApplicationMenu", SetApplicationMenu);
|
2013-05-16 09:25:02 +00:00
|
|
|
NODE_SET_METHOD(
|
|
|
|
target, "sendActionToFirstResponder", SendActionToFirstResponder);
|
2013-05-16 12:31:58 +00:00
|
|
|
#endif
|
2013-05-06 12:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
NODE_MODULE(atom_browser_menu, atom::api::Menu::Initialize)
|