Skip to content

Commit c564572

Browse files
committed
Fixed file menu, New Sketch and New File items were not shown in main menu
Signed-off-by: jbicker <[email protected]>
1 parent 206b65f commit c564572

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import * as electron from 'electron';
2-
import { injectable } from "inversify";
2+
import { injectable, inject } from "inversify";
33
import { ElectronMenuContribution } from "@theia/core/lib/electron-browser/menu/electron-menu-contribution";
44
import { FrontendApplication } from "@theia/core/lib/browser";
55
import { isOSX } from '@theia/core';
6+
import { WorkspaceService } from '@theia/workspace/lib/browser';
67

78
@injectable()
89
export class ElectronArduinoMenuContribution extends ElectronMenuContribution {
9-
onStart(app: FrontendApplication): void {
10-
const currentWindow = electron.remote.getCurrentWindow();
11-
const createdMenuBar = this.factory.createMenuBar();
1210

13-
if (isOSX) {
14-
electron.remote.Menu.setApplicationMenu(createdMenuBar);
15-
currentWindow.on('focus', () =>
16-
// OSX: Recreate the menus when changing windows.
17-
// OSX only has one menu bar for all windows, so we need to swap
18-
// between them as the user switch windows.
19-
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
20-
);
11+
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
2112

22-
} else {
23-
// Unix/Windows: Set the per-window menus
24-
currentWindow.setMenu(createdMenuBar);
25-
}
13+
onStart(app: FrontendApplication): void {
14+
this.workspaceService.onWorkspaceChanged(() => {
15+
const createdMenuBar = this.factory.createMenuBar();
16+
const currentWindow = electron.remote.getCurrentWindow();
17+
if (isOSX) {
18+
electron.remote.Menu.setApplicationMenu(createdMenuBar);
19+
currentWindow.on('focus', () =>
20+
// OSX: Recreate the menus when changing windows.
21+
// OSX only has one menu bar for all windows, so we need to swap
22+
// between them as the user switch windows.
23+
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
24+
);
25+
} else {
26+
// Unix/Windows: Set the per-window menus
27+
currentWindow.setMenu(createdMenuBar);
28+
}
29+
});
2630
}
2731
}

0 commit comments

Comments
 (0)