Skip to content

Commit ca1b288

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-667: Show dirty indicator on unclosable widget
Signed-off-by: Akos Kitta <[email protected]>
1 parent 41eeb33 commit ca1b288

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import {
3333
ApplicationShell as TheiaApplicationShell,
3434
ShellLayoutRestorer as TheiaShellLayoutRestorer,
3535
CommonFrontendContribution as TheiaCommonFrontendContribution,
36-
KeybindingRegistry as TheiaKeybindingRegistry
36+
KeybindingRegistry as TheiaKeybindingRegistry,
37+
TabBarRendererFactory,
38+
ContextMenuRenderer
3739
} from '@theia/core/lib/browser';
3840
import { MenuContribution } from '@theia/core/lib/common/menu';
3941
import { ApplicationShell } from './theia/core/application-shell';
@@ -120,6 +122,8 @@ import { OutputServicePath, OutputService } from '../common/protocol/output-serv
120122
import { NotificationCenter } from './notification-center';
121123
import { NotificationServicePath, NotificationServiceServer } from '../common/protocol';
122124
import { About } from './contributions/about';
125+
import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service';
126+
import { TabBarRenderer } from './theia/core/tab-bars';
123127

124128
const ElementQueries = require('css-element-queries/src/ElementQueries');
125129

@@ -329,4 +333,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
329333

330334
bind(NotificationCenter).toSelf().inSingletonScope();
331335
bind(NotificationServiceServer).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, NotificationServicePath)).inSingletonScope();
336+
337+
// Enable the dirty indicator on uncloseable widgets.
338+
rebind(TabBarRendererFactory).toFactory(context => () => {
339+
const contextMenuRenderer = context.container.get<ContextMenuRenderer>(ContextMenuRenderer);
340+
const decoratorService = context.container.get<TabBarDecoratorService>(TabBarDecoratorService);
341+
const iconThemeService = context.container.get<IconThemeService>(IconThemeService);
342+
return new TabBarRenderer(contextMenuRenderer, decoratorService, iconThemeService);
343+
});
332344
});

Diff for: arduino-ide-extension/src/browser/style/editor.css

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

Diff for: arduino-ide-extension/src/browser/style/index.css

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@import './arduino-select.css';
66
@import './status-bar.css';
77
@import './terminal.css';
8+
@import './editor.css';
89

910
.theia-input.warning:focus {
1011
outline-width: 1px;
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { TabBar } from '@phosphor/widgets';
2+
import { Saveable } from '@theia/core/lib/browser/saveable';
3+
import { TabBarRenderer as TheiaTabBarRenderer } from '@theia/core/lib/browser/shell/tab-bars';
4+
5+
export class TabBarRenderer extends TheiaTabBarRenderer {
6+
7+
createTabClass(data: TabBar.IRenderData<any>): string {
8+
let className = super.createTabClass(data);
9+
if (!data.title.closable && Saveable.isDirty(data.title.owner)) {
10+
className += ' p-mod-closable';
11+
}
12+
return className;
13+
}
14+
15+
}

0 commit comments

Comments
 (0)