Fixed file menu, New Sketch and New File items were not shown in main menu

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker 2019-09-03 16:25:59 +02:00
parent 206b65f138
commit c564572718

View File

@ -1,27 +1,31 @@
import * as electron from 'electron';
import { injectable } from "inversify";
import { injectable, inject } from "inversify";
import { ElectronMenuContribution } from "@theia/core/lib/electron-browser/menu/electron-menu-contribution";
import { FrontendApplication } from "@theia/core/lib/browser";
import { isOSX } from '@theia/core';
import { WorkspaceService } from '@theia/workspace/lib/browser';
@injectable()
export class ElectronArduinoMenuContribution extends ElectronMenuContribution {
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
onStart(app: FrontendApplication): void {
const currentWindow = electron.remote.getCurrentWindow();
const createdMenuBar = this.factory.createMenuBar();
if (isOSX) {
electron.remote.Menu.setApplicationMenu(createdMenuBar);
currentWindow.on('focus', () =>
// OSX: Recreate the menus when changing windows.
// OSX only has one menu bar for all windows, so we need to swap
// between them as the user switch windows.
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
);
} else {
// Unix/Windows: Set the per-window menus
currentWindow.setMenu(createdMenuBar);
}
this.workspaceService.onWorkspaceChanged(() => {
const createdMenuBar = this.factory.createMenuBar();
const currentWindow = electron.remote.getCurrentWindow();
if (isOSX) {
electron.remote.Menu.setApplicationMenu(createdMenuBar);
currentWindow.on('focus', () =>
// OSX: Recreate the menus when changing windows.
// OSX only has one menu bar for all windows, so we need to swap
// between them as the user switch windows.
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
);
} else {
// Unix/Windows: Set the per-window menus
currentWindow.setMenu(createdMenuBar);
}
});
}
}