Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] refactor: use electron-menubar instead of menubar #563

Merged
merged 6 commits into from
Dec 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"dependencies": {
"electron-compile": "^6.4.2",
"electron-is-dev": "^0.3.0",
"electron-menubar": "^1.0.1",
"electron-squirrel-startup": "^1.0.0",
"file-extension": "^4.0.0",
"ipfs-geoip": "^2.3.0",
"ipfsd-ctl": "^0.26.0",
"menubar": "^5.2.3",
"moment": "^2.19.3",
"multiaddr": "^3.0.1",
"normalize.css": "^7.0.0",
Expand Down
19 changes: 10 additions & 9 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,20 @@ export default {
black: logo('black')
},
menubar: {
dir: __dirname,
width: 850,
height: 400,
backgroundColor: '#000000',
index: `file://${__dirname}/views/menubar.html`,
icon: logo('black'),
tooltip: 'Your IPFS instance',
preloadWindow: true,
resizable: false,
skipTaskbar: true,
webPreferences: {
nodeIntegration: true,
webSecurity: false
window: {
resizable: false,
skipTaskbar: true,
width: 850,
height: 400,
backgroundColor: '#000000',
webPreferences: {
nodeIntegration: true,
webSecurity: false
}
}
},
ipfsPath: ipfsPath,
Expand Down
1 change: 0 additions & 1 deletion src/controls/main/toggle-sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default function (opts) {
ipcMain.on('toggle-sticky', () => {
sticky = !sticky
menubar.window.setAlwaysOnTop(sticky)
menubar.setOption('alwaysOnTop', sticky)
send('sticky-window', sticky)
})
}
15 changes: 9 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import menubar from 'menubar'
import {Menubar} from 'electron-menubar'
import fs from 'fs'
import ipfsd from 'ipfsd-ctl'
import {join} from 'path'
Expand Down Expand Up @@ -133,7 +133,7 @@ function initialize (path, node) {
mb.window.webContents.on('did-finish-load', () => {
send('setup-config-path', path)
})
mb.showWindow()
mb.show()

// Close the application if the welcome dialog is canceled
mb.window.once('close', () => {
Expand Down Expand Up @@ -196,9 +196,7 @@ ipfsd.local((err, node) => {
process.exit(1)
}

mb = menubar(config.menubar)

mb.on('ready', () => {
let appReady = () => {
logger.info('Application is ready')
mb.tray.setHighlightMode(true)

Expand All @@ -224,5 +222,10 @@ ipfsd.local((err, node) => {
// Start up the daemon
onStartDaemon(node)
}
})
}

mb = new Menubar(config.menubar)

if (mb.isReady()) appReady()
else mb.on('ready', appReady)
})