Last active
June 15, 2016 03:45
-
-
Save akashnimare/4dd83b6a3a7dce68689ff96087177bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const path = require('path'); | |
const electron = require('electron'); | |
const app = electron.app; | |
// const ipc = require('electron').ipc; | |
const remote = require('electron').remote; | |
const ipcMain = require('electron').ipcMain; | |
// var BrowserWindow = require('BrowserWindow'); | |
const tray = require('./tray'); | |
// adds debug features like hotkeys for triggering dev tools and reload | |
require('electron-debug')(); | |
// prevent window being garbage collected | |
let mainWindow; | |
let aboutWindow; | |
function onClosed() { | |
mainWindow = null; | |
aboutWindow = null; | |
} | |
function createMainWindow() { | |
const win = new electron.BrowserWindow({ | |
width: 1000, | |
height: 600, | |
icon: process.platform === 'linux' && path.join(__dirname, 'resources/Icon.png'), | |
minWidth: 800, | |
minHeight: 600, | |
titleBarStyle: 'hidden-inset', | |
autoHideMenuBar: true | |
}); | |
win.loadURL('http://akashnimare.in'); | |
win.on('closed', onClosed); | |
return win; | |
} | |
function createAboutWindow() { | |
const abouturl = new electron.BrowserWindow({ | |
width: 400, | |
height: 400, | |
show: false | |
}) | |
abouturl.loadURL('file://' + __dirname + '/settings.html'); | |
abouturl.on('closed', onClosed); | |
return abouturl; | |
} | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit(); | |
} | |
}); | |
app.on('activate', () => { | |
if (!mainWindow) { | |
mainWindow = createMainWindow(); | |
} | |
}); | |
app.on('ready', () => { | |
mainWindow = createMainWindow(); | |
tray.create(mainWindow); | |
aboutWindow = createAboutWindow(); | |
// tray.create(aboutWindow); | |
ipcMain.on('About', function () { | |
aboutWindow.show(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const path = require('path'); | |
const electron = require('electron'); | |
const app = require('electron').app; | |
const {shell} = require('electron'); | |
// const remote = require('electron').remote; | |
const ipcMain = require('electron').ipcMain; | |
const remote = require('electron').remote; | |
//const ipcRenderer = require('electron').ipcRenderer; | |
let tray = null; | |
exports.create = win => { | |
if (process.platform === 'darwin' || tray) { | |
return; | |
} | |
const iconPath = path.join(__dirname, 'resources', 'Icon.png'); | |
const toggleWin = () => { | |
if (win.isVisible()) { | |
win.hide(); | |
} else { | |
win.show(); | |
} | |
}; | |
const reload = () => { | |
win.reload(); | |
}; | |
const contextMenu = electron.Menu.buildFromTemplate([ | |
{ | |
label: 'About', | |
click() { | |
ipcMain.send("About"); | |
} | |
} | |
]); | |
tray = new electron.Tray(iconPath); | |
tray.setToolTip(`${app.getName()}`); | |
tray.setContextMenu(contextMenu); | |
tray.on('click', toggleWin); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment