Skip to content

Commit

Permalink
Basic Support for MacBookPro TouchBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Wisotzky committed Oct 22, 2018
1 parent 2f3c42f commit 96db8d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -58,3 +58,6 @@ Enhanced Features (beta):

### 2.3 - Updates (2018 October 17th)
* introducing environment / templating

### 3.0 - Updates (2018 October 22nd)
* basic support for MacBookPro TouchBar
26 changes: 26 additions & 0 deletions lib/toolbar-netconf.coffee
Expand Up @@ -10,6 +10,9 @@
###

{CompositeDisposable, TextEditor} = require 'atom'
{TouchBar, nativeImage} = require'remote'
{TouchBarButton, TouchBarColorPicker, TouchBarGroup, TouchBarLabel, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer} = TouchBar

ncclient = require './ncclient'
Status = require './statusbar-netconf'
xmltools = require './xmltools'
Expand Down Expand Up @@ -118,6 +121,15 @@ class NetconfToolbar extends HTMLElement
@addEventListener 'mouseout', =>@icons.classList.add('hidden')
@addEventListener 'mouseout', =>@select_server.classList.add('hidden')

# --- create MacBookPro touchbar items ------------------------------------
logo = nativeImage.createFromPath(path.join(__dirname, '../logo-tiny.png')).resize({ height: 16 })
@tbLabel = new TouchBarLabel {label: "atom-netconf"}
@tbConnect = new TouchBarButton {label: "connect", click: @do_connect.bind(this), backgroundColor: [-1, 0, 1]}
@tbDisconnect = new TouchBarButton {label: "disconnect", click: @do_disconnect.bind(this), backgroundColor: [-1, 0, 1]}
@tbRPC = new TouchBarButton {label: "RPC", click: @do_rpc_call.bind(this), backgroundColor: [-1, 0, 1]}
@tbLogo = new TouchBarButton {icon: logo, iconPosition: 'overlay', backgroundColor: "#000000"}
@updateTB()


register: (object) =>
console.debug '::register()' if @debugging
Expand All @@ -143,11 +155,13 @@ class NetconfToolbar extends HTMLElement
@icon_idle.classList.remove('hidden')
@icon_connected.classList.add('hidden')
@select_server.removeAttribute('disabled');
@updateTB()

@client.on 'connected', callback = (hello) =>
@icon_idle.classList.add('hidden')
@icon_connected.classList.remove('hidden')
@select_server.setAttribute('disabled', '');
@updateTB()

destroy: =>
console.debug '::destroy()' if @debugging
Expand Down Expand Up @@ -198,6 +212,7 @@ class NetconfToolbar extends HTMLElement
@icon_idle.classList.remove('hidden')
@icon_connected.classList.add('hidden')
@select_server.removeAttribute('disabled');
@updateTB()
else
@status.warning('Already disconnected!')

Expand Down Expand Up @@ -295,6 +310,17 @@ class NetconfToolbar extends HTMLElement
else
@link_netconf_rpc.classList.remove('active')

updateTB: =>
@touchbar = []
@touchbar.push @tbLabel
if @client?.isConnected()
@touchbar.push @tbDisconnect
@touchbar.push @tbRPC
else
@touchbar.push @tbConnect
@touchbar.push @tbLogo
atom.getCurrentWindow().setTouchBar(@touchbar)

module.exports = document.registerElement('toolbar-netconf', prototype: NetconfToolbar.prototype, extends: 'div')

# EOF

0 comments on commit 96db8d3

Please sign in to comment.