function createMainWindow() { const win = new BrowserWindow({ 'title': app.getName(), 'show': false, 'width': 400, 'height': 600, 'icon': path.join(__dirname, 'media', 'Icon.png'), 'min-width': 400, 'min-height': 600, 'transparent': true, 'frame': true, 'resizable':false, 'title':'Cyberoam Client', 'title-bar-style': 'hidden-inset', 'web-preferences': { // fails without this because of CommonJS script detection 'node-integration': false, 'preload': path.join(__dirname, 'browser.js'), 'preload': path.join(__dirname, 'jquery.js'), 'preload': path.join(__dirname, 'main.js'), 'preload': path.join(__dirname, 'cy.js'), 'web-security': true, //set it false for testing 'plugins': true } }); win.setTitle("title"); win.loadUrl('http://172.50.1.1:8090/httpclient.html'); win.on('closed', app.quit); // win.on('page-title-updated', (e, title) => updateBadge(title)); return win; }
var data = fs.readFile(filename, 'utf8', function(err, data) { if (err) { error('danger', "<strong>Uh-Oh!</strong> The file could not be opened."); throw err; } if (mainWindow.send('fileContent', data)) { mainWindow.send('extension', extension); } mainWindow.setTitle(filename + " | Proton"); });
ipc.on('fileSaveAs', function(event, arg) { if (save(arg)) { var data = fs.readFile(filename, 'utf8', function(err, data) { if (err) { error('danger', "<strong>Uh-Oh!</strong> The file could not be loaded."); throw err; } mainWindow.send('fileContent', data); }); } mainWindow.setTitle(filename + " | Proton"); });
click: function() { console.log(filename); // Ready var to see if saving is complete var ready = false; if (filename != undefined) { // Save the filename mainWindow.send('getSave'); ipc.on('fileSave', function(event, arg) { // Error's are handled internally in the save function save(arg); }); ready = true; } else { // Check if there is any content mainWindow.send('getSave'); ipc.on('fileSave', function(event, arg) { // There is content, and the file has not been previously saved if (arg.length !== 0) { // Prompt the user if they would like to save var options = { type: "question", buttons: ["Save", "Cancel"], message: "Do you want to save?", detail: "The file has not been saved.", } dialog.showMessageBox(mainWindow, options, function(response) { if (response == 0) { // 'Save as' the file var file; dialog.showSaveDialog(mainWindow, function(fileName) { file = fileName; filename = file; mainWindow.send('getSaveAs'); }); ipc.on('fileSaveAs', function(event, arg) { save(arg); ready = true; mainWindow.send('fileContent', ""); }); } }); } }); } if (ready == true) { mainWindow.setTitle("Proton"); filename = undefined; mainWindow.send('fileContent', ""); } }
app.on('ready', function() { window = new browser({ width: 1200, height: 900, 'node-integration': false }); window.setTitle("Benchmark.h Visualizer"); electrify.boot(function() { window.loadUrl(electrify.meteor_url); }); });
app.on('ready', function() { // Create the browser window. mainWindow = new BrowserWindow({ width: 800, height: 600 }); // and load the index.html of the app. mainWindow.loadUrl('file://' + __dirname + '/index.html'); mainWindow.setTitle('hello world'); Menu.setApplicationMenu(menu); // Emitted when the window is closed. mainWindow.on('closed', function() { // 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; }); });
mainWindow.webContents.on('did-finish-load', function() { mainWindow.setTitle('Kitematic'); mainWindow.show(); mainWindow.focus(); if (openURL) { mainWindow.webContents.send('application:open-url', { url: openURL }); } app.on('open-url', function (event, url) { event.preventDefault(); mainWindow.webContents.send('application:open-url', { url: url }); }); if (process.env.NODE_ENV !== 'development') { autoUpdater.setFeedUrl('https://updates.kitematic.com/releases/latest?version=' + app.getVersion() + '&beta=' + !!settingsjson.beta + '&platform=' + os.platform()); } });
app.on('ready', function() { mainWindow = new BrowserWindow({ width: 1200, height: 860, resizable: true, title: "zStackEdit", icon: "/zStackEdit.icns", icon: "/zStackEdit.ico", icon: "/zStackEdit.png" }); mainWindow.setOverlayIcon( __dirname + "/zStackEdit.png", "Test?"); mainWindow.setTitle("zStackEdit"); mainWindow.loadUrl('file://' + __dirname + '/index.html'); mainWindow.focus(); mainWindow.on('closed', function() { mainWindow = null; }); //mainWindow.toggleDevTools(); });
mainWindow.webContents.on('did-finish-load', function() { mainWindow.setTitle(settings.title); mainWindow.show(); mainWindow.focus(); if (openURL) { mainWindow.webContents.send('application:open-url', { url: openURL }); } app.on('open-url', function (event, url) { event.preventDefault(); mainWindow.webContents.send('application:open-url', { url: url }); }); if (process.env.NODE_ENV !== 'development' && settings.autoUpdater.enabled) { var feedUrl = settings.feedUrl.replace('[version]', app.getVersion()).replace('[beta]', !!settings.beta); autoUpdater.setFeedUrl(feedUrl); } });
mainWindow.webContents.on('did-finish-load', function() { mainWindow.setTitle(app.getName()); });
mainWindow.webContents.on('did-finish-load', () => { mainWindow.setTitle('ΛLΞXΛNDRIΛ Librarian'); mainWindow.show(); mainWindow.focus(); });
app.on('ready', function() { updateWindow = new BrowserWindow({width: 300, height: 300, icon: __dirname + '/icon.png', title: "Discord", 'auto-hide-menu-bar': true, frame: false}); updateWindow.setResizable(false); updateWindow.setAlwaysOnTop(true); updateWindow.setSkipTaskbar(true); updateWindow.loadURL('file://' + __dirname + '/update.html'); //When no updates //mainWindow = new BrowserWindow((data && data.bounds) ? data.bounds : {width: 1200, height: 900}); mainWindow = new BrowserWindow({width: 900, height: 750, icon: __dirname + '/icon.png', title: "Discord", 'auto-hide-menu-bar': true}); mainWindow.setBounds(data.bounds); webContents = mainWindow.webContents; updateWindow.close(); mainWindow.setTitle("Discord"); mainWindow.setMenuBarVisibility(false); mainWindow.loadURL('file://' + __dirname + '/index.html'); //Nullify any closed windows. mainWindow.on('closed', function() { //updateWindow.close(); mainWindow = null; }); updateWindow.on('closed', function(){ updateWindow = null; }); //Save settings when app is closed. mainWindow.on('close', function(){ var data = { bounds: mainWindow.getBounds(), minTray: minToTray, useCSS: useCustomCSS }; fs.writeFileSync(initPath, JSON.stringify(data)); }); var showButton = new MenuItem({ label: 'Show Discord', type: 'normal', click: function() { mainWindow.setSkipTaskbar(false); mainWindow.show(); } }); //Minimize to tray. (Only works on some OSs) var disMinButton = new MenuItem({ label: 'Disable Minimize to Tray', type: 'checkbox', checked: !minToTray, click: function() { if(disMinButton.checked == true){ minToTray = false; console.log("Disabled MinToTray"); } else if (disMinButton.checked == false) { minToTray = true; console.log("Enabled MinToTray"); } disMinButton.checked = !minToTray; } }); //Toggle CSS (Only works on some OSs?) var toggleCSS = new MenuItem({ label: 'Use Custom CSS', type: 'checkbox', checked: useCustomCSS, click: function() { if(toggleCSS.checked == true){ useCustomCSS = true; console.log("Disabled useCustomCSS"); } else if (toggleCSS.checked == false) { useCustomCSS = false; console.log("Enabled useCustomCSS"); } toggleCSS.checked = useCustomCSS; } }); mainWindow.on('close', function(event) { if(minToTray && !quitForReal){ event.preventDefault(); data.bounds = mainWindow.getBounds(); mainWindow.hide(); mainWindow.setSkipTaskbar(true); } }); //Tray Menu //menu.append(new MenuItem({ label: 'Show Discord', type: 'normal', click: function() { mainWindow.restore(); mainWindow.setSkipTaskbar(false); } })); //menu.append(showButton); - Depricated. Doesn't work in Ubuntu Unity menu.append(new MenuItem({label: 'Show Discord', type: 'normal', click: function(){ mainWindow.setSkipTaskbar(false); mainWindow.show(); } })); menu.append(new MenuItem({ type: 'separator' })); menu.append(new MenuItem({ label: 'Refresh Discord', type: 'normal', click: function(){ mainWindow.reload(); } })); menu.append(new MenuItem({ type: 'separator' })); menu.append(disMinButton); menu.append(toggleCSS); menu.append(new MenuItem({ type: 'separator' })); menu.append(new MenuItem({ label: 'Quit Discord', type: 'normal', click: function() { quitForReal = true; app.quit(); } })); appIcon = new Tray(__dirname + '/tray.png'); appIcon.setToolTip('Discord'); appIcon.setContextMenu(menu); appIcon.on('click', function(event){ mainWindow.setSkipTaskbar(false); mainWindow.show(); }); //Link fix webContents.on('new-window', function(event, urlToOpen) { event.preventDefault(); shell.openExternal(urlToOpen); }); //Allow refreshing and Show Window mainWindow.on('focus', function(){ //showButton.enabled = false; globalShortcut.register('ctrl+r', function () { mainWindow.reload(); }); }); //Disable refresh when not in focus. mainWindow.on('blur', function(){ //showButton.enabled = true; globalShortcut.unregister('ctrl+r'); }); mainWindow.webContents.on('will-navigate', function(event){ event.preventDefault(); }); });
setTitle () { var info = require('../package.json'); if (this.path) this.browserWindow.setTitle(`${info.productName} - ${path.basename(this.path)}`); }