forked from yakyak/yakyak
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7b9774
commit 68cc15d
Showing
4 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
{nativeImage} = require("electron"); | ||
path = require 'path' | ||
os = require 'os' | ||
i18n = require 'i18n' | ||
|
||
{ Menu, Tray, nativeImage } = require('electron').remote | ||
|
||
if os.platform() == 'darwin' | ||
trayIcons = | ||
trayIconsPath = | ||
"read": path.join __dirname, '..', '..', 'icons', 'osx-icon-read-Template.png' | ||
"unread": path.join __dirname, '..', '..', 'icons', 'osx-icon-unread-Template.png' | ||
|
||
else if process.env.XDG_CURRENT_DESKTOP && process.env.XDG_CURRENT_DESKTOP.match(/KDE/) | ||
# This is to work around a bug with electron apps + KDE not showing correct icon size. | ||
trayIcons = | ||
trayIconsPath = | ||
"read": path.join __dirname, '..', '..', 'icons', '[email protected]' | ||
"unread": path.join __dirname, '..', '..', 'icons', '[email protected]' | ||
|
||
else | ||
trayIcons = | ||
trayIconsPath = | ||
"read": path.join __dirname, '..', '..', 'icons', '[email protected]' | ||
"unread": path.join __dirname, '..', '..', 'icons', '[email protected]' | ||
|
||
trayIcons = | ||
"read": nativeImage.createFromPath(trayIconsPath["read"]) | ||
"unread": nativeImage.createFromPath(trayIconsPath["unread"]) | ||
|
||
tray = null | ||
|
||
# TODO: this is all WIP | ||
|
@@ -29,15 +32,15 @@ quit = -> | |
compact = (array) -> item for item in array when item | ||
|
||
create = () -> | ||
tray = new Tray(nativeImage.createEmpty()); | ||
tray.setImage(nativeImage.createFromPath(trayIcons["read"])); | ||
tray = new Tray trayIcons["read"] | ||
tray.currentImage = 'read' | ||
tray.setToolTip i18n.__('title:YakYak - Hangouts Client') | ||
# Emitted when the tray icon is clicked | ||
tray.on 'click', -> action 'togglewindow' | ||
|
||
destroy = -> | ||
tray.destroy() if tray | ||
console.log('is Destroyed', tray.isDestroyed()) | ||
tray = null | ||
|
||
update = (unreadCount, viewstate) -> | ||
|
@@ -91,10 +94,10 @@ update = (unreadCount, viewstate) -> | |
# update icon | ||
try | ||
if unreadCount > 0 | ||
tray.setImage nativeImage.createFromPath(trayIcons["unread"]) unless tray.currentImage == 'unread' | ||
tray.setImage trayIcons["unread"] unless tray.currentImage == 'unread' | ||
tray.currentImage = 'unread' | ||
else | ||
tray.setImage nativeImage.createFromPath(trayIcons["read"]) unless tray.currentImage == 'read' | ||
tray.setImage trayIcons["read"] unless tray.currentImage == 'read' | ||
tray.currentImage = 'read' | ||
catch e | ||
console.log 'missing icons', e | ||
|