[WIP] Add proper window support (#547)

* Add proper window support to both the top menu, and the dock

* Sort out linting

* Only create dockMenu on Mac

* Remove label from menu as it is not needed when using role

* Fix spacing
This commit is contained in:
James Hall 2016-08-04 01:52:31 +01:00 committed by GitHub
parent f175268912
commit 77a103fbf1
2 changed files with 14 additions and 4 deletions

View file

@ -97,7 +97,6 @@ app.on('ready', () => {
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
const win = new BrowserWindow(browserOptions);
windowSet.add(win);
win.loadURL(url);
@ -159,6 +158,7 @@ app.on('ready', () => {
});
session.on('title', (title) => {
win.setTitle(title);
rpc.emit('session title', { uid, title });
});
@ -174,14 +174,15 @@ app.on('ready', () => {
// on Session and focus/blur to subscribe
rpc.on('focus', ({ uid }) => {
const session = sessions.get(uid);
if (typeof session !== 'undefined' && typeof session.lastTitle !== 'undefined') {
win.setTitle(session.lastTitle);
}
if (session) {
session.focus();
} else {
console.log('session not found by', uid);
}
});
rpc.on('blur', ({ uid }) => {
const session = sessions.get(uid);
@ -309,6 +310,15 @@ app.on('ready', () => {
}
}));
// If we're on Mac make a Dock Menu
if (process.platform === 'darwin') {
const { app, Menu } = require('electron');
const dockMenu = Menu.buildFromTemplate([
{label: 'New Window', click () { createWindow(); }}
]);
app.dock.setMenu(dockMenu);
}
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
};

View file

@ -208,7 +208,7 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) {
]
},
{
label: 'Window',
role: 'window',
submenu: [
{
role: 'minimize'