Commit 77851b7e authored by carlosperate's avatar carlosperate

Electron: Add basic application menu.

Good foundation to expand in the future.
parent 452fafd1
......@@ -90,12 +90,8 @@ cef_debug.log
/upload
/releases
/arduexec
/ardublockly_server_run.bat
/ardublockly_server_run.sh
/ardublockly_server_run.command
/ardublockly_run.bat
/ardublockly_run.sh
/ardublockly_run.command
ardublockly_server_run.*
ardublockly_run.*
# The documentation is built with the GitHub wiki data
/Documentation
......
'use strict';
var app = require('app');
var Menu = require('menu');
var MenuItem = require('menu-item');
var BrowserWindow = require('browser-window');
var dialog = require('dialog');
var shell = require('shell');
module.exports.setArdublocklyMenu = function(devMode) {
if (typeof(devMode)==='undefined') devMode = false;
var ardublocklyMenu = [
getFileMenuData(),
getHelpMenuData(),
];
if (devMode) {
ardublocklyMenu.push(getDevMenuData());
}
Menu.setApplicationMenu(Menu.buildFromTemplate(ardublocklyMenu));
};
var getFileMenuData = function() {
return {
label: 'File',
submenu: [
{
label: 'Open',
accelerator: 'CmdOrCtrl+O',
click: functionNotImplemented
}, {
label: 'Save as',
accelerator: 'CmdOrCtrl+S',
click: functionNotImplemented
}, {
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: function () {
app.quit();
}
}
]
};
};
var getHelpMenuData = function() {
return {
label: 'Help',
submenu: [
{
label: 'Website',
click: function () {
shell.openExternal('http://ardublockly.embeddedlog.com');
}
}, {
label: 'Source code',
click: function () {
shell.openExternal('https://github.com/carlosperate/ardublockly');
}
}, {
type: 'separator'
}, {
label: 'About',
click: functionNotImplemented
}
]
};
};
var getDevMenuData = function () {
return {
label: 'Development',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click: function () {
BrowserWindow.getFocusedWindow().reloadIgnoringCache();
}
}, {
label: 'Toggle DevTools',
accelerator: 'Alt+CmdOrCtrl+I',
click: function () {
BrowserWindow.getFocusedWindow().toggleDevTools();
}
}, {
label: 'Restart server and page',
accelerator: 'Shift+CmdOrCtrl+R',
click: function () {
BrowserWindow.getFocusedWindow().toggleDevTools();
}
}
]
};
};
var functionNotImplemented = function() {
console.log("test");
dialog.showMessageBox({
type: "info",
title: "Dialog",
buttons: ["ok",],
message: "This functionality has not yet been implemented."
});
};
'use strict';
var app = require('app');
var appMenu = require('./appmenu.js');
var BrowserWindow = require('browser-window');
var env = require('./vendor/electron_boilerplate/env_config');
var devHelper = require('./vendor/electron_boilerplate/dev_helper');
var windowStateKeeper = require('./vendor/electron_boilerplate/window_state');
var mainWindow;
// Global reference of the window object must be maintain, or the window will
// be closed automatically when the javascript object is garbage collected.
var mainWindow = null;
// Preserver of the window size and position between app launches.
var mainWindowState = windowStateKeeper('main', {
width: 1000,
height: 600
width: 1200,
height: 765
});
app.on('ready', function () {
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
"node-integration": false
title: 'Ardublockly',
type: 'desktop',
'node-integration': false,
'web-preferences': {
'web-security': true,
'java': false,
'text-areas-are-resizable': false,
'webgl': false,
'webaudio': true,
'plugins': false
}
});
if (mainWindowState.isMaximized) {
mainWindow.maximize();
}
mainWindow.loadUrl('http://localhost:8000/ardublockly');
if (env.name === 'development') {
devHelper.setDevMenu();
appMenu.setArdublocklyMenu(true);
mainWindow.openDevTools();
} else {
appMenu.setArdublocklyMenu();
}
mainWindow.loadUrl('http://localhost:8000/ardublockly');
mainWindow.on('close', function () {
mainWindowState.saveState(mainWindow);
mainWindow = null;
});
});
app.on('window-all-closed', function () {
// Might need to add OS X exception
// https://github.com/atom/electron/issues/1357
app.quit();
});
......@@ -16,14 +16,14 @@ var paths = {
jsCodeToTranspile: [
'app/**/*.js',
'!app/main.js',
'!app/spec.js',
'!app/*.js',
'!app/node_modules/**',
'!app/bower_components/**',
'!app/vendor/**'
],
toCopy: [
'app/main.js',
'app/spec.js',
'app/*.js',
'app/node_modules/**',
'app/bower_components/**',
'app/vendor/**',
......
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