MCPcopy Create free account
hub / github.com/breach/thrust / CallLocalMethod

Method CallLocalMethod

src/api/thrust_menu_binding.cc:48–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48void
49ThrustMenuBinding::CallLocalMethod(
50 const std::string& method,
51 scoped_ptr<base::DictionaryValue> args,
52 const API::MethodCallback& callback)
53{
54 std::string err = std::string("");
55 base::DictionaryValue* res = new base::DictionaryValue;
56
57 LOG(INFO) << "ThrustMenu call [" << method << "]";
58 if(method.compare("add_item") == 0 ||
59 method.compare("add_check_item") == 0 ||
60 method.compare("add_radio_item") == 0 ||
61 method.compare("add_separator") == 0) {
62 int command_id = -1;
63 int group_id = -1;
64 std::string label = "NO-LABEL";
65
66 args->GetString("label", &label);
67 args->GetInteger("command_id", &command_id);
68 args->GetInteger("group_id", &group_id);
69
70 if(method.compare("add_item") == 0) {
71 menu_->AddItem(command_id, base::UTF8ToUTF16(label));
72 }
73 if(method.compare("add_check_item") == 0) {
74 menu_->AddCheckItem(command_id, base::UTF8ToUTF16(label));
75 }
76 if(method.compare("add_radio_item") == 0) {
77 menu_->AddRadioItem(command_id, base::UTF8ToUTF16(label), group_id);
78 }
79 if(method.compare("add_separator") == 0) {
80 menu_->AddSeparator();
81 }
82 }
83 else if(method.compare("set_checked") == 0 ||
84 method.compare("set_enabled") == 0 ||
85 method.compare("set_visible") == 0) {
86 int command_id = -1;
87 bool value = false;
88
89 args->GetInteger("command_id", &command_id);
90 args->GetBoolean("value", &value);
91
92 if(method.compare("set_checked") == 0) {
93 menu_->SetChecked(command_id, value);
94 }
95 if(method.compare("set_enabled") == 0) {
96 menu_->SetEnabled(command_id, value);
97 }
98 if(method.compare("set_visible") == 0) {
99 menu_->SetVisible(command_id, value);
100 }
101 }
102 else if(method.compare("set_accelerator") == 0) {
103 int command_id = -1;
104 std::string accelerator = "";
105

Callers 1

CallMethodMethod · 0.45

Calls 15

GetStringMethod · 0.80
AddItemMethod · 0.80
AddCheckItemMethod · 0.80
AddRadioItemMethod · 0.80
AddSeparatorMethod · 0.80
SetCheckedMethod · 0.80
SetEnabledMethod · 0.80
SetVisibleMethod · 0.80
SetAcceleratorMethod · 0.80
AddSubMenuMethod · 0.80
GetMenuMethod · 0.80
GetWindowMethod · 0.80

Tested by

no test coverage detected