1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 10:22:31 +01:00
lossless-cut/src/index.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-10-30 11:57:12 +01:00
const electron = require('electron'); // eslint-disable-line
const isDev = require('electron-is-dev');
const path = require('path');
const url = require('url');
2016-10-30 11:57:12 +01:00
const menu = require('./menu');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
app.setName('LosslessCut');
if (!isDev) process.env.NODE_ENV = 'production';
2016-10-30 11:57:12 +01:00
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
darkTheme: true,
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true,
}));
2016-10-30 11:57:12 +01:00
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
createWindow();
menu(app, mainWindow);
2016-10-30 11:57:12 +01:00
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
electron.ipcMain.on('renderer-ready', () => {
if (!isDev) {
const fileToOpen = process.argv[1];
if (fileToOpen) mainWindow.webContents.send('file-opened', [fileToOpen]);
}
});