2013-05-03 10:53:54 +08:00
|
|
|
var app = require('app');
|
2013-05-07 20:33:50 +08:00
|
|
|
var delegate = require('atom_delegate');
|
2013-04-23 12:18:07 +08:00
|
|
|
var ipc = require('ipc');
|
2013-05-14 21:39:00 +08:00
|
|
|
var Menu = require('menu');
|
2013-05-16 20:29:13 +08:00
|
|
|
var MenuItem = require('menu_item');
|
2013-05-15 19:19:35 +08:00
|
|
|
var BrowserWindow = require('browser_window');
|
2013-04-17 20:05:43 +08:00
|
|
|
|
|
|
|
|
var mainWindow = null;
|
2013-05-14 21:39:00 +08:00
|
|
|
var menu = null;
|
2013-04-15 15:39:54 +08:00
|
|
|
|
2013-05-03 10:53:54 +08:00
|
|
|
// Quit when all windows are closed.
|
|
|
|
|
app.on('window-all-closed', function() {
|
|
|
|
|
app.terminate();
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-07 20:33:50 +08:00
|
|
|
delegate.browserMainParts.preMainMessageLoopRun = function() {
|
2013-05-15 19:19:35 +08:00
|
|
|
mainWindow = new BrowserWindow({ width: 800, height: 600 });
|
2013-05-03 15:21:41 +08:00
|
|
|
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
2013-04-19 00:06:10 +08:00
|
|
|
|
2013-04-18 23:50:47 +08:00
|
|
|
mainWindow.on('page-title-updated', function(event, title) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
2013-04-24 16:43:01 +08:00
|
|
|
this.setTitle('Atom Shell - ' + title);
|
2013-04-18 23:50:47 +08:00
|
|
|
});
|
2013-05-07 16:20:52 +08:00
|
|
|
|
|
|
|
|
mainWindow.on('closed', function() {
|
|
|
|
|
console.log('closed');
|
|
|
|
|
mainWindow = null;
|
|
|
|
|
});
|
2013-05-14 21:39:00 +08:00
|
|
|
|
|
|
|
|
menu = new Menu;
|
|
|
|
|
|
2013-05-16 20:29:13 +08:00
|
|
|
var appleMenu = new Menu;
|
|
|
|
|
appleMenu.append(new MenuItem({
|
|
|
|
|
label: 'About Atom Shell',
|
|
|
|
|
click: function() {
|
|
|
|
|
Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:');
|
2013-05-14 21:39:00 +08:00
|
|
|
}
|
2013-05-16 20:29:13 +08:00
|
|
|
}));
|
|
|
|
|
appleMenu.append(new MenuItem({ type: 'separator' }));
|
|
|
|
|
appleMenu.append(new MenuItem({
|
|
|
|
|
label: 'Hide Atom Shell',
|
|
|
|
|
accelerator: 'Command+H',
|
|
|
|
|
click: function() {
|
|
|
|
|
Menu.sendActionToFirstResponder('hide:');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
appleMenu.append(new MenuItem({
|
|
|
|
|
label: 'Hide Others',
|
|
|
|
|
accelerator: 'Command+Shift+H',
|
|
|
|
|
click: function() {
|
|
|
|
|
Menu.sendActionToFirstResponder('hideOtherApplications:');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
appleMenu.append(new MenuItem({ type: 'separator' }));
|
|
|
|
|
appleMenu.append(new MenuItem({
|
|
|
|
|
label: 'Quit',
|
|
|
|
|
accelerator: 'Command+Q',
|
|
|
|
|
click: function() {
|
|
|
|
|
app.quit();
|
|
|
|
|
}
|
|
|
|
|
}));
|
2013-05-14 21:39:00 +08:00
|
|
|
|
2013-05-16 20:29:13 +08:00
|
|
|
menu.append(new MenuItem({ type: 'submenu', submenu: appleMenu }));
|
|
|
|
|
|
|
|
|
|
Menu.setApplicationMenu(menu);
|
2013-05-14 21:39:00 +08:00
|
|
|
|
|
|
|
|
ipc.on('message', function(processId, routingId, type) {
|
|
|
|
|
if (type == 'menu')
|
|
|
|
|
menu.popup(mainWindow);
|
|
|
|
|
});
|
2013-04-15 15:39:54 +08:00
|
|
|
}
|