Skip to content

Commit 0f35553

Browse files
loads of updates
1 parent 16fbaab commit 0f35553

File tree

6 files changed

+139
-73
lines changed

6 files changed

+139
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Name=Trello
2525
Exec=/full/path/to/folder/Trello
2626
Terminal=false
2727
Type=Application
28-
Icon=/full/path/to/folder/Trello/resources/app/media/Icon.png
28+
Icon=/full/path/to/folder/Trello/resources/app/static/Icon.png
2929
```
3030

3131
### Windows

config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
const Config = require('electron-config');
3+
4+
module.exports = new Config({
5+
defaults: {
6+
zoomFactor: 1,
7+
lastWindowState: {
8+
width: 800,
9+
height: 600
10+
}
11+
}
12+
});

index.js

Lines changed: 113 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,139 @@
11
'use strict';
22
const path = require('path');
33
const fs = require('fs');
4-
const app = require('app');
5-
const BrowserWindow = require('browser-window');
6-
const Dialog = require('dialog');
7-
const shell = require('shell');
4+
const electron = require('electron');
5+
const config = require('./config')
6+
7+
const app = electron.app;
88

99
require('electron-debug')();
10-
require('crash-reporter').start();
10+
require('electron-dl')();
11+
require('electron-context-menu')();
1112

1213
let mainWindow;
14+
let isQuitting = false;
1315

1416
function updateBadge(title) {
15-
if (!app.dock) {
16-
return;
17-
}
17+
if (!app.dock) {
18+
return;
19+
}
1820

19-
if (title.indexOf('Messenger') === -1) {
20-
return;
21-
}
21+
if (title.indexOf('Messenger') === -1) {
22+
return;
23+
}
2224

23-
const messageCount = (/\(([0-9]+)\)/).exec(title);
24-
app.dock.setBadge(messageCount ? messageCount[1] : '');
25+
const messageCount = (/\(([0-9]+)\)/).exec(title);
26+
app.dock.setBadge(messageCount ? messageCount[1] : '');
2527
}
2628

2729
function createMainWindow() {
28-
const win = new BrowserWindow({
29-
'title': app.getName(),
30-
'show': false,
31-
'width': 800,
32-
'height': 600,
33-
'icon': process.platform === 'linux' && path.join(__dirname, 'media', 'Icon.png'),
34-
'min-width': 400,
35-
'min-height': 200,
36-
'title-bar-style': 'hidden-inset',
37-
'web-preferences': {
38-
// fails without this because of CommonJS script detection
39-
'node-integration': false,
40-
41-
'preload': path.join(__dirname, 'browser.js'),
42-
43-
// required for Facebook active ping thingy
44-
'web-security': false,
45-
46-
'plugins': true
30+
const lastWindowState = config.get('lastWindowState');
31+
const win = new electron.BrowserWindow({
32+
title: app.getName(),
33+
show: false,
34+
x: lastWindowState.x,
35+
y: lastWindowState.y,
36+
width: lastWindowState.width,
37+
height: lastWindowState.height,
38+
icon: process.platform === 'linux' && path.join(__dirname, 'static', 'Icon.png'),
39+
minWidth: 400,
40+
minHeight: 200,
41+
titleBarStyle: 'hidden-inset',
42+
autoHideMenuBar: true,
43+
webPreferences: {
44+
nodeIntegration: false,
45+
preload: path.join(__dirname, 'browser.js'),
46+
plugins: true
47+
}
48+
});
49+
50+
if (process.platform === 'darwin') {
51+
win.setSheetOffset(40);
52+
}
53+
54+
win.loadURL('https://trello.com/login');
55+
win.on('close', e => {
56+
if (!isQuitting) {
57+
e.preventDefault();
58+
59+
if (process.platform === 'darwin') {
60+
app.hide();
61+
} else {
62+
win.hide();
63+
}
4764
}
4865
});
66+
//win.on('page-title-updated', (e, title) => updateBadge(title));
4967

50-
win.loadUrl('https://trello.com/login');
51-
win.on('closed', app.quit);
52-
//win.on('page-title-updated', (e, title) => updateBadge(title));
53-
54-
return win;
68+
return win;
5569
}
5670

5771
app.on('ready', () => {
5872

59-
mainWindow = createMainWindow();
60-
61-
const page = mainWindow.webContents;
62-
63-
page.on('dom-ready', () => {
64-
page.insertCSS(fs.readFileSync(path.join(__dirname, 'browser.css'), 'utf8'));
65-
mainWindow.show();
66-
});
67-
68-
page.on('new-window', (e, url) => {
69-
e.preventDefault();
70-
shell.openExternal(url);
71-
});
73+
mainWindow = createMainWindow();
74+
75+
const page = mainWindow.webContents;
76+
77+
page.on('dom-ready', () => {
78+
page.insertCSS(fs.readFileSync(path.join(__dirname, 'browser.css'), 'utf8'));
79+
mainWindow.show();
80+
});
81+
82+
page.on('new-window', (e, url) => {
83+
e.preventDefault();
84+
shell.openExternal(url);
85+
});
86+
87+
mainWindow.webContents.session.on('will-download', (event, item) => {
88+
const totalBytes = item.getTotalBytes();
89+
90+
item.on('updated', () => {
91+
mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes);
92+
});
93+
94+
item.on('done', (e, state) => {
95+
mainWindow.setProgressBar(-1);
96+
97+
if (state === 'interrupted') {
98+
Dialog.showErrorBox('Download error', 'The download was interrupted');
99+
}
100+
});
101+
});
102+
103+
var template = [{
104+
label: "Application",
105+
submenu: [
106+
{ label: "About Application", selector: "orderFrontStandardAboutPanel:" },
107+
{ type: "separator" },
108+
{ label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }}
109+
]}, {
110+
label: "Edit",
111+
submenu: [
112+
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
113+
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
114+
{ type: "separator" },
115+
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
116+
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
117+
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
118+
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
119+
]}
120+
];
121+
122+
electron.Menu.setApplicationMenu(electron.Menu.buildFromTemplate(template));
123+
});
72124

73-
mainWindow.webContents.session.on('will-download', (event, item) => {
74-
const totalBytes = item.getTotalBytes();
125+
app.on("window-all-closed", function(){
126+
app.quit();
127+
});
75128

76-
item.on('updated', () => {
77-
mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes);
78-
});
129+
app.on('activate', () => {
130+
mainWindow.show();
131+
});
79132

80-
item.on('done', (e, state) => {
81-
mainWindow.setProgressBar(-1);
133+
app.on('before-quit', () => {
134+
isQuitting = true;
82135

83-
if (state === 'interrupted') {
84-
Dialog.showErrorBox('Download error', 'The download was interrupted');
85-
}
86-
});
87-
});
136+
if (!mainWindow.isFullScreen()) {
137+
config.set('lastWindowState', mainWindow.getBounds());
138+
}
88139
});

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "trello-desktop",
33
"productName": "Trello",
44
"desktopName": "Trello",
5-
"version": "0.0.1",
5+
"version": "0.1.0",
66
"description": "Unofficial Trello desktop app",
77
"license": "MIT",
88
"repository": "danielchatfield/trello-desktop",
@@ -18,28 +18,31 @@
1818
"scripts": {
1919
"test": "xo",
2020
"start": "electron .",
21-
"build": "npm run build-osx && npm run build-linux && npm run build-windows",
22-
"build-osx": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --ignore='^/media$' --prune --platform=darwin --arch=x64 --icon=media/Icon.icns --app-bundle-id=com.danielchatfield.trello-desktop --sign='Developer ID Application: Daniel Chatfield (BB2HNG5KBM)' --app-version=$npm_package_version --version=$npm_package_electronVersion && cd ./dist/Trello-darwin-x64 && zip -ryXq9 ../Trello-osx-${npm_package_version}.zip Trello.app",
23-
"build-linux": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --ignore='^/media/(?!Icon.png$).*' --prune --platform=linux --arch=x64 --app-bundle-id=com.danielchatfield.trello-desktop --app-version=$npm_package_version --version=$npm_package_electronVersion && cd ./dist/Trello-linux-x64/ && zip -ryq9 ../Trello-linux-\"$npm_package_version\".zip *",
24-
"build-windows": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --ignore='^/media/(?!Icon.ico$).*' --prune --platform=win32 --arch=ia32 --icon=media/Icon.ico --version=$npm_package_electronVersion --version-string.ProductName=$npm_package_productName --version-string.ProductVersion=$npm_package_electronVersion && cd ./dist/Trello-win32-ia32/ && zip -ryq9 ../Trello-windows-\"$npm_package_version\".zip *"
21+
"build": "npm run build:macos && npm run build:linux && npm run build:windows",
22+
"build:macos": "electron-packager . --overwrite --asar --out=dist --ignore='^media$' --prune --platform=darwin --arch=x64 --icon=static/Icon.icns --app-bundle-id=com.danielchatfield.trello-desktop --sign='Developer ID Application: Daniel Chatfield (BB2HNG5KBM)' --app-version=$npm_package_version && cd dist/Trello-darwin-x64 && zip -ryXq9 ../Trello-osx-${npm_package_version}.zip Trello.app",
23+
"build:linux": "electron-packager . --overwrite --out=dist --ignore='^media$' --prune --platform=linux --arch=x64 --app-bundle-id=com.danielchatfield.trello-desktop --app-version=$npm_package_version && cd dist/Trello-linux-x64/ && zip -ryq9 ../Trello-linux-${npm_package_version}.zip *",
24+
"build:windows": "electron-packager . --overwrite --asar --out=dist --ignore='^media$' --prune --platform=win32 --arch=ia32 --icon=static/Icon.ico --version-string.ProductName=$npm_package_productName --app-version=$npm_package_version && cd dist/Trello-win32-ia32 && zip -ryq9 ../Trello-windows-${npm_package_version}.zip *"
2525
},
2626
"files": [
2727
"index.js",
2828
"browser.js",
2929
"browser.css",
30-
"media/Icon.icns",
31-
"media/Icon.ico"
30+
"static/Icon.icns",
31+
"static/Icon.ico"
3232
],
3333
"keywords": [
3434
"electron-app",
3535
"trello"
3636
],
3737
"dependencies": {
38-
"electron-debug": "^0.2.1"
38+
"electron-config": "^0.1.1",
39+
"electron-context-menu": "^0.1.0",
40+
"electron-debug": "^1.0.0",
41+
"electron-dl": "^1.0.0"
3942
},
4043
"devDependencies": {
41-
"electron-packager": "^5.1.0",
42-
"electron-prebuilt": "^0.34.3",
44+
"electron-packager": "^7.0.4",
45+
"electron-prebuilt": "^1.2.3",
4346
"xo": "*"
4447
},
4548
"xo": {
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)