Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracted the top-panel removal to a method. #6261

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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