Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.1 compatible #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions app/js/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

var ipc = require('ipc');
var remote = require('remote');
var Tray = remote.require('tray');
var Menu = remote.require('menu');
const {Tray, Menu} = require('electron').remote;

const {ipcRenderer} = require('electron');
var path = require('path');

var soundButtons = document.querySelectorAll('.button-sound');
Expand Down Expand Up @@ -31,14 +30,14 @@ function prepareButton(buttonEl, soundName) {
}

closeEl.addEventListener('click', function () {
ipc.send('close-main-window');
ipcRenderer.send('close-main-window');
});

settingsEl.addEventListener('click', function () {
ipc.send('open-settings-window');
ipcRenderer.send('open-settings-window');
});

ipc.on('global-shortcut', function (arg) {
ipcRenderer.on('global-shortcut', (arg) => {
var event = new MouseEvent('click');
soundButtons[arg].dispatchEvent(event);
});
Expand All @@ -58,13 +57,13 @@ var trayMenuTemplate = [
{
label: 'Settings',
click: function () {
ipc.send('open-settings-window');
ipcRenderer.send('open-settings-window');
}
},
{
label: 'Quit',
click: function () {
ipc.send('close-main-window');
ipcRenderer.send('close-main-window');
}
}
];
Expand Down
6 changes: 3 additions & 3 deletions app/js/settings.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

var ipc = require('ipc');
const {ipcRenderer} = require('electron');
var configuration = require('../configuration');

var modifierCheckboxes = document.querySelectorAll('.global-shortcut');
var closeEl = document.querySelector('.close');

closeEl.addEventListener('click', function (e) {
ipc.send('close-settings-window');
ipcRenderer.send('close-settings-window');
});

for (var i = 0; i < modifierCheckboxes.length; i++) {
Expand All @@ -33,5 +33,5 @@ function bindModifierCheckboxes(e) {
}

configuration.saveSettings('shortcutKeys', shortcutKeys);
ipc.send('set-global-shortcuts');
ipcRenderer.send('set-global-shortcuts');
}
17 changes: 7 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

var app = require('app');
var BrowserWindow = require('browser-window');
var globalShortcut = require('global-shortcut');
const {app, BrowserWindow, globalShortcut, ipcMain} = require('electron');
var configuration = require('./configuration');
var ipc = require('ipc');

var mainWindow = null;
var settingsWindow = null;
Expand All @@ -21,7 +18,7 @@ app.on('ready', function() {
width: 368
});

mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
mainWindow.loadURL('file://' + __dirname + '/app/index.html');

setGlobalShortcuts();
});
Expand All @@ -40,11 +37,11 @@ function setGlobalShortcuts() {
});
}

ipc.on('close-main-window', function () {
ipcMain.on('close-main-window', () => {
app.quit();
});

ipc.on('open-settings-window', function () {
ipcMain.on('open-settings-window', () => {
if (settingsWindow) {
return;
}
Expand All @@ -56,19 +53,19 @@ ipc.on('open-settings-window', function () {
width: 200
});

settingsWindow.loadUrl('file://' + __dirname + '/app/settings.html');
settingsWindow.loadURL('file://' + __dirname + '/app/settings.html');

settingsWindow.on('closed', function () {
settingsWindow = null;
});
});

ipc.on('close-settings-window', function () {
ipcMain.on('close-settings-window', function () {
if (settingsWindow) {
settingsWindow.close();
}
});

ipc.on('set-global-shortcuts', function () {
ipcMain.on('set-global-shortcuts', function () {
setGlobalShortcuts();
});