signal-desktop/preload.js
Axel 3dc3667b45 Add setting to hide menu bar (#1551)
* Add setting to hide menu bar

Add a setting in the themes section to hide the menu bar.
The menu bar is not needed in everyday use and might not fit in with
signals dark theme. The hidden menu bar can still be shown by pressing
alt.
autoHideMenuBar is added to windowConfig and saved and restored on
startup to prevent flickering.

* Trigger events only when related setting changes

Set the event to trigger on instanciation of the view.
Notification settings no longer reapply the theme or menu bar settings.

* Save window state when closing the window

When not moving or resizing the window, no BrowserWindow config would be
created and saved.
2017-10-13 11:39:18 -07:00

54 lines
1.5 KiB
JavaScript

(function () {
'use strict';
console.log('preload');
const electron = require('electron');
window.PROTO_ROOT = 'protos';
window.config = require('url').parse(window.location.toString(), true).query;
const ipc = electron.ipcRenderer;
window.config.localeMessages = ipc.sendSync('locale-data');
window.setBadgeCount = function(count) {
ipc.send('set-badge-count', count);
};
window.drawAttention = function() {
console.log('draw attention');
ipc.send('draw-attention');
};
window.showWindow = function() {
console.log('show window');
ipc.send('show-window');
};
window.setAutoHideMenuBar = function(autoHide) {
ipc.send('set-auto-hide-menu-bar', autoHide);
};
window.setMenuBarVisibility = function(visibility) {
ipc.send('set-menu-bar-visibility', visibility);
};
window.restart = function() {
console.log('restart');
ipc.send('restart');
};
ipc.on('debug-log', function() {
Whisper.events.trigger('showDebugLog');
});
// We pull these dependencies in now, from here, because they have Node.js dependencies
require('./js/logging');
require('./js/spell_check');
require('./js/backup');
window.nodeSetImmediate = setImmediate;
window.nodeXMLHttpRequest = require("./js/XMLHttpRequest").XMLHttpRequest;
window.nodeWebSocket = require("websocket").w3cwebsocket;
// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(function() {
window.nodeSetImmediate(function() {});
}, 1000);
window.EmojiConvertor = require('emoji-js');
})();