2018-01-12 03:09:26 -05:00
|
|
|
function Controller()
|
|
|
|
{
|
|
|
|
this.menu = {default:{}};
|
|
|
|
this.mode = "default";
|
|
|
|
|
|
|
|
this.app = require('electron').remote.app;
|
|
|
|
|
|
|
|
this.start = function()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
this.add = function(mode,cat,label,fn,accelerator)
|
|
|
|
{
|
|
|
|
if(!this.menu[mode]){ this.menu[mode] = {}; }
|
|
|
|
if(!this.menu[mode][cat]){ this.menu[mode][cat] = {}; }
|
|
|
|
this.menu[mode][cat][label] = {fn:fn,accelerator:accelerator};
|
2018-01-12 22:03:21 -05:00
|
|
|
console.log(`${mode}/${cat}/${label} <${accelerator}>`);
|
2018-01-12 03:09:26 -05:00
|
|
|
}
|
|
|
|
|
2018-01-12 22:03:21 -05:00
|
|
|
this.format = function()
|
2018-01-12 03:09:26 -05:00
|
|
|
{
|
|
|
|
var f = [];
|
|
|
|
var m = this.menu[this.mode];
|
|
|
|
for(cat in m){
|
|
|
|
var submenu = [];
|
|
|
|
for(name in m[cat]){
|
|
|
|
var option = m[cat][name];
|
|
|
|
submenu.push({label:name,accelerator:option.accelerator,click:option.fn})
|
|
|
|
}
|
|
|
|
f.push({label:cat,submenu:submenu});
|
|
|
|
}
|
2018-01-12 22:03:21 -05:00
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.commit = function()
|
|
|
|
{
|
|
|
|
this.app.inject_menu(this.format());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.docs = function()
|
|
|
|
{
|
|
|
|
console.log("Generating docs..");
|
|
|
|
this.app.generate_docs(this.format());
|
2018-01-12 03:09:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new Controller();
|