diff --git a/resources/osx/MenuIconMentionTemplate.svg b/resources/osx/MenuIconMentionTemplate.svg new file mode 100644 index 00000000..2c390b00 --- /dev/null +++ b/resources/osx/MenuIconMentionTemplate.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/resources/osx/MenuIconTemplate.png b/resources/osx/MenuIconTemplate.png new file mode 100644 index 00000000..2e993e9e Binary files /dev/null and b/resources/osx/MenuIconTemplate.png differ diff --git a/resources/osx/MenuIconUnreadTemplate.svg b/resources/osx/MenuIconUnreadTemplate.svg new file mode 100644 index 00000000..113578d0 --- /dev/null +++ b/resources/osx/MenuIconUnreadTemplate.svg @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 2e46f8d7..ce266237 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -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) { diff --git a/src/main.js b/src/main.js index 9e6c2884..8b870905 100644 --- a/src/main.js +++ b/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,19 +159,38 @@ app.on('ready', function() { // Set overlay icon from dataURL // Set trayicon to show "dot" - ipc.on('win32-overlay', function(event, arg) { - const overlay = arg.overlayDataURL ? electron.nativeImage.createFromDataURL(arg.overlayDataURL) : null; - mainWindow.setOverlayIcon(overlay, arg.description); + 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; - if (arg.mentionCount > 0) { - tray_image = 'tray_mention.png'; - } - else if (arg.unreadCount > 0) { - tray_image = 'tray_unread.png'; - } - else { - tray_image = 'tray.png'; + switch (process.platform) { + case 'win32': + if (arg.mentionCount > 0) { + tray_image = 'tray_mention.png'; + } + else if (arg.unreadCount > 0) { + tray_image = 'tray_unread.png'; + } + 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)); }); diff --git a/src/resources/osx/MenuIconMentionTemplate.png b/src/resources/osx/MenuIconMentionTemplate.png new file mode 100644 index 00000000..0536f189 Binary files /dev/null and b/src/resources/osx/MenuIconMentionTemplate.png differ diff --git a/src/resources/osx/MenuIconMentionTemplate@2x.png b/src/resources/osx/MenuIconMentionTemplate@2x.png new file mode 100644 index 00000000..0f1a6134 Binary files /dev/null and b/src/resources/osx/MenuIconMentionTemplate@2x.png differ diff --git a/src/resources/osx/MenuIconTemplate.png b/src/resources/osx/MenuIconTemplate.png new file mode 100644 index 00000000..9c675b3c Binary files /dev/null and b/src/resources/osx/MenuIconTemplate.png differ diff --git a/src/resources/osx/MenuIconTemplate@2x.png b/src/resources/osx/MenuIconTemplate@2x.png new file mode 100644 index 00000000..31e065d8 Binary files /dev/null and b/src/resources/osx/MenuIconTemplate@2x.png differ diff --git a/src/resources/osx/MenuIconUnreadTemplate.png b/src/resources/osx/MenuIconUnreadTemplate.png new file mode 100644 index 00000000..5c1eff26 Binary files /dev/null and b/src/resources/osx/MenuIconUnreadTemplate.png differ diff --git a/src/resources/osx/MenuIconUnreadTemplate@2x.png b/src/resources/osx/MenuIconUnreadTemplate@2x.png new file mode 100644 index 00000000..a6f2811a Binary files /dev/null and b/src/resources/osx/MenuIconUnreadTemplate@2x.png differ