git ssb

10+

Matt McKegg / patchwork



Tree: 32d251a78db95ceb448ed94743c944b8be3de181

Files: 32d251a78db95ceb448ed94743c944b8be3de181 / index.js

2155 bytesRaw
1process.on('uncaughtException', function (err) {
2 console.log(err)
3 process.exit()
4})
5
6var electron = require('electron')
7var openWindow = require('./lib/window')
8
9var Path = require('path')
10var defaultMenu = require('electron-default-menu')
11var Menu = electron.Menu
12var extend = require('xtend')
13var ssbKeys = require('ssb-keys')
14
15var windows = {
16 dialogs: new Set()
17}
18
19var ssbConfig = require('./config')
20
21electron.app.on('ready', () => {
22 setupContext(() => {
23 Menu.setApplicationMenu(Menu.buildFromTemplate(defaultMenu(electron.app, electron.shell)))
24 openMainWindow()
25 })
26
27 electron.app.on('activate', function (e) {
28 openMainWindow()
29 })
30
31 electron.ipcMain.on('open-background-devtools', function (ev, config) {
32 if (windows.background) {
33 windows.background.webContents.openDevTools({detach: true})
34 }
35 })
36})
37
38function openMainWindow () {
39 if (!windows.main) {
40 windows.main = openWindow(ssbConfig, Path.join(__dirname, 'main-window.js'), {
41 minWidth: 800,
42 width: 1024,
43 height: 768,
44 titleBarStyle: 'hidden-inset',
45 title: 'Patchwork',
46 show: true,
47 backgroundColor: '#EEE',
48 webPreferences: {
49 experimentalFeatures: true
50 },
51 icon: './ferment-logo.png'
52 })
53 windows.main.setSheetOffset(40)
54 windows.main.on('closed', function () {
55 windows.main = null
56 if (process.platform != 'darwin') electron.app.quit()
57 })
58 }
59}
60
61function setupContext (cb) {
62 if (ssbConfig.server === false) {
63 cb && cb()
64 } else {
65 electron.ipcMain.once('server-started', function (ev) {
66 cb && cb()
67 })
68 windows.background = openWindow(ssbConfig, Path.join(__dirname, 'server-process.js'), {
69 connect: false,
70 center: true,
71 fullscreen: false,
72 fullscreenable: false,
73 height: 150,
74 maximizable: false,
75 minimizable: false,
76 resizable: false,
77 show: false,
78 skipTaskbar: true,
79 title: 'patchwork-server',
80 useContentSize: true,
81 width: 150
82 })
83 // windows.background.on('close', (ev) => {
84 // ev.preventDefault()
85 // windows.background.hide()
86 // })
87 }
88}
89

Built with git-ssb-web