Commit 99d9d809 authored by carlosperate's avatar carlosperate

Electron: Add menus to window, all non-functional for now.

parent 7aa50c66
...@@ -20,10 +20,18 @@ var BrowserWindow = require('browser-window'); ...@@ -20,10 +20,18 @@ var BrowserWindow = require('browser-window');
module.exports.setArdublocklyMenu = function(devMode) { module.exports.setArdublocklyMenu = function(devMode) {
if (typeof(devMode)==='undefined') devMode = false; if (typeof(devMode)==='undefined') devMode = false;
var ardublocklyMenu = [ var ardublocklyMenu = []
getFileMenuData(), if (process.platform == "darwin") {
getHelpMenuData(), ardublocklyMenu.push(getMacMenuData());
]; }
ardublocklyMenu.push(getFileMenuData());
ardublocklyMenu.push(getEditMenuData());
ardublocklyMenu.push(getProgramMenuData());
ardublocklyMenu.push(getExamplesMenuData());
if (process.platform == "darwin") {
ardublocklyMenu.push(getWindowMenuData());
}
ardublocklyMenu.push(getHelpMenuData());
if (devMode) { if (devMode) {
ardublocklyMenu.push(getDevMenuData()); ardublocklyMenu.push(getDevMenuData());
...@@ -32,11 +40,59 @@ module.exports.setArdublocklyMenu = function(devMode) { ...@@ -32,11 +40,59 @@ module.exports.setArdublocklyMenu = function(devMode) {
Menu.setApplicationMenu(Menu.buildFromTemplate(ardublocklyMenu)); Menu.setApplicationMenu(Menu.buildFromTemplate(ardublocklyMenu));
}; };
var getFileMenuData = function() { var getMacMenuData = function() {
return { return {
label: 'Ardublockly',
submenu: [
{
label: 'About',
click: functionNotImplemented
}, {
type: 'separator'
}, {
label: 'Preferences',
//accelerator: 'CmdOrCtrl+comma',
click: functionNotImplemented
}, {
type: 'separator'
}, {
label: 'Services',
submenu: []
}, {
type: 'separator'
}, {
label: 'Hide Ardublockly',
accelerator: 'Command+H',
selector: 'hide:'
}, {
label: 'Hide Others',
accelerator: 'Command+Shift+H',
selector: 'hideOtherApplications:'
}, {
label: 'Show All',
selector: 'unhideAllApplications:'
}, {
type: 'separator'
}, {
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: function() {
app.quit();
}
}
]
};
};
var getFileMenuData = function() {
var fileMenu = {
label: 'File', label: 'File',
submenu: [ submenu: [
{ {
label: 'New',
accelerator: 'CmdOrCtrl+N',
click: functionNotImplemented
}, {
label: 'Open', label: 'Open',
accelerator: 'CmdOrCtrl+O', accelerator: 'CmdOrCtrl+O',
click: functionNotImplemented click: functionNotImplemented
...@@ -44,13 +100,131 @@ var getFileMenuData = function() { ...@@ -44,13 +100,131 @@ var getFileMenuData = function() {
label: 'Save as', label: 'Save as',
accelerator: 'CmdOrCtrl+S', accelerator: 'CmdOrCtrl+S',
click: functionNotImplemented click: functionNotImplemented
}
]
};
// On MacOS the Quit option is in the app menu, so only add it if not mac
if (process.platform != "darwin") {
fileMenu.submenu.push(
{
type: 'separator'
}, { }, {
label: 'Quit', label: 'Quit',
accelerator: 'CmdOrCtrl+Q', accelerator: 'CmdOrCtrl+Q',
click: function () { click: function() {
app.quit(); app.quit();
} }
} }
);
}
return fileMenu;
};
var getEditMenuData = function() {
var editMenud = {
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
click: functionNotImplemented
}, {
label: 'Redo',
accelerator: 'CmdOrCtrl+Y',
click: functionNotImplemented
}, {
type: 'separator'
}, {
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
click: functionNotImplemented
}, {
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
click: functionNotImplemented
}, {
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
click: functionNotImplemented
}
]
};
// On MacOS Preferences is in the app menu, so only add it if not mac
if (process.platform != "darwin") {
editMenud.submenu.push(
{
type: 'separator'
}, {
label: 'Preferences',
//accelerator: 'CmdOrCtrl+comma',
click: functionNotImplemented
}
);
}
return editMenud;
};
var getExamplesMenuData = function() {
return {
label: 'Examples',
submenu: [
{
label: 'Example 1',
click: functionNotImplemented
}, {
label: 'Example 2',
click: functionNotImplemented
}, {
label: 'Example 3',
click: functionNotImplemented
}
]
};
};
var getProgramMenuData = function() {
return {
label: 'Program',
submenu: [
{
label: 'Open sketch in IDE',
//accelerator: 'CmdOrCtrl+O',
click: functionNotImplemented
}, {
label: 'Verify',
//accelerator: 'CmdOrCtrl+S',
click: functionNotImplemented
}, {
label: 'Upload program',
//accelerator: 'CmdOrCtrl+S',
click: functionNotImplemented
}
]
};
};
var getWindowMenuData = function() {
return {
label: 'Window',
submenu: [
{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
}, {
label: 'Close',
accelerator: 'Command+W',
selector: 'performClose:'
}, {
type: 'separator'
}, {
label: 'Bring All to Front',
selector: 'arrangeInFront:'
}
] ]
}; };
}; };
...@@ -60,14 +234,29 @@ var getHelpMenuData = function() { ...@@ -60,14 +234,29 @@ var getHelpMenuData = function() {
label: 'Help', label: 'Help',
submenu: [ submenu: [
{ {
label: 'Quick Start',
click: function() {
shell.openExternal(
'http://localhost:8000/documentation/Quick-Start');
}
}, {
label: 'Manual',
click: function() {
shell.openExternal(
'http://localhost:8000/documentation/Quick-Start');
}
}, {
type: 'separator'
}, {
label: 'Website', label: 'Website',
click: function () { click: function() {
shell.openExternal('http://ardublockly.embeddedlog.com'); shell.openExternal('http://ardublockly.embeddedlog.com');
} }
}, { }, {
label: 'Source code', label: 'Source code',
click: function () { click: function() {
shell.openExternal('https://github.com/carlosperate/ardublockly'); shell.openExternal(
'https://github.com/carlosperate/ardublockly');
} }
}, { }, {
type: 'separator' type: 'separator'
...@@ -79,20 +268,20 @@ var getHelpMenuData = function() { ...@@ -79,20 +268,20 @@ var getHelpMenuData = function() {
}; };
}; };
var getDevMenuData = function () { var getDevMenuData = function() {
return { return {
label: 'Development', label: 'Development',
submenu: [ submenu: [
{ {
label: 'Reload', label: 'Reload',
accelerator: 'CmdOrCtrl+R', accelerator: 'CmdOrCtrl+R',
click: function () { click: function() {
BrowserWindow.getFocusedWindow().reloadIgnoringCache(); BrowserWindow.getFocusedWindow().reloadIgnoringCache();
} }
}, { }, {
label: 'Toggle DevTools', label: 'Toggle DevTools',
accelerator: 'Alt+CmdOrCtrl+I', accelerator: 'Alt+CmdOrCtrl+I',
click: function () { click: function() {
BrowserWindow.getFocusedWindow().toggleDevTools(); BrowserWindow.getFocusedWindow().toggleDevTools();
} }
}, { }, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment