add application menu

This commit is contained in:
Paul Frazee 2015-06-24 13:14:52 -05:00
parent af5b5c5706
commit db3018c698
2 changed files with 20 additions and 9 deletions

View File

@ -12,17 +12,28 @@ var tray
app.on('ready', function ready () { app.on('ready', function ready () {
// start sbot // start sbot
require('scuttlebot').init(config, function (err, sbot) { require('scuttlebot').init(config, function (err, sbot) {
// open the web app
shell.openExternal('http://localhost:8008')
// setup menu
Menu.setApplicationMenu(Menu.buildFromTemplate([{
label: 'Window',
submenu: [
{ label: 'Open Web App', click: onopen },
{ label: 'Quit', click: onquit }
]
}]))
// setup tray icon // setup tray icon
tray = new Tray(__dirname+'/icon.png') tray = new Tray(__dirname+'/icon.png')
var contextMenu = Menu.buildFromTemplate([ tray.setContextMenu(Menu.buildFromTemplate([
{ label: 'Open App', click: onopen }, { label: 'Open Web App', click: onopen },
{ label: 'Quit', click: onquit } { label: 'Quit', click: onquit }
]) ]))
tray.setContextMenu(contextMenu)
tray.setToolTip('Secure Scuttlebutt: Running on port 8008') tray.setToolTip('Secure Scuttlebutt: Running on port 8008')
tray.on('double-clicked', onopen) tray.on('double-clicked', onopen)
// menu handlers
function onopen () { function onopen () {
shell.openExternal('http://localhost:8008') shell.openExternal('http://localhost:8008')
} }

View File

@ -5,13 +5,13 @@
"main": "app/index.js", "main": "app/index.js",
"scripts": { "scripts": {
"start": "electron .", "start": "electron .",
"clean": "rm -rf ./dist", "clean": "rm -Rf ./dist",
"clean:osx": "rm -rf ./dist/osx", "clean:osx": "rm -Rf ./dist/osx",
"clean:win": "rm -rf ./dist/win", "clean:win": "rm -Rf ./dist/win",
"build": "npm run clean && npm run build:osx && npm run build:win", "build": "npm run clean && npm run build:osx && npm run build:win",
"build:icon": "./scripts/make-icns.sh assets/icon1024.png assets/osx/scuttlebot.icns", "build:icon": "./scripts/make-icns.sh assets/icon1024.png assets/osx/scuttlebot.icns",
"build:osx": "npm run clean:osx && electron-packager ./ \"Scuttlebot\" --out=dist/osx --platform=darwin --arch=x64 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/osx/scuttlebot.icns", "build:osx": "electron-packager ./ \"Scuttlebot\" --out=dist/osx --platform=darwin --arch=x64 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/osx/scuttlebot.icns",
"build:win": "npm run clean:win && electron-packager ./ \"Scuttlebot\" --out=dist/win --platform=win32 --arch=ia32 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/win/scuttlebot.ico", "build:win": "electron-packager ./ \"Scuttlebot\" --out=dist/win --platform=win32 --arch=ia32 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/win/scuttlebot.ico",
"pack": "npm run pack:osx && npm run pack:win", "pack": "npm run pack:osx && npm run pack:win",
"pack:osx": "electron-builder \"dist/osx/Scuttlebot.app\" --platform=osx --out=\"dist/osx\" --config=packager.json", "pack:osx": "electron-builder \"dist/osx/Scuttlebot.app\" --platform=osx --out=\"dist/osx\" --config=packager.json",
"pack:win": "electron-builder \"dist/win/Scuttlebot-win32\" --platform=win --out=\"dist/win\" --config=packager.json" "pack:win": "electron-builder \"dist/win/Scuttlebot-win32\" --platform=win --out=\"dist/win\" --config=packager.json"