implemented dock badges and progress bar

Not actually working on my system, but I don't know that has
	anything to do with the code in this repo.
This commit is contained in:
tigerbot 2017-04-21 15:41:37 -06:00
parent 40813b1bb6
commit ee7a386421
3 changed files with 43 additions and 6 deletions

View File

@ -22,11 +22,9 @@ function createWindow () {
var tray = require('./tray'); var tray = require('./tray');
tray.init(win); tray.init(win);
var menu = require('./menu'); require('./menu').init(win);
menu.init(win); require('./progress').init(win);
require('./drag-drop-main').init(win);
var drag = require('./drag-drop-main');
drag.init(win);
// Open the DevTools. // Open the DevTools.
win.webContents.openDevTools(); win.webContents.openDevTools();

View File

@ -1,4 +1,6 @@
;(function () { ;(function () {
var electron = require('electron');
var ipc = electron.ipcRenderer;
// This file runs in a render thread of the Electron app. It must be required (directly or // This file runs in a render thread of the Electron app. It must be required (directly or
// indirectly) from one of the html files. // indirectly) from one of the html files.
@ -16,8 +18,11 @@
notif.close(); notif.close();
}; };
notif.onclose = function () { notif.onclose = function () {
setTimeout(notifyUser, 5000); if (count < 10) {
setTimeout(notifyUser, 5000);
}
}; };
ipc.send('notification', count);
} }
setTimeout(notifyUser, 1000); setTimeout(notifyUser, 1000);
}()); }());

34
progress.js Normal file
View File

@ -0,0 +1,34 @@
var electron = require('electron');
var app = electron.app;
var ipc = electron.ipcMain;
var win;
function init(window) {
if (win) {
console.error("can't initialize badge/progress tracker multiple times");
return;
}
win = window;
ipc.on('notification', function (ev, count) {
updateProgress(count);
increaseBadge();
});
win.on('focus', clearBadge);
}
function increaseBadge() {
if (!win.isFocused()) {
app.setBadgeCount(app.getBadgeCount() + 1);
}
}
function clearBadge() {
app.setBadgeCount(0);
}
function updateProgress(count) {
win.setProgressBar((count % 10)/10);
}
module.exports.init = init;