From c13afa3745bb7a02f90fe768dd613dd94481ee24 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 25 Feb 2016 22:21:28 +0900 Subject: [PATCH] Show a dot on tray icon to notify unread messages Tray icon is too small to show a number. So a dot(small circle) is used. --- src/browser/index.jsx | 6 ++++-- src/main.js | 15 ++++++++++++++- src/resources/tray_mention.png | Bin 0 -> 735 bytes src/resources/tray_unread.png | Bin 0 -> 715 bytes 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/resources/tray_mention.png create mode 100644 src/resources/tray_unread.png diff --git a/src/browser/index.jsx b/src/browser/index.jsx index a1097c75..059da87a 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -321,7 +321,9 @@ var showUnreadBadgeWindows = function(unreadCount, mentionCount) { // https://github.com/atom/electron/issues/4011 electron.ipcRenderer.send('win32-overlay', { overlayDataURL: dataURL, - description: description + description: description, + unreadCount: unreadCount, + mentionCount: mentionCount }); }; @@ -332,7 +334,7 @@ var showUnreadBadgeWindows = function(unreadCount, mentionCount) { const dataURL = badge.createDataURL('•'); sendBadge(dataURL, 'You have unread channels'); } else { - remote.getCurrentWindow().setOverlayIcon(null, ''); + sendBadge(null, 'You have no unread messages'); } } diff --git a/src/main.js b/src/main.js index 8dd38c02..f2a1b0f1 100644 --- a/src/main.js +++ b/src/main.js @@ -104,9 +104,22 @@ app.on('ready', function() { }); // Set overlay icon from dataURL + // Set trayicon to show "dot" ipc.on('win32-overlay', function(event, arg) { - var overlay = electron.nativeImage.createFromDataURL(arg.overlayDataURL); + 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'; + } + trayIcon.setImage(path.resolve(__dirname, 'resources', tray_image)); }); } diff --git a/src/resources/tray_mention.png b/src/resources/tray_mention.png new file mode 100644 index 0000000000000000000000000000000000000000..3a3ee1a99deac1d2a9cfbd85c85e118eccd618d5 GIT binary patch literal 735 zcmV<50wDc~P)XJ?1Y z%gc1hnSy0magr>T%Q^s_ot=>+H#Rm1fWyPXoS2xPrfDR}a5&7%%S)XkEz62|01N^^ zsZ3fGaC2%?4JhRqpNP_+iw~THiF;A0+#O zto2QEan#R)-M!SECa$lq696|iH))z?V+ynLcff9v*8|UX+k_C?Qpy7%#JHj;MmC#m z4~0Td6a_OgGtj@CphNVa)jEU+z1Lc|up2cFU>^W(Z*PrsI^DjoumAvf)6tJlkH_v2 z06^r=_q>OV#W(;k4**`Tw>=Vxn3YP!$mjEB@8omVDer;nlu%{uv~?fGN$$D6E6)o> zE$yDk7y3 zq&Qm*w7Xi#PDvo7i-76EEZn#ZWRYzbZc4#^7_qoAj3y?Hg=sMv$Y9c$$s8A%7p9F~ zc)Xdp_uO~RnRf-eAUPt0aJ=V5*LCkHiZbJ+e**X*gxI}WI{09vtF;0Bpt`Gd`-dw36i#H znpPwd;m*#^pei1Zb9;N6B$?0Wd47IwNjdWLMM*oEOfs9z_Frt9TU%QMz|GA~lH~sW zKGW$meR3Aj>-CZ(*=#l~0IXK4B*{XdKmZH|gIrixV7uKWNv^K0^6c!)BFSE_mrwxA z0D!LR0ssPm002PKG|3Q$hll8PyO8<>l>z+(WIoSYnu#bQpY z)w0XwvJ<&AO