diff --git a/app/launcher/index.html b/app/launcher/index.html
index ef044391..c2319910 100644
--- a/app/launcher/index.html
+++ b/app/launcher/index.html
@@ -10,7 +10,8 @@
-
+
+
diff --git a/src/launcher/toolbar.js b/src/launcher/toolbar.js
index 6edc04ac..7f07b45c 100644
--- a/src/launcher/toolbar.js
+++ b/src/launcher/toolbar.js
@@ -3,20 +3,24 @@ var {remote, ipcRenderer} = eval('require(\'electron\')'),
menu = new Menu(),
terminal = require('./terminal'),
settings = require('./settings'),
- midilist = remote.getGlobal('midilist')
-
+ midilist = remote.getGlobal('midilist'),
+ serverStarted = false,
+ serverStart = ()=>{
+ if (serverStarted) return
+ ipcRenderer.send('start')
+ },
+ serverStop = ()=>{
+ if (!serverStarted) return
+ ipcRenderer.send('stop')
+ }
var start = new MenuItem({
label: 'Start',
- click: ()=>{
- ipcRenderer.send('start')
- }
+ click: serverStart
})
var stop = new MenuItem({
label: 'Stop',
- click: ()=>{
- ipcRenderer.send('stop')
- }
+ click: serverStop
})
var newWindow = new MenuItem({
label: 'New window',
@@ -100,15 +104,14 @@ class Toolbar {
constructor() {
- this.container = DOM.get('osc-toolbar')[0]
-
+ this.container = DOM.get('osc-toolbar#menu')[0]
+ this.startButton = DOM.get('osc-toolbar#start')[0]
this.container.addEventListener('click', (e)=>{
this.container.classList.add('on')
- var serverProcess = remote.getGlobal('serverProcess')
- start.visible = !serverProcess
- stop.visible = !!serverProcess
- newWindow.visible = !!serverProcess
+ start.visible = !serverStarted
+ stop.visible = !!serverStarted
+ newWindow.visible = !!serverStarted
menu.popup({window: remote.getCurrentWindow(), x: parseInt(PXSCALE), y: parseInt(40 * PXSCALE)})
})
@@ -116,6 +119,20 @@ class Toolbar {
this.container.classList.remove('on')
})
+ this.startButton.addEventListener('click', (e)=>{
+ if (!serverStarted) serverStart()
+ else serverStop()
+ })
+
+ ipcRenderer.on('server-started', ()=>{
+ serverStarted = true
+ this.startButton.classList.add('started')
+ })
+ ipcRenderer.on('server-stopped', ()=>{
+ serverStarted = false
+ this.startButton.classList.remove('started')
+ })
+
}
}
diff --git a/src/scss/ui/toolbar.scss b/src/scss/ui/toolbar.scss
index ffd2a01a..0f377caa 100644
--- a/src/scss/ui/toolbar.scss
+++ b/src/scss/ui/toolbar.scss
@@ -24,3 +24,16 @@ osc-toolbar {
}
}
}
+
+osc-toolbar#start {
+
+ left: var(--size);
+ &:after {
+ content: "\f04b"
+ }
+ &.started:after {
+ content: "\f04d";
+ color: var(--color-widget);
+ }
+
+}