ATL-667: Show dirty indicator on unclosable widget

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-11-06 09:37:21 +01:00 committed by Akos Kitta
parent 41eeb337f9
commit ca1b288706
4 changed files with 35 additions and 1 deletions

View File

@ -33,7 +33,9 @@ import {
ApplicationShell as TheiaApplicationShell,
ShellLayoutRestorer as TheiaShellLayoutRestorer,
CommonFrontendContribution as TheiaCommonFrontendContribution,
KeybindingRegistry as TheiaKeybindingRegistry
KeybindingRegistry as TheiaKeybindingRegistry,
TabBarRendererFactory,
ContextMenuRenderer
} from '@theia/core/lib/browser';
import { MenuContribution } from '@theia/core/lib/common/menu';
import { ApplicationShell } from './theia/core/application-shell';
@ -120,6 +122,8 @@ import { OutputServicePath, OutputService } from '../common/protocol/output-serv
import { NotificationCenter } from './notification-center';
import { NotificationServicePath, NotificationServiceServer } from '../common/protocol';
import { About } from './contributions/about';
import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
import { TabBarRenderer } from './theia/core/tab-bars';
const ElementQueries = require('css-element-queries/src/ElementQueries');
@ -329,4 +333,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(NotificationCenter).toSelf().inSingletonScope();
bind(NotificationServiceServer).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, NotificationServicePath)).inSingletonScope();
// Enable the dirty indicator on uncloseable widgets.
rebind(TabBarRendererFactory).toFactory(context => () => {
const contextMenuRenderer = context.container.get<ContextMenuRenderer>(ContextMenuRenderer);
const decoratorService = context.container.get<TabBarDecoratorService>(TabBarDecoratorService);
const iconThemeService = context.container.get<IconThemeService>(IconThemeService);
return new TabBarRenderer(contextMenuRenderer, decoratorService, iconThemeService);
});
});

View File

@ -0,0 +1,6 @@
/* Show the dirty indicator on unclosable widgets. On hover, it should still show the dot instead of the X. */
/* https://github.com/arduino/arduino-pro-ide/issues/380 */
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable.theia-mod-dirty > .p-TabBar-tabCloseIcon:hover {
background-size: 13px;
background-image: var(--theia-icon-circle);
}

View File

@ -5,6 +5,7 @@
@import './arduino-select.css';
@import './status-bar.css';
@import './terminal.css';
@import './editor.css';
.theia-input.warning:focus {
outline-width: 1px;

View File

@ -0,0 +1,15 @@
import { TabBar } from '@phosphor/widgets';
import { Saveable } from '@theia/core/lib/browser/saveable';
import { TabBarRenderer as TheiaTabBarRenderer } from '@theia/core/lib/browser/shell/tab-bars';
export class TabBarRenderer extends TheiaTabBarRenderer {
createTabClass(data: TabBar.IRenderData<any>): string {
let className = super.createTabClass(data);
if (!data.title.closable && Saveable.isDirty(data.title.owner)) {
className += ' p-mod-closable';
}
return className;
}
}