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:
parent
40813b1bb6
commit
ee7a386421
8
index.js
8
index.js
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue