mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 03:46:33 +00:00
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:
parent
206b65f138
commit
c564572718
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user