From 657053ce5bba5ea64e8f78e92086143ab4b2fcbe Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Wed, 25 Sep 2019 14:58:27 +0200 Subject: [PATCH] Extracted the top-panel removal to a method. Signed-off-by: Akos Kitta --- .../menu/electron-menu-contribution.ts | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts index cd7d99472f912..7c203504b11f5 100644 --- a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts +++ b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts @@ -76,19 +76,7 @@ export class ElectronMenuContribution implements FrontendApplicationContribution ) { } onStart(app: FrontendApplication): void { - const itr = app.shell.children(); - let child = itr.next(); - while (child) { - // Top panel for the menu contribution is not required for Electron. - // TODO: Make sure this is the case on Windows too. - if (child.id === 'theia-top-panel') { - child.setHidden(true); - child = undefined; - } else { - child = itr.next(); - } - } - + this.hideTopPanel(app); this.setMenu(); if (isOSX) { // OSX: Recreate the menus when changing windows. @@ -112,6 +100,26 @@ export class ElectronMenuContribution implements FrontendApplicationContribution onStateChange = this.stateService.onStateChanged(stateServiceListener); } + /** + * Makes the `theia-top-panel` hidden as it is unused for the electron-based application. + * The `theia-top-panel` is used as the container of the main, application menu-bar for the + * browser. Electron has it's own. + * By default, this method is called on application `onStart`. + */ + protected hideTopPanel(app: FrontendApplication): void { + const itr = app.shell.children(); + let child = itr.next(); + while (child) { + // Top panel for the menu contribution is not required for Electron. + if (child.id === 'theia-top-panel') { + child.setHidden(true); + child = undefined; + } else { + child = itr.next(); + } + } + } + private setMenu(menu: electron.Menu = this.factory.createMenuBar(), electronWindow: electron.BrowserWindow = electron.remote.getCurrentWindow()): void { if (isOSX) { electron.remote.Menu.setApplicationMenu(menu);