2013-05-03 02:53:54 +00:00
|
|
|
var app = require('app');
|
2013-05-30 12:16:54 +00:00
|
|
|
var delegate = require('atom-delegate');
|
2013-04-23 04:18:07 +00:00
|
|
|
var ipc = require('ipc');
|
2013-05-14 13:39:00 +00:00
|
|
|
var Menu = require('menu');
|
2013-05-30 12:16:54 +00:00
|
|
|
var MenuItem = require('menu-item');
|
|
|
|
var BrowserWindow = require('browser-window');
|
2013-04-17 12:05:43 +00:00
|
|
|
|
|
|
|
var mainWindow = null;
|
2013-05-14 13:39:00 +00:00
|
|
|
var menu = null;
|
2013-04-15 07:39:54 +00:00
|
|
|
|
2013-05-03 02:53:54 +00:00
|
|
|
// Quit when all windows are closed.
|
|
|
|
app.on('window-all-closed', function() {
|
|
|
|
app.terminate();
|
|
|
|
});
|
|
|
|
|
2013-05-07 12:33:50 +00:00
|
|
|
delegate.browserMainParts.preMainMessageLoopRun = function() {
|
2013-05-17 07:39:44 +00:00
|
|
|
app.commandLine.appendSwitch('js-flags', '--harmony_collections');
|
|
|
|
|
2013-05-15 11:19:35 +00:00
|
|
|
mainWindow = new BrowserWindow({ width: 800, height: 600 });
|
2013-05-03 07:21:41 +00:00
|
|
|
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
2013-04-18 16:06:10 +00:00
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
mainWindow.on('page-title-updated', function(event, title) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2013-04-24 08:43:01 +00:00
|
|
|
this.setTitle('Atom Shell - ' + title);
|
2013-04-18 15:50:47 +00:00
|
|
|
});
|
2013-05-07 08:20:52 +00:00
|
|
|
|
|
|
|
mainWindow.on('closed', function() {
|
|
|
|
console.log('closed');
|
|
|
|
mainWindow = null;
|
|
|
|
});
|
2013-05-14 13:39:00 +00:00
|
|
|
|
2013-05-16 14:43:58 +00:00
|
|
|
var template = [
|
|
|
|
{
|
|
|
|
label: 'Atom Shell',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'About Atom Shell',
|
|
|
|
selector: 'orderFrontStandardAboutPanel:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'separator'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Hide Atom Shell',
|
|
|
|
accelerator: 'Command+H',
|
|
|
|
selector: 'hide:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Hide Others',
|
|
|
|
accelerator: 'Command+Shift+H',
|
|
|
|
selector: 'hideOtherApplications:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Show All',
|
|
|
|
selector: 'unhideAllApplications:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'separator'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Quit',
|
|
|
|
accelerator: 'Command+Q',
|
|
|
|
click: function() { app.quit(); }
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2013-05-18 02:38:56 +00:00
|
|
|
{
|
|
|
|
label: 'Edit',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Undo',
|
|
|
|
accelerator: 'Command+Z',
|
|
|
|
selector: 'undo:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Redo',
|
|
|
|
accelerator: 'Shift+Command+Z',
|
|
|
|
selector: 'redo:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'separator'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Cut',
|
|
|
|
accelerator: 'Command+X',
|
|
|
|
selector: 'cut:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Copy',
|
|
|
|
accelerator: 'Command+C',
|
|
|
|
selector: 'copy:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Paste',
|
|
|
|
accelerator: 'Command+V',
|
|
|
|
selector: 'paste:'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Select All',
|
|
|
|
accelerator: 'Command+A',
|
|
|
|
selector: 'selectAll:'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2013-05-16 14:43:58 +00:00
|
|
|
{
|
|
|
|
label: 'View',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Reload',
|
|
|
|
accelerator: 'Command+R',
|
2013-05-16 15:00:43 +00:00
|
|
|
click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
|
2013-05-16 14:43:58 +00:00
|
|
|
},
|
|
|
|
{
|
2013-05-17 08:09:12 +00:00
|
|
|
label: 'Toggle DevTools',
|
2013-05-16 14:43:58 +00:00
|
|
|
accelerator: 'Alt+Command+I',
|
2013-05-17 08:09:12 +00:00
|
|
|
click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
|
2013-05-16 14:43:58 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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:'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
];
|
2013-05-16 12:29:13 +00:00
|
|
|
|
2013-05-16 14:43:58 +00:00
|
|
|
menu = Menu.buildFromTemplate(template);
|
2013-05-16 12:29:13 +00:00
|
|
|
Menu.setApplicationMenu(menu);
|
2013-05-14 13:39:00 +00:00
|
|
|
|
|
|
|
ipc.on('message', function(processId, routingId, type) {
|
|
|
|
if (type == 'menu')
|
|
|
|
menu.popup(mainWindow);
|
|
|
|
});
|
2013-04-15 07:39:54 +00:00
|
|
|
}
|