Browse Source

Save Window State

Fixes #24
pull/92/merge
Ramiro Saenz 9 years ago
parent
commit
ad9dd5aa98
  1. 1
      app/package.json
  2. 22
      electron/main.js

1
app/package.json

@ -25,6 +25,7 @@
"author": "Ramiro Saenz", "author": "Ramiro Saenz",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"electron-window-state": "^3.0.3",
"firebase": "^3.0.5", "firebase": "^3.0.5",
"firebase-token-generator": "^2.0.0" "firebase-token-generator": "^2.0.0"
} }

22
electron/main.js

@ -13,6 +13,8 @@ const appMenu = require('./menu');
const tray = require('./tray'); const tray = require('./tray');
// Require for autpUpdate file // Require for autpUpdate file
const autoupdater = require('./autoupdater'); const autoupdater = require('./autoupdater');
// Window State Plugin
const windowStateKeeper = require('electron-window-state');
const MenuItem = electron.MenuItem; const MenuItem = electron.MenuItem;
@ -91,11 +93,21 @@ let mainWindow;
let isQuitting = false; let isQuitting = false;
function createWindow () { function createWindow () {
// Create the browser window. // Load the previous state with fallback to defaults
let mainWindowState = windowStateKeeper({
defaultWidth: 1000
,defaultHeight: 800
,maximize: true
});
// Create the browser window using the state information
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
title: 'Rambox' title: 'Rambox'
,skipTaskbar: false ,skipTaskbar: false
,icon: __dirname + '/../resources/Icon.png' ,icon: __dirname + '/../resources/Icon.png'
,x: mainWindowState.x
,y: mainWindowState.y
,width: mainWindowState.width
,height: mainWindowState.height
,webPreferences: { ,webPreferences: {
webSecurity: false webSecurity: false
,nodeIntegration: true ,nodeIntegration: true
@ -104,10 +116,12 @@ function createWindow () {
} }
}); });
process.setMaxListeners(100); // Let us register listeners on the window, so we can update the state
// automatically (the listeners will be removed when the window is closed)
// and restore the maximized or full screen state
mainWindowState.manage(mainWindow);
// Start maximize process.setMaxListeners(100);
mainWindow.maximize();
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/../index.html'); mainWindow.loadURL('file://' + __dirname + '/../index.html');

Loading…
Cancel
Save