Browse Source

loading window base code added

stub code added to first show loading window, frameless.
when loading window closes, load easydex gui window
ca333-dev
Satinder Grewal 8 years ago
parent
commit
9ced8a01f1
  1. 77
      main.js

77
main.js

@ -60,9 +60,67 @@ mkdirp(iguanaDir, function (err) {
let mainWindow
let loadingWindow
function createWindow () {
function createLoadingWindow() {
mainWindow = null;
// initialise window
loadingWindow = new BrowserWindow({width: 500, height: 300, frame: false})
// load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL('http://localhost:17777/');
// DEVTOOLS - only for dev purposes - ca333
//loadingWindow.webContents.openDevTools()
// if window closed we kill iguana proc
loadingWindow.on('closed', function () {
ig.kill();
// our app does not have multiwindow - so we dereference the window object instead of
// putting them into an window_arr
loadingWindow = null
createWindow('open')
})
//ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms
if (os.platform() === 'win32') {
process.chdir(iguanaDir);
ig = spawn(iguanaWin); //specify binary in startup
}
if (os.platform() === 'linux') {
process.chdir(iguanaDir);
ig = spawn(iguanaLinux);
}
if (os.platform() === 'darwin') {
process.chdir(iguanaDir);
ig = spawn(iguanaOSX);
}
//}if (os.platform() === 'freeBSD') {
//ex(iguanaFreeBSD)
//}
//ca333 - could also specifiy via os.arch (x86, x64, etc. ) in startup and pass via param to main proc
ig.stderr.on( 'error: ', data => {
console.log( `stderr: ${data}` );
});
}
app.on('ready', createLoadingWindow)
app.on('window-all-closed', function () {
ig.kill();
// in osx apps stay active in menu bar until explictly closed or quitted by CMD Q
// so we do not kill the app --> for the case user clicks again on the iguana icon
// we open just a new window and respawn iguana proc
if (process.platform !== 'darwin') {
app.quit()
}
})
function createWindow (status) {
if ( status === 'open') {
// initialise window
mainWindow = new BrowserWindow({width: 1280, height: 800})
@ -86,10 +144,9 @@ function createWindow () {
})
//ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms
if (os.platform() === 'win32') {
process.chdir(iguanaDir);
ig = spawn(iguanaWin); //specify binary in startup
}
//if (os.platform() === 'win32') {
//ex(iguanaWin) //specify binary in startup
//}
if (os.platform() === 'linux') {
process.chdir(iguanaDir);
ig = spawn(iguanaLinux);
@ -106,9 +163,12 @@ function createWindow () {
ig.stderr.on( 'error: ', data => {
console.log( `stderr: ${data}` );
});
}
}
app.on('ready', createWindow)
app.on('ready', function() {
createLoadingWindow
})
app.on('window-all-closed', function () {
ig.kill();
@ -121,7 +181,8 @@ app.on('window-all-closed', function () {
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
if (loadingWindow === null) {
//createWindow()
createLoadingWindow();
}
})
Loading…
Cancel
Save