mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 14:57:14 +00:00
fixes #55454
This commit is contained in:
parent
c8f0ee9763
commit
9129656f3d
|
@ -112,8 +112,14 @@ export class Menubar {
|
|||
return enableNativeTabs;
|
||||
}
|
||||
|
||||
updateMenu(menus: IMenubarData, windowId: number) {
|
||||
updateMenu(menus: IMenubarData, windowId: number, additionalKeybindings?: Array<IMenubarKeybinding>) {
|
||||
this.menubarMenus = menus;
|
||||
if (additionalKeybindings) {
|
||||
additionalKeybindings.forEach(keybinding => {
|
||||
this.keybindings[keybinding.id] = keybinding;
|
||||
});
|
||||
}
|
||||
|
||||
this.scheduleUpdateMenu();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export const IMenubarService = createDecorator<IMenubarService>('menubarService'
|
|||
export interface IMenubarService {
|
||||
_serviceBrand: any;
|
||||
|
||||
updateMenubar(windowId: number, menus: IMenubarData): TPromise<void>;
|
||||
updateMenubar(windowId: number, menus: IMenubarData, additionalKeybindings?: Array<IMenubarKeybinding>): TPromise<void>;
|
||||
}
|
||||
|
||||
export interface IMenubarData {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
'use strict';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar';
|
||||
import { IMenubarService, IMenubarData, IMenubarKeybinding } from 'vs/platform/menubar/common/menubar';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
export interface IMenubarChannel extends IChannel {
|
||||
|
@ -24,7 +24,7 @@ export class MenubarChannel implements IMenubarChannel {
|
|||
|
||||
call(command: string, arg?: any): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'updateMenubar': return this.service.updateMenubar(arg[0], arg[1]);
|
||||
case 'updateMenubar': return this.service.updateMenubar(arg[0], arg[1], arg[2]);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ export class MenubarChannelClient implements IMenubarService {
|
|||
|
||||
constructor(private channel: IMenubarChannel) { }
|
||||
|
||||
updateMenubar(windowId: number, menus: IMenubarData): TPromise<void> {
|
||||
return this.channel.call('updateMenubar', [windowId, menus]);
|
||||
updateMenubar(windowId: number, menus: IMenubarData, additionalKeybindings?: Array<IMenubarKeybinding>): TPromise<void> {
|
||||
return this.channel.call('updateMenubar', [windowId, menus, additionalKeybindings]);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar';
|
||||
import { IMenubarService, IMenubarData, IMenubarKeybinding } from 'vs/platform/menubar/common/menubar';
|
||||
import { Menubar } from 'vs/code/electron-main/menubar';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
@ -24,11 +24,11 @@ export class MenubarService implements IMenubarService {
|
|||
this._menubar = this.instantiationService.createInstance(Menubar);
|
||||
}
|
||||
|
||||
updateMenubar(windowId: number, menus: IMenubarData): TPromise<void> {
|
||||
updateMenubar(windowId: number, menus: IMenubarData, additionalKeybindings?: Array<IMenubarKeybinding>): TPromise<void> {
|
||||
this.logService.trace('menubarService#updateMenubar', windowId);
|
||||
|
||||
if (this._menubar) {
|
||||
this._menubar.updateMenu(menus, windowId);
|
||||
this._menubar.updateMenu(menus, windowId, additionalKeybindings);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
|
|
|
@ -430,8 +430,7 @@ export class MenubarPart extends Part {
|
|||
this.setupCustomMenubar();
|
||||
} else {
|
||||
// Send menus to main process to be rendered by Electron
|
||||
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus());
|
||||
|
||||
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus(), this.getAdditionalKeybindings());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -846,6 +845,15 @@ export class MenubarPart extends Part {
|
|||
}
|
||||
}
|
||||
|
||||
private getAdditionalKeybindings(): Array<IMenubarKeybinding> {
|
||||
const keybindings = [];
|
||||
if (isMacintosh) {
|
||||
keybindings.push(this.getMenubarKeybinding('workbench.action.quit'));
|
||||
}
|
||||
|
||||
return keybindings;
|
||||
}
|
||||
|
||||
private getMenubarMenus(): IMenubarData {
|
||||
let ret: IMenubarData = {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue