Skip to content

Commit

Permalink
Add a sourceChanged signal and use it to notify of command changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Oct 17, 2019
1 parent 2afb2ae commit 77354b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/logconsole-extension/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,13 @@ function activateLogConsole(
return true;
});

logConsolePanel.sourceChanged.connect(() => {
app.commands.notifyCommandChanged();
});

logConsoleWidget.disposed.connect(() => {
logConsoleWidget = null;
app.commands.notifyCommandChanged();
status.model.flashEnabled = flashEnabled;
});

Expand All @@ -499,6 +504,7 @@ function activateLogConsole(
});

logConsoleWidget.update();
app.commands.notifyCommandChanged();
};

app.commands.addCommand(CommandIDs.open, {
Expand Down
13 changes: 11 additions & 2 deletions packages/logconsole/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,21 @@ export class LogConsolePanel extends StackedPanel {
/**
* The log source displayed
*/
get source(): string {
get source(): string | null {
return this._source;
}
set source(name: string) {
set source(name: string | null) {
this._source = name;
this._showOutputFromSource(this._source);
this._handlePlaceholder();
this._sourceChanged.emit(name);
}

/**
* Signal for source changes
*/
get sourceChanged(): ISignal<this, string | null> {
return this._sourceChanged;
}

private _handlePlaceholder() {
Expand Down Expand Up @@ -554,6 +562,7 @@ export class LogConsolePanel extends StackedPanel {
private _loggerRegistry: ILoggerRegistry;
private _outputAreas = new Map<string, LogConsoleOutputArea>();
private _source: string | null = null;
private _sourceChanged = new Signal<this, string | null>(this);
private _entryLimit: number = DEFAULT_LOG_ENTRY_LIMIT;
private _scrollTimer: number = null;
private _placeholder: Widget;
Expand Down

0 comments on commit 77354b5

Please sign in to comment.