提交 718167fb 编写于 作者: B Benjamin Pasero

macOS: show more native tab related actions when tabs are enabled (fixes #33884)

上级 c2ec62ae
...@@ -32,6 +32,7 @@ interface IExtensionViewlet { ...@@ -32,6 +32,7 @@ interface IExtensionViewlet {
interface IConfiguration extends IFilesConfiguration { interface IConfiguration extends IFilesConfiguration {
window: { window: {
enableMenuBarMnemonics: boolean; enableMenuBarMnemonics: boolean;
nativeTabs: boolean;
}; };
workbench: { workbench: {
sideBar: { sideBar: {
...@@ -66,6 +67,7 @@ export class CodeMenu { ...@@ -66,6 +67,7 @@ export class CodeMenu {
private currentStatusbarVisible: boolean; private currentStatusbarVisible: boolean;
private currentActivityBarVisible: boolean; private currentActivityBarVisible: boolean;
private currentEnableMenuBarMnemonics: boolean; private currentEnableMenuBarMnemonics: boolean;
private currentEnableNativeTabs: boolean;
private isQuitting: boolean; private isQuitting: boolean;
private appMenuInstalled: boolean; private appMenuInstalled: boolean;
...@@ -80,6 +82,8 @@ export class CodeMenu { ...@@ -80,6 +82,8 @@ export class CodeMenu {
private closeWorkspace: Electron.MenuItem; private closeWorkspace: Electron.MenuItem;
private saveWorkspaceAs: Electron.MenuItem; private saveWorkspaceAs: Electron.MenuItem;
private nativeTabMenuItems: Electron.MenuItem[];
constructor( constructor(
@IUpdateService private updateService: IUpdateService, @IUpdateService private updateService: IUpdateService,
@IInstantiationService instantiationService: IInstantiationService, @IInstantiationService instantiationService: IInstantiationService,
...@@ -91,6 +95,7 @@ export class CodeMenu { ...@@ -91,6 +95,7 @@ export class CodeMenu {
@IWorkspacesMainService private workspacesService: IWorkspacesMainService @IWorkspacesMainService private workspacesService: IWorkspacesMainService
) { ) {
this.extensionViewlets = []; this.extensionViewlets = [];
this.nativeTabMenuItems = [];
this.menuUpdater = new RunOnceScheduler(() => this.doUpdateMenu(), 0); this.menuUpdater = new RunOnceScheduler(() => this.doUpdateMenu(), 0);
this.keybindingsResolver = instantiationService.createInstance(KeybindingsResolver); this.keybindingsResolver = instantiationService.createInstance(KeybindingsResolver);
...@@ -188,6 +193,15 @@ export class CodeMenu { ...@@ -188,6 +193,15 @@ export class CodeMenu {
updateMenu = true; updateMenu = true;
} }
let newEnableNativeTabs = config && config.window && config.window.nativeTabs;
if (typeof newEnableNativeTabs !== 'boolean') {
newEnableNativeTabs = false;
}
if (newEnableNativeTabs !== this.currentEnableNativeTabs) {
this.currentEnableNativeTabs = newEnableNativeTabs;
updateMenu = true;
}
if (handleMenu && updateMenu) { if (handleMenu && updateMenu) {
this.updateMenu(); this.updateMenu();
} }
...@@ -222,6 +236,15 @@ export class CodeMenu { ...@@ -222,6 +236,15 @@ export class CodeMenu {
if ((e.oldCount === 0 && e.newCount > 0) || (e.oldCount > 0 && e.newCount === 0)) { if ((e.oldCount === 0 && e.newCount > 0) || (e.oldCount > 0 && e.newCount === 0)) {
this.updateMenu(); this.updateMenu();
} }
// Update specific items that are dependent on window count
else if (this.currentEnableNativeTabs) {
this.nativeTabMenuItems.forEach(item => {
if (item) {
item.enabled = e.newCount > 1;
}
});
}
} }
private updateWorkspaceMenuItems(): void { private updateWorkspaceMenuItems(): void {
...@@ -877,10 +900,25 @@ export class CodeMenu { ...@@ -877,10 +900,25 @@ export class CodeMenu {
const bringAllToFront = new MenuItem({ label: nls.localize('mBringToFront', "Bring All to Front"), role: 'front', enabled: this.windowsService.getWindowCount() > 0 }); const bringAllToFront = new MenuItem({ label: nls.localize('mBringToFront', "Bring All to Front"), role: 'front', enabled: this.windowsService.getWindowCount() > 0 });
const switchWindow = this.createMenuItem(nls.localize({ key: 'miSwitchWindow', comment: ['&& denotes a mnemonic'] }, "Switch &&Window..."), 'workbench.action.switchWindow'); const switchWindow = this.createMenuItem(nls.localize({ key: 'miSwitchWindow', comment: ['&& denotes a mnemonic'] }, "Switch &&Window..."), 'workbench.action.switchWindow');
const nativeTabMenuItems: Electron.MenuItem[] = [];
if (this.currentEnableNativeTabs) {
const hasMultipleWindows = this.windowsService.getWindowCount() > 1;
this.nativeTabMenuItems.push(new MenuItem({ label: nls.localize('mShowPreviousTab', "Show Previous Tab"), enabled: hasMultipleWindows, click: () => Menu.sendActionToFirstResponder('selectPreviousTab:') }));
this.nativeTabMenuItems.push(new MenuItem({ label: nls.localize('mShowNextTab', "Show Next Tab"), enabled: hasMultipleWindows, click: () => Menu.sendActionToFirstResponder('selectNextTab:') }));
this.nativeTabMenuItems.push(new MenuItem({ label: nls.localize('mMoveTabToNewWindow', "Move Tab to New Window"), enabled: hasMultipleWindows, click: () => Menu.sendActionToFirstResponder('moveTabToNewWindow:') }));
this.nativeTabMenuItems.push(new MenuItem({ label: nls.localize('mMergeAllWindows', "Merge All Windows"), enabled: hasMultipleWindows, click: () => Menu.sendActionToFirstResponder('mergeAllWindows:') }));
nativeTabMenuItems.push(__separator__(), ...this.nativeTabMenuItems);
} else {
this.nativeTabMenuItems = [];
}
[ [
minimize, minimize,
zoom, zoom,
switchWindow, switchWindow,
...nativeTabMenuItems,
__separator__(), __separator__(),
bringAllToFront bringAllToFront
].forEach(item => macWindowMenu.append(item)); ].forEach(item => macWindowMenu.append(item));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册