mirror of
https://github.com/Eugeny/tabby
synced 2024-12-16 00:02:53 +00:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import { DomSanitizer } from '@angular/platform-browser'
|
|
import { ToolbarButtonProvider, IToolbarButton, AppService, HostAppService } from 'terminus-core'
|
|
|
|
import { SettingsTabComponent } from './components/settingsTab.component'
|
|
|
|
@Injectable()
|
|
export class ButtonProvider extends ToolbarButtonProvider {
|
|
constructor (
|
|
hostApp: HostAppService,
|
|
private app: AppService,
|
|
private domSanitizer: DomSanitizer,
|
|
) {
|
|
super()
|
|
hostApp.preferencesMenu$.subscribe(() => this.open())
|
|
}
|
|
|
|
provide (): IToolbarButton[] {
|
|
return [{
|
|
icon: this.domSanitizer.bypassSecurityTrustHtml(require('./icons/cog.svg')),
|
|
title: 'Settings',
|
|
touchBarTitle: '⚙️',
|
|
weight: 10,
|
|
click: () => this.open(),
|
|
}]
|
|
}
|
|
|
|
open (): void {
|
|
let settingsTab = this.app.tabs.find((tab) => tab instanceof SettingsTabComponent)
|
|
if (settingsTab) {
|
|
this.app.selectTab(settingsTab)
|
|
} else {
|
|
this.app.openNewTab(SettingsTabComponent)
|
|
}
|
|
}
|
|
}
|