From 38fddea3d4d60235565aa750bcb0c8a8d2c20bb2 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 7 Jan 2016 08:45:52 +0100 Subject: [PATCH] updates as discussed --- github-electron/github-electron-main-tests.ts | 25 ++++++++++--------- .../github-electron-renderer-tests.ts | 8 +++--- github-electron/github-electron.d.ts | 4 +-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 55588681fa..00f9b3ae19 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -31,7 +31,7 @@ require('crash-reporter').start(); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the javascript object is GCed. -var mainWindow: GitHubElectron.BrowserWindow = null; +var mainWindow: Electron.BrowserWindow = null; // Quit when all windows are closed. app.on('window-all-closed', () => { @@ -72,6 +72,7 @@ app.on('ready', () => { mainWindow.webContents.addWorkSpace('/path/to/workspace'); mainWindow.webContents.removeWorkSpace('/path/to/workspace'); var opened: boolean = mainWindow.webContents.isDevToolsOpened() + var focused = mainWindow.webContents.isDevToolsFocused(); // Emitted when the window is closed. mainWindow.on('closed', () => { // Dereference the window object, usually you would store windows @@ -116,21 +117,21 @@ app.on('ready', () => { app.addRecentDocument('/Users/USERNAME/Desktop/work.type'); app.clearRecentDocuments(); var dockMenu = Menu.buildFromTemplate([ - { + { label: 'New Window', click: () => { console.log('New Window'); } }, - { + { label: 'New Window with Settings', submenu: [ - { label: 'Basic' }, - { label: 'Pro' } + { label: 'Basic' }, + { label: 'Pro' } ] }, - { label: 'New Command...' }, - { + { label: 'New Command...' }, + { label: 'Edit', submenu: [ { @@ -167,7 +168,7 @@ var dockMenu = Menu.buildFromTemplate([ app.dock.setMenu(dockMenu); app.setUserTasks([ - { + { program: process.execPath, arguments: '--new-window', iconPath: process.execPath, @@ -186,7 +187,7 @@ window.setDocumentEdited(true); // Online/Offline Event Detection // https://github.com/atom/electron/blob/master/docs/tutorial/online-offline-events.md -var onlineStatusWindow: GitHubElectron.BrowserWindow; +var onlineStatusWindow: Electron.BrowserWindow; app.on('ready', () => { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); @@ -275,12 +276,12 @@ globalShortcut.unregisterAll(); // ipcMain // https://github.com/atom/electron/blob/master/docs/api/ipc-main-process.md -ipcMain.on('asynchronous-message', (event: GitHubElectron.IPCMainEvent, arg: any) => { +ipcMain.on('asynchronous-message', (event: Electron.IPCMainEvent, arg: any) => { console.log(arg); // prints "ping" event.sender.send('asynchronous-reply', 'pong'); }); -ipcMain.on('synchronous-message', (event: GitHubElectron.IPCMainEvent, arg: any) => { +ipcMain.on('synchronous-message', (event: Electron.IPCMainEvent, arg: any) => { console.log(arg); // prints "ping" event.returnValue = 'pong'; }); @@ -460,7 +461,7 @@ app.on('ready', () => { // tray // https://github.com/atom/electron/blob/master/docs/api/tray.md -var appIcon: GitHubElectron.Tray = null; +var appIcon: Electron.Tray = null; app.on('ready', () => { appIcon = new Tray('/path/to/my/icon'); var contextMenu = Menu.buildFromTemplate([ diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index cf610718ce..7ddd585a72 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -24,7 +24,7 @@ ipcRenderer.send('asynchronous-message', 'ping'); // remote // https://github.com/atom/electron/blob/master/docs/api/remote.md -var BrowserWindow: typeof GitHubElectron.BrowserWindow = remote.require('browser-window'); +var BrowserWindow: typeof Electron.BrowserWindow = remote.require('browser-window'); var win = new BrowserWindow({ width: 800, height: 600 }); win.loadURL('https://github.com'); @@ -75,7 +75,7 @@ crashReporter.start({ // nativeImage // https://github.com/atom/electron/blob/master/docs/api/native-image.md -var Tray: typeof GitHubElectron.Tray = remote.require('Tray'); +var Tray: typeof Electron.Tray = remote.require('Tray'); var appIcon2 = new Tray('/Users/somebody/images/icon.png'); var window2 = new BrowserWindow({ icon: '/Users/somebody/images/window.png' }); var image = clipboard.readImage(); @@ -85,9 +85,9 @@ var appIcon4 = new Tray('/Users/somebody/images/icon.png'); // screen // https://github.com/atom/electron/blob/master/docs/api/screen.md -var app: GitHubElectron.App = remote.require('app'); +var app: Electron.App = remote.require('app'); -var mainWindow: GitHubElectron.BrowserWindow = null; +var mainWindow: Electron.BrowserWindow = null; app.on('ready', () => { var size = screen.getPrimaryDisplay().workAreaSize; diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index df04e62711..29244bf93b 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -914,7 +914,7 @@ declare module Electron { * Should be specified for submenu type menu item, when it's specified the * type: 'submenu' can be omitted for the menu item */ - submenu?: Menu; + submenu?: Menu|MenuItemOptions[]; /** * Unique within a single menu. If defined then it can be used as a reference * to this item by the position attribute. @@ -1879,4 +1879,4 @@ declare module 'electron' { interface NodeRequireFunction { (moduleName: 'electron'): Electron.ElectronMainAndRenderer; -} \ No newline at end of file +}