Add the status menu for OS X
101
resources/osx/MenuIconMentionTemplate.svg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
resources/osx/MenuIconTemplate.png
Normal file
After Width: | Height: | Size: 20 KiB |
102
resources/osx/MenuIconUnreadTemplate.svg
Normal file
After Width: | Height: | Size: 18 KiB |
|
@ -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) {
|
||||
|
|
39
src/main.js
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
|
BIN
src/resources/osx/MenuIconMentionTemplate.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/resources/osx/MenuIconMentionTemplate@2x.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src/resources/osx/MenuIconTemplate.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/resources/osx/MenuIconTemplate@2x.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
src/resources/osx/MenuIconUnreadTemplate.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/resources/osx/MenuIconUnreadTemplate@2x.png
Normal file
After Width: | Height: | Size: 2.2 KiB |