2015-06-24 17:41:17 +02:00
|
|
|
var app = require('app')
|
|
|
|
var Tray = require('tray')
|
|
|
|
var Menu = require('menu')
|
|
|
|
var shell = require('shell')
|
2015-06-24 22:38:30 +02:00
|
|
|
var BrowserWindow = require('browser-window')
|
2015-06-24 17:41:17 +02:00
|
|
|
var config = require('ssb-config')
|
|
|
|
|
|
|
|
// Report crashes to our server.
|
|
|
|
//require('crash-reporter').start();
|
|
|
|
|
|
|
|
var tray
|
2015-06-24 22:38:30 +02:00
|
|
|
var mainWindow
|
2015-06-24 17:41:17 +02:00
|
|
|
|
|
|
|
app.on('ready', function ready () {
|
|
|
|
// start sbot
|
|
|
|
require('scuttlebot').init(config, function (err, sbot) {
|
2015-06-24 20:14:52 +02:00
|
|
|
// open the web app
|
2015-06-24 22:38:30 +02:00
|
|
|
// shell.openExternal('http://localhost:8008')
|
|
|
|
mainWindow = new BrowserWindow({width: 1000, height: 720})
|
|
|
|
mainWindow.loadUrl('http://localhost:8008')
|
|
|
|
mainWindow.on('closed', function() { mainWindow = null })
|
2015-06-24 20:14:52 +02:00
|
|
|
|
|
|
|
// setup menu
|
2015-06-24 23:48:00 +02:00
|
|
|
// Menu.setApplicationMenu(Menu.buildFromTemplate([{
|
|
|
|
// label: 'Window',
|
|
|
|
// submenu: [
|
|
|
|
// // { label: 'Open Web App', click: onopen },
|
|
|
|
// { label: 'Quit', click: onquit }
|
|
|
|
// ]
|
|
|
|
// }]))
|
2015-06-24 17:41:17 +02:00
|
|
|
|
|
|
|
// setup tray icon
|
2015-06-24 19:24:53 +02:00
|
|
|
tray = new Tray(__dirname+'/icon.png')
|
2015-06-24 20:14:52 +02:00
|
|
|
tray.setContextMenu(Menu.buildFromTemplate([
|
2015-06-24 22:38:30 +02:00
|
|
|
// { label: 'Open Web App', click: onopen },
|
2015-06-24 17:41:17 +02:00
|
|
|
{ label: 'Quit', click: onquit }
|
2015-06-24 20:14:52 +02:00
|
|
|
]))
|
2015-06-24 17:41:17 +02:00
|
|
|
tray.setToolTip('Secure Scuttlebutt: Running on port 8008')
|
2015-06-24 22:38:30 +02:00
|
|
|
// tray.on('double-clicked', onopen)
|
2015-06-24 17:41:17 +02:00
|
|
|
|
2015-06-24 20:14:52 +02:00
|
|
|
// menu handlers
|
2015-06-24 17:41:17 +02:00
|
|
|
function onopen () {
|
|
|
|
shell.openExternal('http://localhost:8008')
|
|
|
|
}
|
|
|
|
function onquit () {
|
|
|
|
tray = null
|
|
|
|
sbot.close()
|
|
|
|
process.exit()
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
});
|