Add the status menu for OS X

This commit is contained in:
Yuya Ochiai 2016-04-07 00:49:20 +09:00
parent 001a65f5eb
commit 9e07f6213a
11 changed files with 254 additions and 15 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -373,7 +373,7 @@ var showUnreadBadgeWindows = function(unreadCount, mentionCount) {
const sendBadge = function(dataURL, description) {
// window.setOverlayIcon() does't work with NativeImage across remote boundaries.
// https://github.com/atom/electron/issues/4011
electron.ipcRenderer.send('win32-overlay', {
electron.ipcRenderer.send('update-unread', {
overlayDataURL: dataURL,
description: description,
unreadCount: unreadCount,
@ -400,6 +400,11 @@ var showUnreadBadgeOSX = function(unreadCount, mentionCount) {
} else {
remote.app.dock.setBadge('');
}
electron.ipcRenderer.send('update-unread', {
unreadCount: unreadCount,
mentionCount: mentionCount
});
}
var showUnreadBadge = function(unreadCount, mentionCount) {

View file

@ -125,9 +125,21 @@ app.on('certificate-error', function(event, webContents, url, error, certificate
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
if (process.platform === 'win32') {
// set up tray icon to show balloon
trayIcon = new Tray(path.resolve(__dirname, 'resources/tray.png'));
if (process.platform === 'win32' || process.platform === 'darwin') {
// set up tray icon
var tray_image = '';
switch (process.platform) {
case 'win32':
tray_image = path.resolve(__dirname, 'resources/tray.png');
break;
case 'darwin':
tray_image = path.resolve(__dirname, 'resources/osx/MenuIconTemplate.png');
break;
default:
process.exit(1);
break;
}
trayIcon = new Tray(tray_image);
trayIcon.setToolTip(app.getName());
var tray_menu = require('./main/menus/tray').createDefault();
trayIcon.setContextMenu(tray_menu);
@ -147,11 +159,15 @@ app.on('ready', function() {
// Set overlay icon from dataURL
// Set trayicon to show "dot"
ipc.on('win32-overlay', function(event, arg) {
ipc.on('update-unread', function(event, arg) {
if (process.platform === 'win32') {
const overlay = arg.overlayDataURL ? electron.nativeImage.createFromDataURL(arg.overlayDataURL) : null;
mainWindow.setOverlayIcon(overlay, arg.description);
}
var tray_image = null;
switch (process.platform) {
case 'win32':
if (arg.mentionCount > 0) {
tray_image = 'tray_mention.png';
}
@ -161,6 +177,21 @@ app.on('ready', function() {
else {
tray_image = 'tray.png';
}
break;
case 'darwin':
if (arg.mentionCount > 0) {
tray_image = 'osx/MenuIconMentionTemplate.png';
}
else if (arg.unreadCount > 0) {
tray_image = 'osx/MenuIconUnreadTemplate.png';
}
else {
tray_image = 'osx/MenuIconTemplate.png';
}
break;
default:
break;
}
trayIcon.setImage(path.resolve(__dirname, 'resources', tray_image));
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB