Skip to content

Commit

Permalink
⬆️ tray.
Browse files Browse the repository at this point in the history
  • Loading branch information
hokein committed May 21, 2016
1 parent c22a01e commit 228f10c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
91 changes: 44 additions & 47 deletions tray/main.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
var app = require('app');
var Tray = require('tray');
var Menu = require('menu');
var path = require('path');
var BrowserWindow = require('browser-window');

var iconPath = path.join(__dirname, 'icon.png');
var appIcon = null;
var win = null;

app.on('ready', function(){
win = new BrowserWindow({show: false});
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([
{
label: 'Item1',
type: 'radio',
icon: iconPath
},
{
label: 'Item2',
submenu: [
{ label: 'submenu1' },
{ label: 'submenu2' }
]
},
{
label: 'Item3',
type: 'radio',
checked: true
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function() {
win.show();
win.toggleDevTools();
}
},
{ label: 'Quit',
accelerator: 'Command+Q',
selector: 'terminate:',
}
]);
appIcon.setToolTip('This is my application.');
appIcon.setContextMenu(contextMenu);
});
const {app, Tray, Menu, BrowserWindow} = require('electron');
const path = require('path');

const iconPath = path.join(__dirname, 'icon.png');
let appIcon = null;
let win = null;

app.on('ready', function(){
win = new BrowserWindow({show: false});
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([
{
label: 'Item1',
type: 'radio',
icon: iconPath
},
{
label: 'Item2',
submenu: [
{ label: 'submenu1' },
{ label: 'submenu2' }
]
},
{
label: 'Item3',
type: 'radio',
checked: true
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function() {
win.show();
win.toggleDevTools();
}
},
{ label: 'Quit',
accelerator: 'Command+Q',
selector: 'terminate:',
}
]);
appIcon.setToolTip('This is my application.');
appIcon.setContextMenu(contextMenu);
});
2 changes: 1 addition & 1 deletion tray/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name" : "tray-demo",
"version" : "0.1.0",
"version" : "1.1.0",
"main" : "main.js"
}

0 comments on commit 228f10c

Please sign in to comment.