-
-
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.
Major refactor -- split windows into separate files
- Loading branch information
Showing
15 changed files
with
464 additions
and
358 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,53 @@ | ||
module.exports = { | ||
openSeedFile, | ||
openSeedDirectory, | ||
openTorrentFile, | ||
openTorrentAddress | ||
} | ||
|
||
var electron = require('electron') | ||
var windows = require('./windows') | ||
|
||
// Prompts the user for a file, then creates a torrent. Only allows a single file | ||
// selection. | ||
function openSeedFile () { | ||
electron.dialog.showOpenDialog({ | ||
title: 'Select a file for the torrent file.', | ||
properties: [ 'openFile' ] | ||
}, function (selectedPaths) { | ||
if (!Array.isArray(selectedPaths)) return | ||
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths) | ||
}) | ||
} | ||
|
||
// Prompts the user for a file or directory, then creates a torrent. Only allows a | ||
// single selection. To create a multi-file torrent, the user must select a | ||
// directory. | ||
function openSeedDirectory () { | ||
electron.dialog.showOpenDialog({ | ||
title: 'Select a file or folder for the torrent file.', | ||
properties: [ 'openFile', 'openDirectory' ] | ||
}, function (selectedPaths) { | ||
if (!Array.isArray(selectedPaths)) return | ||
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths) | ||
}) | ||
} | ||
|
||
// Prompts the user to choose a torrent file, then adds it. | ||
function openTorrentFile () { | ||
electron.dialog.showOpenDialog(windows.main.win, { | ||
title: 'Select a .torrent file to open.', | ||
filters: [{ name: 'Torrent Files', extensions: ['torrent'] }], | ||
properties: [ 'openFile', 'multiSelections' ] | ||
}, function (selectedPaths) { | ||
if (!Array.isArray(selectedPaths)) return | ||
selectedPaths.forEach(function (selectedPath) { | ||
windows.main.send('dispatch', 'addTorrent', selectedPath) | ||
}) | ||
}) | ||
} | ||
|
||
// Prompts the user for the URL of a torrent file, then downloads and adds it | ||
function openTorrentAddress () { | ||
windows.main.send('showOpenTorrentAddress') | ||
} |
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
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.