1
- {nativeImage } = require (" electron" );
2
1
path = require ' path'
3
2
os = require ' os'
4
3
i18n = require ' i18n'
5
4
6
5
{ Menu , Tray , nativeImage } = require (' electron' ).remote
7
6
8
7
if os .platform () == ' darwin'
9
- trayIcons =
8
+ trayIconsPath =
10
9
" read" : path .join __dirname , ' ..' , ' ..' , ' icons' , ' osx-icon-read-Template.png'
11
10
" unread" : path .join __dirname , ' ..' , ' ..' , ' icons' , ' osx-icon-unread-Template.png'
12
11
13
12
else if process .env .XDG_CURRENT_DESKTOP && process .env .XDG_CURRENT_DESKTOP .match (/ KDE/ )
14
13
# This is to work around a bug with electron apps + KDE not showing correct icon size.
15
- trayIcons =
14
+ trayIconsPath =
16
15
" read" : path .
join __dirname ,
' ..' ,
' ..' ,
' icons' ,
' [email protected] '
17
16
" unread" : path .
join __dirname ,
' ..' ,
' ..' ,
' icons' ,
' [email protected] '
18
17
19
18
else
20
- trayIcons =
19
+ trayIconsPath =
21
20
" read" : path .
join __dirname ,
' ..' ,
' ..' ,
' icons' ,
' [email protected] '
22
21
" unread" : path .
join __dirname ,
' ..' ,
' ..' ,
' icons' ,
' [email protected] '
23
22
23
+ trayIcons =
24
+ " read" : nativeImage .createFromPath (trayIconsPath[" read" ])
25
+ " unread" : nativeImage .createFromPath (trayIconsPath[" unread" ])
26
+
24
27
tray = null
25
28
26
29
# TODO: this is all WIP
@@ -29,15 +32,15 @@ quit = ->
29
32
compact = (array ) -> item for item in array when item
30
33
31
34
create = () ->
32
- tray = new Tray (nativeImage .createEmpty ());
33
- tray .setImage (nativeImage .createFromPath (trayIcons[" read" ]));
35
+ tray = new Tray trayIcons[" read" ]
34
36
tray .currentImage = ' read'
35
37
tray .setToolTip i18n .__ (' title:YakYak - Hangouts Client' )
36
38
# Emitted when the tray icon is clicked
37
39
tray .on ' click' , -> action ' togglewindow'
38
40
39
41
destroy = ->
40
42
tray .destroy () if tray
43
+ console .log (' is Destroyed' , tray .isDestroyed ())
41
44
tray = null
42
45
43
46
update = (unreadCount , viewstate ) ->
@@ -91,10 +94,10 @@ update = (unreadCount, viewstate) ->
91
94
# update icon
92
95
try
93
96
if unreadCount > 0
94
- tray .setImage nativeImage . createFromPath ( trayIcons[" unread" ]) unless tray .currentImage == ' unread'
97
+ tray .setImage trayIcons[" unread" ] unless tray .currentImage == ' unread'
95
98
tray .currentImage = ' unread'
96
99
else
97
- tray .setImage nativeImage . createFromPath ( trayIcons[" read" ]) unless tray .currentImage == ' read'
100
+ tray .setImage trayIcons[" read" ] unless tray .currentImage == ' read'
98
101
tray .currentImage = ' read'
99
102
catch e
100
103
console .log ' missing icons' , e
0 commit comments