started adding copay shell to copay
This commit is contained in:
parent
45ffa94bbe
commit
e7c5addfab
19 changed files with 781 additions and 3 deletions
143
shell/lib/app-menu.js
Normal file
143
shell/lib/app-menu.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
** copay-shell - native app menu
|
||||
*/
|
||||
|
||||
module.exports = function(app, web) {
|
||||
|
||||
var Menu = require('menu');
|
||||
var menu = []
|
||||
|
||||
// add the mac osx app menu entry
|
||||
if (process.platform === 'darwin') {
|
||||
menu.push({
|
||||
label: 'Copay',
|
||||
submenu: [
|
||||
{
|
||||
label: 'About Copay',
|
||||
selector: 'orderFrontStandardAboutPanel:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Hide Copay',
|
||||
accelerator: 'Command+H',
|
||||
selector: 'hide:'
|
||||
},
|
||||
{
|
||||
label: 'Hide Others',
|
||||
accelerator: 'Command+Shift+H',
|
||||
selector: 'hideOtherApplications:'
|
||||
},
|
||||
{
|
||||
label: 'Show All',
|
||||
selector: 'unhideAllApplications:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'Command+Q',
|
||||
click: function() {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
menu.push({
|
||||
label: 'Addresses',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Create New',
|
||||
click: function() {
|
||||
web.send('address:create');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
menu.push({
|
||||
label: 'Transactions',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Send Money',
|
||||
click: function() {
|
||||
web.send('transactions:send');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Pending',
|
||||
click: function() {
|
||||
web.send('transactions:pending');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'All',
|
||||
click: function() {
|
||||
web.send('transactions:all');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
menu.push({
|
||||
label: 'Backup',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Download File',
|
||||
click: function() {
|
||||
web.send('backup:download');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Backup to Email',
|
||||
click: function() {
|
||||
web.send('backup:email');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Import a Backup',
|
||||
click: function() {
|
||||
web.send('backup:import');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
menu.push({
|
||||
label: 'Window',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Minimize',
|
||||
accelerator: 'Command+M',
|
||||
selector: 'performMiniaturize:'
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'Command+W',
|
||||
selector: 'performClose:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Bring All to Front',
|
||||
selector: 'arrangeInFront:'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
return Menu.buildFromTemplate(menu);
|
||||
|
||||
};
|
||||
81
shell/lib/message-handler.js
Normal file
81
shell/lib/message-handler.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
** copay-shell - message handler
|
||||
*/
|
||||
|
||||
var ipc = require('ipc');
|
||||
var dialog = require('dialog');
|
||||
var config = require('../config');
|
||||
var windows = (process.platform === 'win32');
|
||||
var HOME = process.env[windows ? 'USERPROFILE' : 'HOME'];
|
||||
var fs = require('fs');
|
||||
var shell = require('shell');
|
||||
|
||||
module.exports = function(renderer) {
|
||||
|
||||
// handle alerts sent from renderer (browser window)
|
||||
ipc.on('alert', function(e, type, message) {
|
||||
dialog.showMessageBox(renderer, {
|
||||
type: type || 'info',
|
||||
buttons: ['Okay'],
|
||||
title: 'Copay',
|
||||
message: message
|
||||
});
|
||||
});
|
||||
|
||||
// handle saving a wallet backup
|
||||
ipc.on('backup:download', function(e, data) {
|
||||
var backup = new Buffer(data.wallet);
|
||||
var filename = data.name + '-' + (+(new Date)) + '.json.aes';
|
||||
// open save dialog
|
||||
dialog.showSaveDialog(renderer, {
|
||||
title: 'Backup Wallet',
|
||||
defaultPath: HOME + '/' + filename
|
||||
}, function(path) {
|
||||
if (!path) return;
|
||||
fs.writeFile(path, backup, function(err) {
|
||||
dialog.showMessageBox(renderer, {
|
||||
type: err ? 'warning' : 'info',
|
||||
buttons: ['Okay'],
|
||||
title: 'Copay',
|
||||
message: err ? err.message : 'Wallet backup saved!'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// handle emailing a wallet backup
|
||||
ipc.on('backup:email', function(e, href) {
|
||||
// open email client
|
||||
shell.openExternal(href)
|
||||
});
|
||||
|
||||
// handle importing a wallet backup
|
||||
ipc.on('backup:import', function(e, data) {
|
||||
|
||||
// open file dialog
|
||||
dialog.showOpenDialog(renderer, {
|
||||
title: 'Import Wallet Backup',
|
||||
defaultPath: HOME,
|
||||
properties: ['openFile']
|
||||
}, function(path) {
|
||||
if (!path) return;
|
||||
fs.readFile(path[0], function(err, contents) {
|
||||
if (err) {
|
||||
return dialog.showMessageBox(renderer, {
|
||||
type: 'warning',
|
||||
buttons: ['Okay'],
|
||||
title: 'Copay',
|
||||
message: err.message
|
||||
});
|
||||
}
|
||||
renderer.send('backup:import:data', contents.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// if we get an error, let's pop open the console for the user
|
||||
ipc.on('error', function() {
|
||||
if (config.debug) renderer.toggleDevTools();
|
||||
});
|
||||
|
||||
};
|
||||
16
shell/lib/system-tray.js
Normal file
16
shell/lib/system-tray.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
** copay-shell - system tray integration
|
||||
*/
|
||||
|
||||
var Menu = require('menu');
|
||||
var Tray = require('tray');
|
||||
var tray = new Tray('../assets/copay.icns');
|
||||
|
||||
module.exports = function(app, web) {
|
||||
|
||||
var menu = Menu.buildFromTemplate([]);
|
||||
|
||||
tray.setToolTip('Copay');
|
||||
tray.setContextMenu(menu);
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue