From 6589e134b3e672379ae6e91496a1606b1da96714 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 13 May 2016 12:23:59 -0700 Subject: [PATCH 1/2] code style --- main/ipc.js | 4 +++- main/menu.js | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main/ipc.js b/main/ipc.js index e7410e7c..b2d0295a 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -216,7 +216,9 @@ function setAspectRatio (aspectRatio) { // Display string in dock badging area (OS X) function setBadge (text) { log('setBadge %s', text) - if (app.dock) app.dock.setBadge(String(text)) + if (app.dock) { + app.dock.setBadge(String(text)) + } } // Show progress bar. Valid range is [0, 1]. Remove when < 0; indeterminate when > 1. diff --git a/main/menu.js b/main/menu.js index c537ebc6..8b7163a5 100644 --- a/main/menu.js +++ b/main/menu.js @@ -21,14 +21,16 @@ var config = require('../config') var log = require('./log') var windows = require('./windows') -var appMenu, dockMenu +var appMenu function init () { appMenu = electron.Menu.buildFromTemplate(getAppMenuTemplate()) electron.Menu.setApplicationMenu(appMenu) - dockMenu = electron.Menu.buildFromTemplate(getDockMenuTemplate()) - if (app.dock) app.dock.setMenu(dockMenu) + if (app.dock) { + var dockMenu = electron.Menu.buildFromTemplate(getDockMenuTemplate()) + app.dock.setMenu(dockMenu) + } } function toggleFullScreen (flag) { From 290a25c3937c6135443a19db69cb45d6a321a515 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 13 May 2016 12:25:03 -0700 Subject: [PATCH 2/2] OS X: Bounce the Downloads stack when download completes (If the download is inside the Downloads folder.) --- main/ipc.js | 7 +++++++ renderer/index.js | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main/ipc.js b/main/ipc.js index b2d0295a..493fb4b4 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -93,6 +93,13 @@ function init () { windows.focusWindow(windows[windowName]) }) + ipcMain.on('downloadFinished', function (e, filePath) { + if (app.dock) { + // Bounces the Downloads stack if the filePath is inside the Downloads folder. + app.dock.downloadFinished(filePath) + } + }) + ipcMain.on('checkForVLC', function (e) { vlc.checkForVLC(function (isInstalled) { windows.main.send('checkForVLC', isInstalled) diff --git a/renderer/index.js b/renderer/index.js index c0f0d18e..90ee2877 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -773,6 +773,7 @@ function torrentDone (torrentKey, torrentInfo) { state.dock.badge += 1 } showDoneNotification(torrentSummary) + ipcRenderer.send('downloadFinished', getTorrentPath(torrentSummary)) } update() @@ -1018,12 +1019,16 @@ function openTorrentContextMenu (infoHash) { menu.popup(electron.remote.getCurrentWindow()) } -function showItemInFolder (torrentSummary) { +function getTorrentPath (torrentSummary) { var itemPath = path.join(torrentSummary.path, torrentSummary.files[0].path) if (torrentSummary.files.length > 1) { itemPath = path.dirname(itemPath) } - ipcRenderer.send('showItemInFolder', itemPath) + return itemPath +} + +function showItemInFolder (torrentSummary) { + ipcRenderer.send('showItemInFolder', getTorrentPath(torrentSummary)) } function saveTorrentFileAs (torrentSummary) {