提交 329d38e6 编写于 作者: S SteVen Batten

fallback to old menubar when using macOS or native title

上级 8c5a4fd4
......@@ -278,7 +278,9 @@ export class ActionItem extends BaseActionItem {
public _updateLabel(): void {
if (this.options.label) {
let label = this.getAction().label;
label = label.replace(BaseActionItem.MNEMONIC_REGEX, '<u>$1</u>');
if (label) {
label = label.replace(BaseActionItem.MNEMONIC_REGEX, '<u>$1</u>');
}
this.$e.innerHtml(label);
}
}
......
......@@ -63,6 +63,8 @@ import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
import { IMenubarService } from 'vs/platform/menubar/common/menubar';
import { MenubarService } from 'vs/platform/menubar/electron-main/menubarService';
import { MenubarChannel } from 'vs/platform/menubar/common/menubarIpc';
// TODO@sbatten: Remove after conversion to new dynamic menubar
import { CodeMenu } from 'vs/code/electron-main/menus';
export class CodeApplication {
......@@ -493,6 +495,14 @@ export class CodeApplication {
}
}
// TODO@sbatten: Remove when menu is converted
// Install Menu
const instantiationService = accessor.get(IInstantiationService);
const configurationService = accessor.get(IConfigurationService);
if (platform.isMacintosh || configurationService.getValue<string>('window.titleBarStyle') !== 'custom') {
instantiationService.createInstance(CodeMenu);
}
// Jump List
this.historyMainService.updateWindowsJumpList();
this.historyMainService.onRecentlyOpenedChange(() => this.historyMainService.updateWindowsJumpList());
......
......@@ -10,6 +10,7 @@ import { Menubar } from 'vs/code/electron-main/menubar';
import { ILogService } from 'vs/platform/log/common/log';
import { TPromise } from 'vs/base/common/winjs.base';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { isMacintosh, isWindows } from 'vs/base/common/platform';
export class MenubarService implements IMenubarService {
_serviceBrand: any;
......@@ -21,7 +22,10 @@ export class MenubarService implements IMenubarService {
@ILogService private logService: ILogService
) {
// Install Menu
this._menubar = this.instantiationService.createInstance(Menubar);
// TODO@sbatten: Remove if block
if (isMacintosh && isWindows) {
this._menubar = this.instantiationService.createInstance(Menubar);
}
}
updateMenubar(windowId: number, menus: IMenubarData): TPromise<void> {
......
......@@ -144,13 +144,14 @@ export class MenubarPart extends Part {
}
});
for (let topLevelMenuName of Object.keys(this.topLevelMenus)) {
this.topLevelMenus[topLevelMenuName].onDidChange(() => this.setupNativeMenubar());
}
this._onVisibilityChange = new Emitter<Dimension>();
this.setupNativeMenubar();
if (isMacintosh || this.currentTitlebarStyleSetting !== 'custom') {
for (let topLevelMenuName of Object.keys(this.topLevelMenus)) {
this.topLevelMenus[topLevelMenuName].onDidChange(() => this.setupMenubar());
}
this.setupMenubar();
}
this.isFocused = false;
......@@ -247,7 +248,7 @@ export class MenubarPart extends Part {
}
}
if (this.currentEnableMenuBarMnemonics) {
if (this.currentEnableMenuBarMnemonics && this.customMenus) {
this.customMenus.forEach(customMenu => {
let child = customMenu.titleElement.child();
if (child) {
......@@ -276,7 +277,7 @@ export class MenubarPart extends Part {
}
private setupMenubar(): void {
if (this.currentTitlebarStyleSetting === 'custom') {
if (!isMacintosh && this.currentTitlebarStyleSetting === 'custom') {
this.setupCustomMenubar();
} else {
this.setupNativeMenubar();
......@@ -284,7 +285,10 @@ export class MenubarPart extends Part {
}
private setupNativeMenubar(): void {
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus());
// TODO@sbatten: Remove once native menubar is ready
if (isMacintosh && isWindows) {
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus());
}
}
private registerMnemonic(menuIndex: number, keyCode: KeyCode): void {
......@@ -699,7 +703,7 @@ export class MenubarPart extends Part {
// Build the menubar
if (this.container) {
this.setupCustomMenubar();
this.setupMenubar();
}
return this.container.getHTMLElement();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册