Commit 747bb2d95395b5f07ec8780551fd62881c5618af
Merge pull request #132 from ssbc/save-window-settings
Save window settingsmix irving authored on 9/4/2017, 9:39:08 PM
GitHub committed on 9/4/2017, 9:39:08 PM
Parent: 2a1d0d14f4337a529079e2dd3756a304c27d7edb
Parent: 41c069304b2bd78a228c769290dcaf99d6b470c2
Files changed
app/html/app.js | changed |
main.js | changed |
package-lock.json | changed |
package.json | changed |
app/html/app.js | |||
---|---|---|---|
@@ -1,7 +1,8 @@ | |||
1 | 1 … | const nest = require('depnest') | |
2 | 2 … | const { h } = require('mutant') | |
3 | 3 … | const insertCss = require('insert-css') | |
4 … | +const electron = require('electron') | ||
4 | 5 … | ||
5 | 6 … | exports.gives = nest('app.html.app') | |
6 | 7 … | ||
7 | 8 … | exports.needs = nest({ | |
@@ -13,9 +14,11 @@ | |||
13 | 14 … | 'app.sync.addPage': 'first', | |
14 | 15 … | 'app.sync.catchKeyboardShortcut': 'first', | |
15 | 16 … | 'router.sync.router': 'first', | |
16 | 17 … | 'router.sync.normalise': 'first', | |
17 | - 'styles.css': 'reduce' | ||
18 … | + 'styles.css': 'reduce', | ||
19 … | + 'settings.sync.get': 'first', | ||
20 … | + 'settings.sync.set': 'first' | ||
18 | 21 … | }) | |
19 | 22 … | ||
20 | 23 … | exports.create = function (api) { | |
21 | 24 … | return nest('app.html.app', app) | |
@@ -55,8 +58,31 @@ | |||
55 | 58 … | ||
56 | 59 … | addError(ev.error || ev) | |
57 | 60 … | }) | |
58 | 61 … | ||
62 … | + ////// TODO - extract this to keep patch-lite isolated from electron | ||
63 … | + const { getCurrentWebContents, getCurrentWindow } = electron.remote | ||
64 … | + window.addEventListener('resize', () => { | ||
65 … | + var wc = getCurrentWebContents() | ||
66 … | + wc && wc.getZoomFactor((zf) => { | ||
67 … | + api.settings.sync.set({ | ||
68 … | + electron: { | ||
69 … | + zoomFactor: zf, | ||
70 … | + windowBounds: getCurrentWindow().getBounds() | ||
71 … | + } | ||
72 … | + }) | ||
73 … | + }) | ||
74 … | + }) | ||
75 … | + | ||
76 … | + var zoomFactor = api.settings.sync.get('electron.zoomFactor') | ||
77 … | + if (zoomFactor) | ||
78 … | + getCurrentWebContents().setZoomFactor(zoomFactor) | ||
79 … | + | ||
80 … | + var bounds = api.settings.sync.get('electron.windowBounds') | ||
81 … | + if (bounds) | ||
82 … | + getCurrentWindow().setBounds(bounds) | ||
83 … | + ////// | ||
84 … | + | ||
59 | 85 … | return App | |
60 | 86 … | } | |
61 | 87 … | } | |
62 | 88 … |
main.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 … | const bayGatherings = require('patchbay-gatherings') |
10 | 10 … | const patchbay = require('./') |
11 | 11 … | const patchContext = require('patch-context') |
12 | 12 … | const patchcore = require('patchcore') |
13 … | +const patchSettings = require('patch-settings') | |
13 | 14 … | |
14 | 15 … | // polyfills |
15 | 16 … | require('setimmediate') |
16 | 17 … | |
@@ -22,8 +23,9 @@ | ||
22 | 23 … | // gatherings, |
23 | 24 … | // bayGatherings, // TODO collect gatherings into this |
24 | 25 … | patchbay, |
25 | 26 … | patchContext, |
27 … | + patchSettings, | |
26 | 28 … | patchcore |
27 | 29 … | ) |
28 | 30 … | |
29 | 31 … | const api = entry(sockets, nest('app.html.app', 'first')) |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 252990 bytes New file size: 253788 bytes |
package.json | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 … | "scripts": { |
7 | 7 … | "lint": "standard", |
8 | 8 … | "setup": "npm install electron electro -g", |
9 | 9 … | "rebuild": "npm rebuild --runtime=electron --target=$(electron -v) --abi=$(electron --abi) --disturl=https://atom.io/download/atom-shell", |
10 | - "start": "electro main.js" | |
10 … | + "start": "electro main.js -- --title patchbay" | |
11 | 11 … | }, |
12 | 12 … | "browserify": { |
13 | 13 … | "transform": [ |
14 | 14 … | "bulkify", |
@@ -55,8 +55,9 @@ | ||
55 | 55 … | "patch-gatherings": "^2.4.3", |
56 | 56 … | "patch-hub": "^1.1.0", |
57 | 57 … | "patchbay-gatherings": "^1.1.2", |
58 | 58 … | "patchcore": "^1.10.3", |
59 … | + "patch-settings": "^1.0.0", | |
59 | 60 … | "pull-abortable": "^4.1.1", |
60 | 61 … | "pull-cat": "^1.1.11", |
61 | 62 … | "pull-next": "1.0.0", |
62 | 63 … | "pull-scroll": "^1.0.7", |
Built with git-ssb-web