Skip to content

Commit

Permalink
Extracted the top-panel removal to a method.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta authored and kittaakos committed Sep 25, 2019
1 parent f25652a commit fbd63c5
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit fbd63c5

Please sign in to comment.