Skip to content

Commit

Permalink
Merge pull request #2327 from mikaoelitiana/fix-1155
Browse files Browse the repository at this point in the history
Add osx touchbar support
  • Loading branch information
Rokt33r authored Sep 15, 2018
2 parents f3c72e5 + a19c13e commit 933f75f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
12 changes: 12 additions & 0 deletions browser/main/NoteList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class NoteList extends React.Component {
this.getViewType = this.getViewType.bind(this)
this.restoreNote = this.restoreNote.bind(this)
this.copyNoteLink = this.copyNoteLink.bind(this)
this.navigate = this.navigate.bind(this)

// TODO: not Selected noteKeys but SelectedNote(for reusing)
this.state = {
Expand All @@ -98,6 +99,7 @@ class NoteList extends React.Component {
ee.on('list:isMarkdownNote', this.alertIfSnippetHandler)
ee.on('import:file', this.importFromFileHandler)
ee.on('list:jump', this.jumpNoteByHash)
ee.on('list:navigate', this.navigate)
}

componentWillReceiveProps (nextProps) {
Expand Down Expand Up @@ -687,6 +689,16 @@ class NoteList extends React.Component {
return copy(noteLink)
}

navigate (sender, pathname) {
const { router } = this.context
router.push({
pathname,
query: {
// key: noteKey
}
})
}

save (note) {
const { dispatch } = this.props
dataApi
Expand Down
2 changes: 2 additions & 0 deletions lib/main-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ app.on('ready', function () {

var template = require('./main-menu')
var menu = Menu.buildFromTemplate(template)
var touchBarMenu = require('./touchbar-menu')
switch (process.platform) {
case 'darwin':
Menu.setApplicationMenu(menu)
mainWindow.setTouchBar(touchBarMenu)
break
case 'win32':
mainWindow.setMenu(menu)
Expand Down
41 changes: 41 additions & 0 deletions lib/touchbar-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const {TouchBar} = require('electron')
const {TouchBarButton, TouchBarSpacer} = TouchBar
const mainWindow = require('./main-window')

const allNotes = new TouchBarButton({
label: '📒',
click: () => {
mainWindow.webContents.send('list:navigate', '/home')
}
})

const starredNotes = new TouchBarButton({
label: '⭐️',
click: () => {
mainWindow.webContents.send('list:navigate', '/starred')
}
})

const trash = new TouchBarButton({
label: '🗑',
click: () => {
mainWindow.webContents.send('list:navigate', '/trashed')
}
})

const newNote = new TouchBarButton({
label: '✎',
click: () => {
mainWindow.webContents.send('list:navigate', '/home')
mainWindow.webContents.send('top:new-note')
}
})

module.exports = new TouchBar([
allNotes,
starredNotes,
trash,
new TouchBarSpacer({size: 'small'}),
newNote
])

0 comments on commit 933f75f

Please sign in to comment.