This repository has been archived by the owner on Apr 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
46 lines (36 loc) · 1.52 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// The renderer process of the Carrot electron app
// https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
var electron = require('electron');
var ipcRenderer = electron.ipcRenderer;
var package = require('../../package.json');
console.log("Carrot desktop engage!");
// By attaching fields and functions to the window object,
// we allow the web page to access a controlled set of native
// desktop funcitonality.
// NOTE: you need to add these fields/functions to externs.js
// in order for them to avoid munging in production builds!
window.OCCarrotDesktop = {};
window.OCCarrotDesktop.showDesktopWindow = function() {
console.log("Sending show-desktop-window IPC");
ipcRenderer.send('show-desktop-window');
}
window.OCCarrotDesktop.setBadgeCount = function(count) {
console.log("Sending set-badge-count IPC: " + count);
ipcRenderer.send('set-badge-count', count);
};
window.OCCarrotDesktop.windowHasFocus = function() {
console.log("Determining focus state of desktop window");
return ipcRenderer.sendSync('window-has-focus?');
};
window.OCCarrotDesktop.isDarkMode = function() {
console.log("Determining if dark mode is enabled");
return ipcRenderer.sendSync('dark-theme-enabled?');
};
window.OCCarrotDesktop.getElectronAppVersion = function() {
console.log("Get electorn app version", package.version);
return package.version;
}
ipcRenderer.on("ui-theme-changed", function(event, arg) {
console.log("Dark mode changed:", arg);
oc.web.actions.theme.desktop_theme_changed();
});