@theia/core 1.37.0-next.8 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -9
- package/i18n/nls.cs.json +6 -1
- package/i18n/nls.de.json +6 -1
- package/i18n/nls.es.json +6 -1
- package/i18n/nls.fr.json +6 -1
- package/i18n/nls.hu.json +6 -1
- package/i18n/nls.it.json +6 -1
- package/i18n/nls.ja.json +6 -1
- package/i18n/nls.json +6 -1
- package/i18n/nls.pl.json +6 -1
- package/i18n/nls.pt-br.json +6 -1
- package/i18n/nls.pt-pt.json +6 -1
- package/i18n/nls.ru.json +6 -1
- package/i18n/nls.zh-cn.json +6 -1
- package/lib/browser/core-preferences.d.ts +4 -0
- package/lib/browser/core-preferences.d.ts.map +1 -1
- package/lib/browser/core-preferences.js +22 -0
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/hover-service.d.ts +5 -0
- package/lib/browser/hover-service.d.ts.map +1 -1
- package/lib/browser/hover-service.js +7 -1
- package/lib/browser/hover-service.js.map +1 -1
- package/lib/browser/icon-theme-service.js +1 -1
- package/lib/browser/icon-theme-service.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +2 -1
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +30 -3
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts +21 -5
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +94 -17
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/test/jsdom.js +1 -1
- package/lib/browser/test/jsdom.js.map +1 -1
- package/lib/browser/tree/tree-iterator.js +4 -4
- package/lib/browser/tree/tree-iterator.js.map +1 -1
- package/lib/browser/tree/tree-selection-state.spec.js +26 -2
- package/lib/browser/tree/tree-selection-state.spec.js.map +1 -1
- package/lib/common/i18n/localization.d.ts +1 -0
- package/lib/common/i18n/localization.d.ts.map +1 -1
- package/lib/common/i18n/localization.js +2 -16
- package/lib/common/i18n/localization.js.map +1 -1
- package/lib/common/nls.d.ts +1 -0
- package/lib/common/nls.d.ts.map +1 -1
- package/lib/common/nls.js +2 -1
- package/lib/common/nls.js.map +1 -1
- package/lib/common/quick-pick-service.d.ts +2 -1
- package/lib/common/quick-pick-service.d.ts.map +1 -1
- package/lib/common/quick-pick-service.js.map +1 -1
- package/lib/electron-browser/electron-clipboard-service.d.ts.map +1 -1
- package/lib/electron-browser/electron-clipboard-service.js +2 -3
- package/lib/electron-browser/electron-clipboard-service.js.map +1 -1
- package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.d.ts.map +1 -1
- package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.js +1 -2
- package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.js.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +2 -3
- package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.js +10 -18
- package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +10 -8
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.js +33 -32
- package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.d.ts +6 -6
- package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.js +39 -54
- package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js +2 -6
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +1 -1
- package/lib/electron-browser/preload.d.ts +2 -0
- package/lib/electron-browser/preload.d.ts.map +1 -0
- package/lib/electron-browser/preload.js +183 -0
- package/lib/electron-browser/preload.js.map +1 -0
- package/lib/electron-browser/token/electron-token-frontend-module.d.ts.map +1 -1
- package/lib/electron-browser/token/electron-token-frontend-module.js +1 -2
- package/lib/electron-browser/token/electron-token-frontend-module.js.map +1 -1
- package/lib/electron-browser/window/electron-frontend-application-state.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-frontend-application-state.js +1 -3
- package/lib/electron-browser/window/electron-frontend-application-state.js.map +1 -1
- package/lib/electron-browser/window/electron-secondary-window-service.d.ts +1 -3
- package/lib/electron-browser/window/electron-secondary-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-secondary-window-service.js +6 -34
- package/lib/electron-browser/window/electron-secondary-window-service.js.map +1 -1
- package/lib/electron-browser/window/electron-window-service.d.ts +1 -8
- package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-service.js +8 -25
- package/lib/electron-browser/window/electron-window-service.js.map +1 -1
- package/lib/electron-common/electron-api.d.ts +94 -0
- package/lib/electron-common/electron-api.d.ts.map +1 -0
- package/lib/electron-common/electron-api.js +53 -0
- package/lib/electron-common/electron-api.js.map +1 -0
- package/lib/electron-common/messaging/electron-connection-handler.d.ts +0 -7
- package/lib/electron-common/messaging/electron-connection-handler.d.ts.map +1 -1
- package/lib/electron-common/messaging/electron-connection-handler.js +1 -5
- package/lib/electron-common/messaging/electron-connection-handler.js.map +1 -1
- package/lib/electron-main/electron-api-main.d.ts +21 -0
- package/lib/electron-main/electron-api-main.d.ts.map +1 -0
- package/lib/electron-main/electron-api-main.js +261 -0
- package/lib/electron-main/electron-api-main.js.map +1 -0
- package/lib/electron-main/electron-main-application-module.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application-module.js +3 -3
- package/lib/electron-main/electron-main-application-module.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts +8 -2
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +32 -29
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/electron-security-token-service.d.ts.map +1 -1
- package/lib/electron-main/electron-security-token-service.js +2 -1
- package/lib/electron-main/electron-security-token-service.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +4 -5
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.js +4 -7
- package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts +2 -4
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +11 -34
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/lib/node/i18n/localization-backend-contribution.d.ts.map +1 -1
- package/lib/node/i18n/localization-backend-contribution.js +2 -1
- package/lib/node/i18n/localization-backend-contribution.js.map +1 -1
- package/lib/node/i18n/localization-provider.d.ts.map +1 -1
- package/lib/node/i18n/localization-provider.js +2 -1
- package/lib/node/i18n/localization-provider.js.map +1 -1
- package/package.json +9 -6
- package/src/browser/core-preferences.ts +26 -0
- package/src/browser/hover-service.ts +12 -1
- package/src/browser/icon-theme-service.ts +1 -1
- package/src/browser/shell/application-shell.ts +29 -1
- package/src/browser/shell/tab-bars.ts +111 -17
- package/src/browser/style/hover-service.css +4 -0
- package/src/browser/style/tabs.css +25 -0
- package/src/browser/style/tree.css +1 -0
- package/src/browser/test/jsdom.ts +1 -1
- package/src/browser/tree/tree-iterator.ts +4 -4
- package/src/browser/tree/tree-selection-state.spec.ts +29 -2
- package/src/common/i18n/localization.ts +6 -16
- package/src/common/nls.ts +3 -1
- package/src/common/quick-pick-service.ts +2 -1
- package/src/electron-browser/electron-clipboard-service.ts +2 -3
- package/src/electron-browser/keyboard/electron-keyboard-layout-change-notifier.ts +1 -2
- package/src/electron-browser/menu/electron-context-menu-renderer.ts +10 -17
- package/src/electron-browser/menu/electron-main-menu-factory.ts +51 -44
- package/src/electron-browser/menu/electron-menu-contribution.ts +46 -57
- package/src/electron-browser/messaging/electron-ipc-connection-provider.ts +4 -9
- package/src/electron-browser/preload.ts +208 -0
- package/src/electron-browser/token/electron-token-frontend-module.ts +1 -2
- package/src/electron-browser/window/electron-frontend-application-state.ts +1 -3
- package/src/electron-browser/window/electron-secondary-window-service.ts +7 -31
- package/src/electron-browser/window/electron-window-service.ts +8 -25
- package/src/electron-common/electron-api.ts +134 -0
- package/src/electron-common/messaging/electron-connection-handler.ts +0 -9
- package/src/electron-main/electron-api-main.ts +291 -0
- package/src/electron-main/electron-main-application-module.ts +3 -4
- package/src/electron-main/electron-main-application.ts +33 -37
- package/src/electron-main/electron-security-token-service.ts +2 -1
- package/src/electron-main/messaging/electron-messaging-contribution.ts +8 -10
- package/src/electron-main/theia-electron-window.ts +8 -33
- package/src/node/i18n/localization-backend-contribution.ts +2 -1
- package/src/node/i18n/localization-provider.ts +2 -1
- package/LICENSE +0 -642
- package/electron-shared/@electron/remote/index.d.ts +0 -1
- package/electron-shared/@electron/remote/index.js +0 -1
- package/electron-shared/@electron/remote/main/index.d.ts +0 -1
- package/electron-shared/@electron/remote/main/index.js +0 -1
- package/lib/electron-common/messaging/electron-messages.d.ts +0 -25
- package/lib/electron-common/messaging/electron-messages.d.ts.map +0 -1
- package/lib/electron-common/messaging/electron-messages.js +0 -37
- package/lib/electron-common/messaging/electron-messages.js.map +0 -1
- package/lib/electron-main/electron-native-keymap.d.ts +0 -8
- package/lib/electron-main/electron-native-keymap.d.ts.map +0 -1
- package/lib/electron-main/electron-native-keymap.js +0 -48
- package/lib/electron-main/electron-native-keymap.js.map +0 -1
- package/src/electron-common/messaging/electron-messages.ts +0 -42
- package/src/electron-main/electron-native-keymap.ts +0 -40
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
18
|
|
|
19
|
-
import * as electronRemote from '../../../electron-shared/@electron/remote';
|
|
20
19
|
import { inject, injectable, postConstruct } from 'inversify';
|
|
21
20
|
import { isOSX, MAIN_MENU_BAR, MenuPath, MenuNode, CommandMenuNode, CompoundMenuNode, CompoundMenuNodeRole } from '../../common';
|
|
22
21
|
import { Keybinding } from '../../common/keybinding';
|
|
@@ -24,7 +23,8 @@ import { PreferenceService, CommonCommands } from '../../browser';
|
|
|
24
23
|
import debounce = require('lodash.debounce');
|
|
25
24
|
import { MAXIMIZED_CLASS } from '../../browser/shell/theia-dock-panel';
|
|
26
25
|
import { BrowserMainMenuFactory } from '../../browser/menu/browser-menu-plugin';
|
|
27
|
-
import { ContextMatcher } from '
|
|
26
|
+
import { ContextMatcher } from '../../browser/context-key-service';
|
|
27
|
+
import { MenuDto, MenuRole } from '../../electron-common/electron-api';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Representation of possible electron menu options.
|
|
@@ -68,7 +68,7 @@ export type ElectronMenuItemRole = ('undo' | 'redo' | 'cut' | 'copy' | 'paste' |
|
|
|
68
68
|
@injectable()
|
|
69
69
|
export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
70
70
|
|
|
71
|
-
protected _menu?:
|
|
71
|
+
protected _menu?: MenuDto[];
|
|
72
72
|
protected _toggledCommands: Set<string> = new Set();
|
|
73
73
|
|
|
74
74
|
@inject(PreferenceService)
|
|
@@ -82,13 +82,13 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
82
82
|
this.setMenuBar();
|
|
83
83
|
}
|
|
84
84
|
if (this._menu) {
|
|
85
|
-
for (const
|
|
86
|
-
const menuItem = this._menu
|
|
85
|
+
for (const cmd of this._toggledCommands) {
|
|
86
|
+
const menuItem = this.findMenuById(this._menu, cmd);
|
|
87
87
|
if (menuItem) {
|
|
88
|
-
menuItem.checked = this.commandRegistry.isToggled(
|
|
88
|
+
menuItem.checked = this.commandRegistry.isToggled(cmd);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
window.electronTheiaCore.setMenu(this._menu);
|
|
92
92
|
}
|
|
93
93
|
}, 10)
|
|
94
94
|
);
|
|
@@ -99,56 +99,49 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
99
99
|
|
|
100
100
|
async setMenuBar(): Promise<void> {
|
|
101
101
|
await this.preferencesService.ready;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
electronRemote.Menu.setApplicationMenu(createdMenuBar);
|
|
105
|
-
} else if (this.preferencesService.get('window.titleBarStyle') === 'native') {
|
|
106
|
-
const createdMenuBar = this.createElectronMenuBar();
|
|
107
|
-
electronRemote.getCurrentWindow().setMenu(createdMenuBar);
|
|
108
|
-
}
|
|
102
|
+
const createdMenuBar = this.createElectronMenuBar();
|
|
103
|
+
window.electronTheiaCore.setMenu(createdMenuBar);
|
|
109
104
|
}
|
|
110
105
|
|
|
111
|
-
createElectronMenuBar():
|
|
106
|
+
createElectronMenuBar(): MenuDto[] | undefined {
|
|
112
107
|
const preference = this.preferencesService.get<string>('window.menuBarVisibility') || 'classic';
|
|
113
108
|
const maxWidget = document.getElementsByClassName(MAXIMIZED_CLASS);
|
|
114
109
|
if (preference === 'visible' || (preference === 'classic' && maxWidget.length === 0)) {
|
|
115
110
|
const menuModel = this.menuProvider.getMenu(MAIN_MENU_BAR);
|
|
116
|
-
|
|
111
|
+
this._menu = this.fillMenuTemplate([], menuModel, [], { rootMenuPath: MAIN_MENU_BAR });
|
|
117
112
|
if (isOSX) {
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
const menu = electronRemote.Menu.buildFromTemplate(template);
|
|
121
|
-
if (!menu) {
|
|
122
|
-
throw new Error('menu is null');
|
|
113
|
+
this._menu.unshift(this.createOSXMenu());
|
|
123
114
|
}
|
|
124
|
-
this._menu = menu;
|
|
125
115
|
return this._menu;
|
|
126
116
|
}
|
|
127
117
|
this._menu = undefined;
|
|
128
118
|
// eslint-disable-next-line no-null/no-null
|
|
129
|
-
return
|
|
119
|
+
return undefined;
|
|
130
120
|
}
|
|
131
121
|
|
|
132
|
-
createElectronContextMenu(menuPath: MenuPath, args?: any[], context?: HTMLElement, contextKeyService?: ContextMatcher):
|
|
122
|
+
createElectronContextMenu(menuPath: MenuPath, args?: any[], context?: HTMLElement, contextKeyService?: ContextMatcher): MenuDto[] {
|
|
133
123
|
const menuModel = this.menuProvider.getMenu(menuPath);
|
|
134
|
-
|
|
135
|
-
return electronRemote.Menu.buildFromTemplate(template);
|
|
124
|
+
return this.fillMenuTemplate([], menuModel, args, { showDisabled: false, context, rootMenuPath: menuPath, contextKeyService });
|
|
136
125
|
}
|
|
137
126
|
|
|
138
|
-
protected fillMenuTemplate(parentItems:
|
|
127
|
+
protected fillMenuTemplate(parentItems: MenuDto[],
|
|
139
128
|
menu: MenuNode,
|
|
140
129
|
args: unknown[] = [],
|
|
141
130
|
options: ElectronMenuOptions
|
|
142
|
-
):
|
|
131
|
+
): MenuDto[] {
|
|
143
132
|
const showDisabled = options?.showDisabled !== false;
|
|
144
133
|
|
|
145
134
|
if (CompoundMenuNode.is(menu) && menu.children.length && this.undefinedOrMatch(options.contextKeyService ?? this.contextKeyService, menu.when, options.context)) {
|
|
146
135
|
const role = CompoundMenuNode.getRole(menu);
|
|
147
|
-
if (role === CompoundMenuNodeRole.Group && menu.id === 'inline') {
|
|
136
|
+
if (role === CompoundMenuNodeRole.Group && menu.id === 'inline') {
|
|
137
|
+
return parentItems;
|
|
138
|
+
}
|
|
148
139
|
const children = CompoundMenuNode.getFlatChildren(menu.children);
|
|
149
|
-
const myItems:
|
|
140
|
+
const myItems: MenuDto[] = [];
|
|
150
141
|
children.forEach(child => this.fillMenuTemplate(myItems, child, args, options));
|
|
151
|
-
if (myItems.length === 0) {
|
|
142
|
+
if (myItems.length === 0) {
|
|
143
|
+
return parentItems;
|
|
144
|
+
}
|
|
152
145
|
if (role === CompoundMenuNodeRole.Submenu) {
|
|
153
146
|
parentItems.push({ label: menu.label, submenu: myItems });
|
|
154
147
|
} else if (role === CompoundMenuNodeRole.Group && menu.id !== 'inline') {
|
|
@@ -183,7 +176,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
183
176
|
|
|
184
177
|
const accelerator = bindings[0] && this.acceleratorFor(bindings[0]);
|
|
185
178
|
|
|
186
|
-
const menuItem:
|
|
179
|
+
const menuItem: MenuDto = {
|
|
187
180
|
id: node.id,
|
|
188
181
|
label: node.label,
|
|
189
182
|
type: this.commandRegistry.getToggledHandler(commandId, ...args) ? 'checkbox' : 'normal',
|
|
@@ -191,14 +184,14 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
191
184
|
enabled: true, // https://github.com/eclipse-theia/theia/issues/446
|
|
192
185
|
visible: true,
|
|
193
186
|
accelerator,
|
|
194
|
-
|
|
187
|
+
execute: () => this.execute(commandId, args, options.rootMenuPath)
|
|
195
188
|
};
|
|
196
189
|
|
|
197
190
|
if (isOSX) {
|
|
198
191
|
const role = this.roleFor(node.id);
|
|
199
192
|
if (role) {
|
|
200
193
|
menuItem.role = role;
|
|
201
|
-
delete menuItem.
|
|
194
|
+
delete menuItem.execute;
|
|
202
195
|
}
|
|
203
196
|
}
|
|
204
197
|
parentItems.push(menuItem);
|
|
@@ -235,8 +228,8 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
235
228
|
return this.keybindingRegistry.acceleratorForKeyCode(keyCode, '+', true);
|
|
236
229
|
}
|
|
237
230
|
|
|
238
|
-
protected roleFor(id: string):
|
|
239
|
-
let role:
|
|
231
|
+
protected roleFor(id: string): MenuRole | undefined {
|
|
232
|
+
let role: MenuRole | undefined;
|
|
240
233
|
switch (id) {
|
|
241
234
|
case CommonCommands.UNDO.id:
|
|
242
235
|
role = 'undo';
|
|
@@ -262,18 +255,18 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
262
255
|
return role;
|
|
263
256
|
}
|
|
264
257
|
|
|
265
|
-
protected async execute(
|
|
258
|
+
protected async execute(cmd: string, args: any[], menuPath: MenuPath): Promise<void> {
|
|
266
259
|
try {
|
|
267
260
|
// This is workaround for https://github.com/eclipse-theia/theia/issues/446.
|
|
268
261
|
// Electron menus do not update based on the `isEnabled`, `isVisible` property of the command.
|
|
269
262
|
// We need to check if we can execute it.
|
|
270
|
-
if (this.menuCommandExecutor.isEnabled(menuPath,
|
|
271
|
-
await this.menuCommandExecutor.executeCommand(menuPath,
|
|
272
|
-
if (this._menu && this.menuCommandExecutor.isVisible(menuPath,
|
|
273
|
-
const item = this._menu
|
|
263
|
+
if (this.menuCommandExecutor.isEnabled(menuPath, cmd, ...args)) {
|
|
264
|
+
await this.menuCommandExecutor.executeCommand(menuPath, cmd, ...args);
|
|
265
|
+
if (this._menu && this.menuCommandExecutor.isVisible(menuPath, cmd, ...args)) {
|
|
266
|
+
const item = this.findMenuById(this._menu, cmd);
|
|
274
267
|
if (item) {
|
|
275
|
-
item.checked = this.menuCommandExecutor.isToggled(menuPath,
|
|
276
|
-
|
|
268
|
+
item.checked = this.menuCommandExecutor.isToggled(menuPath, cmd, ...args);
|
|
269
|
+
window.electronTheiaCore.setMenu(this._menu);
|
|
277
270
|
}
|
|
278
271
|
}
|
|
279
272
|
}
|
|
@@ -281,8 +274,22 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
281
274
|
// no-op
|
|
282
275
|
}
|
|
283
276
|
}
|
|
277
|
+
findMenuById(items: MenuDto[], id: string): MenuDto | undefined {
|
|
278
|
+
for (const item of items) {
|
|
279
|
+
if (item.id === id) {
|
|
280
|
+
return item;
|
|
281
|
+
}
|
|
282
|
+
if (item.submenu) {
|
|
283
|
+
const found = this.findMenuById(item.submenu, id);
|
|
284
|
+
if (found) {
|
|
285
|
+
return found;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
284
291
|
|
|
285
|
-
protected createOSXMenu():
|
|
292
|
+
protected createOSXMenu(): MenuDto {
|
|
286
293
|
return {
|
|
287
294
|
label: 'Theia',
|
|
288
295
|
submenu: [
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import * as electron from '../../../electron-shared/electron';
|
|
18
|
-
import * as electronRemote from '../../../electron-shared/@electron/remote';
|
|
19
17
|
import { inject, injectable, postConstruct } from 'inversify';
|
|
20
18
|
import { Command, CommandContribution, CommandRegistry, isOSX, isWindows, MenuModelRegistry, MenuContribution, Disposable, nls } from '../../common';
|
|
21
19
|
import {
|
|
@@ -25,13 +23,13 @@ import {
|
|
|
25
23
|
import { ElectronMainMenuFactory } from './electron-main-menu-factory';
|
|
26
24
|
import { FrontendApplicationStateService, FrontendApplicationState } from '../../browser/frontend-application-state';
|
|
27
25
|
import { FrontendApplicationConfigProvider } from '../../browser/frontend-application-config-provider';
|
|
28
|
-
import { RequestTitleBarStyle, Restart, TitleBarStyleAtStartup, TitleBarStyleChanged } from '../../electron-common/messaging/electron-messages';
|
|
29
26
|
import { ZoomLevel } from '../window/electron-window-preferences';
|
|
30
27
|
import { BrowserMenuBarContribution } from '../../browser/menu/browser-menu-plugin';
|
|
31
28
|
import { WindowService } from '../../browser/window/window-service';
|
|
32
29
|
import { WindowTitleService } from '../../browser/window/window-title-service';
|
|
33
30
|
|
|
34
31
|
import '../../../src/electron-browser/menu/electron-menu-style.css';
|
|
32
|
+
import { MenuDto } from '../../electron-common/electron-api';
|
|
35
33
|
|
|
36
34
|
export namespace ElectronCommands {
|
|
37
35
|
export const TOGGLE_DEVELOPER_TOOLS = Command.toDefaultLocalizedCommand({
|
|
@@ -131,38 +129,38 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
131
129
|
// OSX: Recreate the menus when changing windows.
|
|
132
130
|
// OSX only has one menu bar for all windows, so we need to swap
|
|
133
131
|
// between them as the user switches windows.
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
window.addEventListener('unload', () =>
|
|
132
|
+
const disposeHandler = window.electronTheiaCore.onWindowEvent('focus', () => {
|
|
133
|
+
this.setMenu(app);
|
|
134
|
+
});
|
|
135
|
+
window.addEventListener('unload', () => disposeHandler.dispose());
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
protected attachMenuBarVisibilityListener(): void {
|
|
141
139
|
this.preferenceService.onPreferenceChanged(e => {
|
|
142
140
|
if (e.preferenceName === 'window.menuBarVisibility') {
|
|
143
|
-
|
|
144
|
-
this.handleFullScreen(targetWindow, e.newValue);
|
|
141
|
+
this.handleFullScreen(e.newValue);
|
|
145
142
|
}
|
|
146
143
|
});
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
handleTitleBarStyling(app: FrontendApplication): void {
|
|
150
147
|
this.hideTopPanel(app);
|
|
151
|
-
|
|
148
|
+
window.electronTheiaCore.getTitleBarStyleAtStartup().then(style => {
|
|
152
149
|
this.titleBarStyle = style;
|
|
153
150
|
this.setMenu(app);
|
|
154
151
|
this.preferenceService.ready.then(() => {
|
|
155
152
|
this.preferenceService.set('window.titleBarStyle', this.titleBarStyle, PreferenceScope.User);
|
|
156
153
|
});
|
|
157
154
|
});
|
|
158
|
-
|
|
155
|
+
|
|
159
156
|
this.preferenceService.ready.then(() => {
|
|
160
|
-
|
|
157
|
+
window.electronTheiaCore.setMenuBarVisible(['classic', 'visible'].includes(this.preferenceService.get('window.menuBarVisibility', 'classic')));
|
|
161
158
|
});
|
|
159
|
+
|
|
162
160
|
this.preferenceService.onPreferenceChanged(change => {
|
|
163
161
|
if (change.preferenceName === 'window.titleBarStyle') {
|
|
164
|
-
if (this.titleBarStyleChangeFlag && this.titleBarStyle !== change.newValue
|
|
165
|
-
|
|
162
|
+
if (this.titleBarStyleChangeFlag && this.titleBarStyle !== change.newValue) {
|
|
163
|
+
window.electronTheiaCore.setTitleBarStyle(change.newValue);
|
|
166
164
|
this.handleRequiredRestart();
|
|
167
165
|
}
|
|
168
166
|
this.titleBarStyleChangeFlag = true;
|
|
@@ -197,21 +195,18 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
protected setMenu(app: FrontendApplication, electronMenu:
|
|
201
|
-
|
|
202
|
-
if (isOSX) {
|
|
203
|
-
electronRemote.Menu.setApplicationMenu(electronMenu);
|
|
204
|
-
} else {
|
|
198
|
+
protected setMenu(app: FrontendApplication, electronMenu: MenuDto[] | undefined = this.factory.createElectronMenuBar()): void {
|
|
199
|
+
if (!isOSX) {
|
|
205
200
|
this.hideTopPanel(app);
|
|
206
201
|
if (this.titleBarStyle === 'custom' && !this.menuBar) {
|
|
207
|
-
this.createCustomTitleBar(app
|
|
202
|
+
this.createCustomTitleBar(app);
|
|
203
|
+
return;
|
|
208
204
|
}
|
|
209
|
-
// Unix/Windows: Set the per-window menus
|
|
210
|
-
electronWindow.setMenu(electronMenu);
|
|
211
205
|
}
|
|
206
|
+
window.electronTheiaCore.setMenu(electronMenu);
|
|
212
207
|
}
|
|
213
208
|
|
|
214
|
-
protected createCustomTitleBar(app: FrontendApplication
|
|
209
|
+
protected createCustomTitleBar(app: FrontendApplication): void {
|
|
215
210
|
const dragPanel = new Widget();
|
|
216
211
|
dragPanel.id = 'theia-drag-panel';
|
|
217
212
|
app.shell.addWidget(dragPanel, { area: 'top' });
|
|
@@ -220,13 +215,13 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
220
215
|
const controls = document.createElement('div');
|
|
221
216
|
controls.id = 'window-controls';
|
|
222
217
|
controls.append(
|
|
223
|
-
this.createControlButton('minimize', () =>
|
|
224
|
-
this.createControlButton('maximize', () =>
|
|
225
|
-
this.createControlButton('restore', () =>
|
|
226
|
-
this.createControlButton('close', () =>
|
|
218
|
+
this.createControlButton('minimize', () => window.electronTheiaCore.minimize()),
|
|
219
|
+
this.createControlButton('maximize', () => window.electronTheiaCore.maximize()),
|
|
220
|
+
this.createControlButton('restore', () => window.electronTheiaCore.unMaximize()),
|
|
221
|
+
this.createControlButton('close', () => window.electronTheiaCore.close())
|
|
227
222
|
);
|
|
228
223
|
app.shell.topPanel.node.append(controls);
|
|
229
|
-
this.handleWindowControls(
|
|
224
|
+
this.handleWindowControls();
|
|
230
225
|
}
|
|
231
226
|
|
|
232
227
|
protected createCustomTitleWidget(app: FrontendApplication): void {
|
|
@@ -236,13 +231,13 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
236
231
|
}
|
|
237
232
|
}
|
|
238
233
|
|
|
239
|
-
protected handleWindowControls(
|
|
234
|
+
protected handleWindowControls(): void {
|
|
240
235
|
toggleControlButtons();
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
window.electronTheiaCore.onWindowEvent('maximize', toggleControlButtons);
|
|
237
|
+
window.electronTheiaCore.onWindowEvent('unmaximize', toggleControlButtons);
|
|
243
238
|
|
|
244
239
|
function toggleControlButtons(): void {
|
|
245
|
-
if (
|
|
240
|
+
if (window.electronTheiaCore.isMaximized()) {
|
|
246
241
|
document.body.classList.add('maximized');
|
|
247
242
|
} else {
|
|
248
243
|
document.body.classList.remove('maximized');
|
|
@@ -275,22 +270,15 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
275
270
|
});
|
|
276
271
|
if (await dialog.open()) {
|
|
277
272
|
this.windowService.setSafeToShutDown();
|
|
278
|
-
|
|
273
|
+
window.electronTheiaCore.restart();
|
|
279
274
|
}
|
|
280
275
|
}
|
|
281
276
|
|
|
282
277
|
registerCommands(registry: CommandRegistry): void {
|
|
283
278
|
|
|
284
|
-
const currentWindow = electronRemote.getCurrentWindow();
|
|
285
|
-
|
|
286
279
|
registry.registerCommand(ElectronCommands.TOGGLE_DEVELOPER_TOOLS, {
|
|
287
280
|
execute: () => {
|
|
288
|
-
|
|
289
|
-
if (!webContent.isDevToolsOpened()) {
|
|
290
|
-
webContent.openDevTools();
|
|
291
|
-
} else {
|
|
292
|
-
webContent.closeDevTools();
|
|
293
|
-
}
|
|
281
|
+
window.electronTheiaCore.toggleDevTools();
|
|
294
282
|
}
|
|
295
283
|
});
|
|
296
284
|
|
|
@@ -298,14 +286,14 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
298
286
|
execute: () => this.windowService.reload()
|
|
299
287
|
});
|
|
300
288
|
registry.registerCommand(ElectronCommands.CLOSE_WINDOW, {
|
|
301
|
-
execute: () =>
|
|
289
|
+
execute: () => window.electronTheiaCore.close()
|
|
302
290
|
});
|
|
303
291
|
|
|
304
292
|
registry.registerCommand(ElectronCommands.ZOOM_IN, {
|
|
305
|
-
execute: () => {
|
|
306
|
-
const
|
|
293
|
+
execute: async () => {
|
|
294
|
+
const currentLevel = await window.electronTheiaCore.getZoomLevel();
|
|
307
295
|
// When starting at a level that is not a multiple of 0.5, increment by at most 0.5 to reach the next highest multiple of 0.5.
|
|
308
|
-
let zoomLevel = (Math.floor(
|
|
296
|
+
let zoomLevel = (Math.floor(currentLevel / ZoomLevel.VARIATION) * ZoomLevel.VARIATION) + ZoomLevel.VARIATION;
|
|
309
297
|
if (zoomLevel > ZoomLevel.MAX) {
|
|
310
298
|
zoomLevel = ZoomLevel.MAX;
|
|
311
299
|
return;
|
|
@@ -314,10 +302,10 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
314
302
|
}
|
|
315
303
|
});
|
|
316
304
|
registry.registerCommand(ElectronCommands.ZOOM_OUT, {
|
|
317
|
-
execute: () => {
|
|
318
|
-
const
|
|
305
|
+
execute: async () => {
|
|
306
|
+
const currentLevel = await window.electronTheiaCore.getZoomLevel();
|
|
319
307
|
// When starting at a level that is not a multiple of 0.5, decrement by at most 0.5 to reach the next lowest multiple of 0.5.
|
|
320
|
-
let zoomLevel = (Math.ceil(
|
|
308
|
+
let zoomLevel = (Math.ceil(currentLevel / ZoomLevel.VARIATION) * ZoomLevel.VARIATION) - ZoomLevel.VARIATION;
|
|
321
309
|
if (zoomLevel < ZoomLevel.MIN) {
|
|
322
310
|
zoomLevel = ZoomLevel.MIN;
|
|
323
311
|
return;
|
|
@@ -328,10 +316,11 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
328
316
|
registry.registerCommand(ElectronCommands.RESET_ZOOM, {
|
|
329
317
|
execute: () => this.preferenceService.set('window.zoomLevel', ZoomLevel.DEFAULT, PreferenceScope.User)
|
|
330
318
|
});
|
|
319
|
+
|
|
331
320
|
registry.registerCommand(ElectronCommands.TOGGLE_FULL_SCREEN, {
|
|
332
|
-
isEnabled: () =>
|
|
333
|
-
isVisible: () =>
|
|
334
|
-
execute: () => this.toggleFullScreen(
|
|
321
|
+
isEnabled: () => window.electronTheiaCore.isFullScreenable(),
|
|
322
|
+
isVisible: () => window.electronTheiaCore.isFullScreenable(),
|
|
323
|
+
execute: () => this.toggleFullScreen()
|
|
335
324
|
});
|
|
336
325
|
}
|
|
337
326
|
|
|
@@ -408,16 +397,16 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
|
|
|
408
397
|
});
|
|
409
398
|
}
|
|
410
399
|
|
|
411
|
-
protected toggleFullScreen(
|
|
412
|
-
|
|
400
|
+
protected toggleFullScreen(): void {
|
|
401
|
+
window.electronTheiaCore.toggleFullScreen();
|
|
413
402
|
const menuBarVisibility = this.preferenceService.get('window.menuBarVisibility', 'classic');
|
|
414
|
-
this.handleFullScreen(
|
|
403
|
+
this.handleFullScreen(menuBarVisibility);
|
|
415
404
|
}
|
|
416
405
|
|
|
417
|
-
protected handleFullScreen(
|
|
418
|
-
const shouldShowTop = !
|
|
406
|
+
protected handleFullScreen(menuBarVisibility: string): void {
|
|
407
|
+
const shouldShowTop = !window.electronTheiaCore.isFullScreen() || menuBarVisibility === 'visible';
|
|
419
408
|
if (this.titleBarStyle === 'native') {
|
|
420
|
-
|
|
409
|
+
window.electronTheiaCore.setMenuBarVisible(shouldShowTop);
|
|
421
410
|
} else if (shouldShowTop) {
|
|
422
411
|
this.shell.topPanel.show();
|
|
423
412
|
} else {
|
|
@@ -14,12 +14,10 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { Event as ElectronEvent, ipcRenderer } from '@theia/electron/shared/electron';
|
|
18
17
|
import { injectable, interfaces } from 'inversify';
|
|
19
18
|
import { JsonRpcProxy } from '../../common/messaging';
|
|
20
19
|
import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider';
|
|
21
|
-
import {
|
|
22
|
-
import { AbstractChannel, Channel, Disposable, WriteBuffer } from '../../common';
|
|
20
|
+
import { AbstractChannel, Channel, WriteBuffer } from '../../common';
|
|
23
21
|
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '../../common/message-rpc/uint8-array-message-buffer';
|
|
24
22
|
|
|
25
23
|
export interface ElectronIpcOptions {
|
|
@@ -50,16 +48,13 @@ export class ElectronIpcRendererChannel extends AbstractChannel {
|
|
|
50
48
|
|
|
51
49
|
constructor() {
|
|
52
50
|
super();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.toDispose.push(Disposable.create(() => ipcRenderer.removeListener(THEIA_ELECTRON_IPC_CHANNEL_NAME, ipcMessageHandler)));
|
|
51
|
+
this.toDispose.push(window.electronTheiaCore.onData(data => this.onMessageEmitter.fire(() => new Uint8ArrayReadBuffer(data))));
|
|
52
|
+
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
getWriteBuffer(): WriteBuffer {
|
|
59
56
|
const writer = new Uint8ArrayWriteBuffer();
|
|
60
|
-
writer.onCommit(buffer =>
|
|
61
|
-
ipcRenderer.send(THEIA_ELECTRON_IPC_CHANNEL_NAME, buffer)
|
|
62
|
-
);
|
|
57
|
+
writer.onCommit(buffer => window.electronTheiaCore.sendData(buffer));
|
|
63
58
|
return writer;
|
|
64
59
|
}
|
|
65
60
|
|