mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 06:16:33 +00:00
Update Electron main menu when a toggle button is switched
This commit is contained in:
parent
f6a8dceabc
commit
69c7383da8
@ -301,7 +301,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
||||
});
|
||||
|
||||
registry.registerCommand(ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG, {
|
||||
execute: () => this.editorMode.toggleCompileForDebug(),
|
||||
execute: () => {
|
||||
this.editorMode.toggleCompileForDebug();
|
||||
this.editorMode.menuContentChanged.fire();
|
||||
},
|
||||
isToggled: () => this.editorMode.compileForDebug
|
||||
});
|
||||
|
||||
@ -416,7 +419,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
||||
});
|
||||
|
||||
registry.registerCommand(ArduinoCommands.TOGGLE_ADVANCED_MODE, {
|
||||
execute: () => this.editorMode.toggleProMode(),
|
||||
execute: () => {
|
||||
this.editorMode.toggleProMode();
|
||||
this.editorMode.menuContentChanged.fire();
|
||||
},
|
||||
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right',
|
||||
isToggled: () => this.editorMode.proMode
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { injectable } from 'inversify';
|
||||
import { Emitter } from '@theia/core/lib/common/event';
|
||||
import { ApplicationShell, FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser';
|
||||
import { ArduinoShellLayoutRestorer } from './shell/arduino-shell-layout-restorer';
|
||||
import { OutputWidget } from '@theia/output/lib/browser/output-widget';
|
||||
@ -7,6 +8,8 @@ import { EditorWidget } from '@theia/editor/lib/browser';
|
||||
@injectable()
|
||||
export class EditorMode implements FrontendApplicationContribution {
|
||||
|
||||
readonly menuContentChanged = new Emitter<void>();
|
||||
|
||||
protected app: FrontendApplication;
|
||||
|
||||
onStart(app: FrontendApplication): void {
|
||||
|
@ -1,9 +1,27 @@
|
||||
import { injectable } from 'inversify';
|
||||
import * as electron from 'electron';
|
||||
import { injectable, inject, postConstruct } from 'inversify';
|
||||
import { isOSX } from '@theia/core/lib/common/os';
|
||||
import { ElectronMenuContribution } from '@theia/core/lib/electron-browser/menu/electron-menu-contribution';
|
||||
import { EditorMode } from '../browser/editor-mode';
|
||||
|
||||
@injectable()
|
||||
export class ElectronArduinoMenuContribution extends ElectronMenuContribution {
|
||||
|
||||
@inject(EditorMode)
|
||||
protected readonly editorMode: EditorMode;
|
||||
|
||||
@postConstruct()
|
||||
protected init(): void {
|
||||
this.editorMode.menuContentChanged.event(() => {
|
||||
const createdMenuBar = this.factory.createMenuBar();
|
||||
if (isOSX) {
|
||||
electron.remote.Menu.setApplicationMenu(createdMenuBar);
|
||||
} else {
|
||||
electron.remote.getCurrentWindow().setMenu(createdMenuBar);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected hideTopPanel(): void {
|
||||
// NOOP
|
||||
// We reuse the `div` for the Arduino toolbar.
|
||||
|
Loading…
x
Reference in New Issue
Block a user