Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Add new window option #1111

Merged
merged 3 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from "path"
import { app, BrowserWindow, ipcMain, Menu, webContents } from "electron"

import * as Log from "./Log"
import { buildMenu } from "./menu"
import { buildDockMenu, buildMenu } from "./menu"
import { makeSingleInstance } from "./ProcessLifecycle"

global["getLogs"] = Log.getAllLogs // tslint:disable-line no-string-literal
Expand Down Expand Up @@ -57,7 +57,7 @@ if (!isDevelopment && !isDebug) {
})
}

function createWindow(commandLineArguments, workingDirectory) {
export function createWindow(commandLineArguments, workingDirectory) {
Log.info(`Creating window with arguments: ${commandLineArguments} and working directory: ${workingDirectory}`)

const webPreferences = {
Expand Down Expand Up @@ -130,6 +130,8 @@ function updateMenu(mainWindow, loadInit) {
if (process.platform === "darwin") {
// all osx windows share the same menu
Menu.setApplicationMenu(menu)
const dockMenu = buildDockMenu(mainWindow, loadInit)
app.dock.setMenu(dockMenu)
} else {
// on windows and linux, set menu per window
mainWindow.setMenu(menu)
Expand Down
22 changes: 22 additions & 0 deletions main/src/menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import * as os from "os"

import { app, dialog, Menu, shell } from "electron"
import { createWindow } from "./main"

export const buildDockMenu = (mainWindow, loadInit) => {
const menu = []
menu.push({
label: "New Window",
click() {
createWindow([], process.cwd())
},
})

return Menu.buildFromTemplate(menu)
}

export const buildMenu = (mainWindow, loadInit) => {
const menu = []
Expand Down Expand Up @@ -98,6 +111,15 @@ export const buildMenu = (mainWindow, loadInit) => {
{
type: "separator",
},
{
label: "New Window",
click() {
createWindow([], process.cwd())
},
},
{
type: "separator",
},
{
label: "Save",
click(item, focusedWindow) {
Expand Down