Merge pull request #53 from Atlante45/console

Add tray icon
This commit is contained in:
Stephen Birarda 2015-12-03 13:20:00 -08:00
commit accdad432b
4 changed files with 34 additions and 19 deletions

View file

@ -1,5 +1,7 @@
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var Menu = require('menu');
var Tray = require('tray');
// Report crashes to our server.
require('crash-reporter').start();
@ -7,33 +9,46 @@ require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
var appIcon = null;
var TRAY_ICON = 'resources/tray-icon.png';
var APP_ICON = 'resources/tray-icon.png';
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
app.quit();
}
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
app.quit();
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// Create tray icon
appIcon = new Tray(TRAY_ICON);
appIcon.setToolTip('High Fidelity Console');
var contextMenu = Menu.buildFromTemplate([{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { app.quit(); }
}]);
appIcon.setContextMenu(contextMenu);
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html');
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600, icon: APP_ICON});
// Open the DevTools.
mainWindow.webContents.openDevTools();
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html');
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB