mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-23 13:13:49 +03:00
touchbar improvements
This commit is contained in:
parent
c3c983daf6
commit
9a8bad4851
@ -1,6 +1,7 @@
|
||||
export interface IToolbarButton {
|
||||
icon: string
|
||||
title: string
|
||||
touchBarTitle?: string
|
||||
weight?: number
|
||||
click: () => void
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export class TouchbarService {
|
||||
app.activeTabChange$.subscribe(() => this.update())
|
||||
app.tabOpened$.subscribe(tab => {
|
||||
let sub = tab.titleChange$.subscribe(title => {
|
||||
this.tabSegments[app.tabs.indexOf(tab)].label = title
|
||||
this.tabSegments[app.tabs.indexOf(tab)].label = this.shortenTitle(title)
|
||||
this.tabsSegmentedControl.segments = this.tabSegments
|
||||
})
|
||||
this.titleSubscriptions.set(tab, sub)
|
||||
@ -43,7 +43,7 @@ export class TouchbarService {
|
||||
})
|
||||
buttons.sort((a, b) => (a.weight || 0) - (b.weight || 0))
|
||||
this.tabSegments = this.app.tabs.map(tab => ({
|
||||
label: tab.title,
|
||||
label: this.shortenTitle(tab.title),
|
||||
}))
|
||||
this.tabsSegmentedControl = new this.electron.TouchBar.TouchBarSegmentedControl({
|
||||
segments: this.tabSegments,
|
||||
@ -58,7 +58,7 @@ export class TouchbarService {
|
||||
new this.electron.TouchBar.TouchBarSpacer({size: 'flexible'}),
|
||||
new this.electron.TouchBar.TouchBarSpacer({size: 'small'}),
|
||||
...buttons.map(button => new this.electron.TouchBar.TouchBarButton({
|
||||
label: button.title,
|
||||
label: this.shortenTitle(button.touchBarTitle || button.title),
|
||||
// backgroundColor: '#0022cc',
|
||||
click: () => this.zone.run(() => button.click()),
|
||||
}))
|
||||
@ -67,4 +67,10 @@ export class TouchbarService {
|
||||
this.electron.app.window.setTouchBar(touchBar)
|
||||
}
|
||||
|
||||
private shortenTitle (title: string): string {
|
||||
if (title.length > 15) {
|
||||
title = title.substring(0, 15) + '...'
|
||||
}
|
||||
return title
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
return [{
|
||||
icon: 'sliders',
|
||||
title: 'Settings',
|
||||
touchBarTitle: '⚙️',
|
||||
weight: 10,
|
||||
click: () => this.open(),
|
||||
}]
|
||||
|
@ -25,7 +25,8 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
return [{
|
||||
icon: 'globe',
|
||||
weight: 5,
|
||||
title: 'SSH',
|
||||
title: 'SSH connections',
|
||||
touchBarTitle: 'SSH',
|
||||
click: async () => {
|
||||
this.activate()
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
return [{
|
||||
icon: 'plus',
|
||||
title: 'New terminal',
|
||||
touchBarTitle: 'New',
|
||||
click: async () => {
|
||||
this.openNewTab()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user