-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move unrelated code out of menu.js and ipc.js
- Loading branch information
Showing
16 changed files
with
460 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module.exports = { | ||
downloadFinished, | ||
init, | ||
setBadge | ||
} | ||
|
||
var electron = require('electron') | ||
|
||
var app = electron.app | ||
|
||
var dialog = require('./dialog') | ||
var log = require('./log') | ||
|
||
/** | ||
* Add a right-click menu to the dock icon. (OS X) | ||
*/ | ||
function init () { | ||
if (!app.dock) return | ||
var menu = electron.Menu.buildFromTemplate(getMenuTemplate()) | ||
app.dock.setMenu(menu) | ||
} | ||
|
||
/** | ||
* Bounce the Downloads stack if `path` is inside the Downloads folder. (OS X) | ||
*/ | ||
function downloadFinished (path) { | ||
if (!app.dock) return | ||
log(`downloadFinished: ${path}`) | ||
app.dock.downloadFinished(path) | ||
} | ||
|
||
/** | ||
* Display string in dock badging area. (OS X) | ||
*/ | ||
function setBadge (text) { | ||
if (!app.dock) return | ||
log(`setBadge: ${text}`) | ||
app.dock.setBadge(String(text)) | ||
} | ||
|
||
function getMenuTemplate () { | ||
return [ | ||
{ | ||
label: 'Create New Torrent...', | ||
accelerator: 'CmdOrCtrl+N', | ||
click: () => dialog.openSeedDirectory() | ||
}, | ||
{ | ||
label: 'Open Torrent File...', | ||
accelerator: 'CmdOrCtrl+O', | ||
click: () => dialog.openTorrentFile() | ||
}, | ||
{ | ||
label: 'Open Torrent Address...', | ||
accelerator: 'CmdOrCtrl+U', | ||
click: () => dialog.openTorrentAddress() | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.