Skip to content

Commit 8c34799

Browse files
committed
Added some basic menus for on OS X.
1 parent 4b8de7d commit 8c34799

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function main(): void {
8181
app.commandLine.appendSwitch('disable-smooth-scrolling'); // Turn off the sluggish scrolling.
8282

8383
if (process.platform === "darwin") {
84-
setupOSXDefaults();
84+
setupOSX();
8585
}
8686

8787
_log.startRecording();
@@ -476,7 +476,7 @@ function systemConfiguration(config: Config): SystemConfig {
476476
return { homeDir: homeDir, keyBindingsContexts: keyBindingsJSON, keyBindingsFiles: keyBindingFiles };
477477
}
478478

479-
function setupOSXDefaults() {
479+
function setupOSX(): void {
480480
child_process.execFileSync("defaults", ["write",
481481
"com.electron.extraterm", "ApplePressAndHoldEnabled", "-bool", "false"]);
482482
}

src/mainweb.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
*
44
* This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
55
*/
6+
import electron = require('electron');
7+
const Menu = electron.remote.Menu;
8+
const MenuItem = electron.remote.MenuItem;
9+
610
import sourceMapSupport = require('source-map-support');
711
import _ = require('lodash');
812
import Logger = require('./logger');
@@ -58,6 +62,9 @@ let mainWebUi: MainWebUi = null;
5862
*
5963
*/
6064
export function startUp(): void {
65+
if (process.platform === "darwin") {
66+
setupOSXEmptyMenus();
67+
}
6168

6269
// Theme control for the window level.
6370
const topThemeable: ThemeTypes.Themeable = {
@@ -137,6 +144,10 @@ export function startUp(): void {
137144
mainWebUi.focus();
138145
});
139146

147+
if (process.platform === "darwin") {
148+
setupOSXMenus(mainWebUi);
149+
}
150+
140151
// Detect when the last tab has closed.
141152
mainWebUi.addEventListener(MainWebUi.EVENT_TAB_CLOSED, (ev: CustomEvent) => {
142153
if (mainWebUi.tabCount === 0) {
@@ -201,6 +212,58 @@ export function startUp(): void {
201212
});
202213
}
203214

215+
function setupOSXEmptyMenus(): void {
216+
const template: GitHubElectron.MenuItemOptions[] = [{
217+
label: "Extraterm",
218+
}];
219+
220+
const emptyTopMenu = Menu.buildFromTemplate(template);
221+
Menu.setApplicationMenu(emptyTopMenu);
222+
}
223+
224+
function setupOSXMenus(mainWebUi: MainWebUi): void {
225+
const template: GitHubElectron.MenuItemOptions[] = [{
226+
label: "Extraterm",
227+
submenu: [
228+
{
229+
label: 'About Extraterm',
230+
click(item, focusedWindow) {
231+
mainWebUi.openAboutTab();
232+
},
233+
},
234+
{
235+
type: 'separator'
236+
},
237+
{
238+
label: 'Preferences...',
239+
click(item, focusedWindow) {
240+
mainWebUi.openSettingsTab();
241+
},
242+
},
243+
{
244+
label: 'Key Bindings...',
245+
click(item, focusedWindow) {
246+
mainWebUi.openKeyBindingsTab();
247+
},
248+
},
249+
{
250+
type: 'separator'
251+
},
252+
{
253+
label: 'Quit',
254+
click(item, focusedWindow) {
255+
webipc.windowCloseRequest();
256+
},
257+
accelerator: 'Command+Q'
258+
}
259+
]
260+
}];
261+
262+
const topMenu = Menu.buildFromTemplate(template);
263+
264+
Menu.setApplicationMenu(topMenu);
265+
}
266+
204267
function handleConfigMessage(msg: Messages.Message): Promise<void> {
205268
const configMessage = <Messages.ConfigMessage> msg;
206269
const oldConfiguration = configuration;

0 commit comments

Comments
 (0)