Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to toggle status bar visibility #5990

Merged
merged 3 commits into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/statusbar-extension/package.json
Expand Up @@ -37,8 +37,10 @@
"@jupyterlab/apputils": "^1.0.0-alpha.3",
"@jupyterlab/cells": "^1.0.0-alpha.3",
"@jupyterlab/console": "^1.0.0-alpha.3",
"@jupyterlab/coreutils": "^3.0.0-alpha.3",
"@jupyterlab/docregistry": "^1.0.0-alpha.3",
"@jupyterlab/fileeditor": "^1.0.0-alpha.3",
"@jupyterlab/mainmenu": "^1.0.0-alpha.3",
"@jupyterlab/notebook": "^1.0.0-alpha.4",
"@jupyterlab/statusbar": "^1.0.0-alpha.3",
"@phosphor/widgets": "^1.6.0"
Expand Down
6 changes: 6 additions & 0 deletions packages/statusbar-extension/schema/plugin.json
Expand Up @@ -21,6 +21,12 @@
"memory-usage-item",
"saving-status-item"
]
},
"visible": {
"type": "boolean",
"title": "Status Bar Visibility",
"description": "Whether to show status bar or not",
"default": true
}
},
"additionalProperties": false,
Expand Down
59 changes: 56 additions & 3 deletions packages/statusbar-extension/src/index.ts
Expand Up @@ -7,7 +7,7 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { IClientSession } from '@jupyterlab/apputils';
import { IClientSession, ICommandPalette } from '@jupyterlab/apputils';

import { Cell, CodeCell } from '@jupyterlab/cells';

Expand Down Expand Up @@ -36,6 +36,10 @@ import {
StatusBar
} from '@jupyterlab/statusbar';

import { ISettingRegistry } from '@jupyterlab/coreutils';

import { IMainMenu } from '@jupyterlab/mainmenu';

import { Title, Widget } from '@phosphor/widgets';

export const STATUSBAR_PLUGIN_ID = '@jupyterlab/statusbar-extension:plugin';
Expand All @@ -47,7 +51,13 @@ const statusBar: JupyterFrontEndPlugin<IStatusBar> = {
id: STATUSBAR_PLUGIN_ID,
provides: IStatusBar,
autoStart: true,
activate: (app: JupyterFrontEnd, labShell: ILabShell | null) => {
activate: (
app: JupyterFrontEnd,
labShell: ILabShell | null,
settingRegistry: ISettingRegistry | null,
mainMenu: IMainMenu | null,
palette: ICommandPalette | null
) => {
const statusBar = new StatusBar();
statusBar.id = 'jp-main-statusbar';
app.shell.add(statusBar, 'bottom');
Expand All @@ -59,9 +69,52 @@ const statusBar: JupyterFrontEndPlugin<IStatusBar> = {
});
}

const category: string = 'Main Area';
const command: string = 'statusbar:toggle';

app.commands.addCommand(command, {
label: 'Show Status Bar',
execute: (args: any) => {
statusBar.setHidden(statusBar.isVisible);
if (settingRegistry) {
settingRegistry.set(
STATUSBAR_PLUGIN_ID,
'visible',
statusBar.isVisible
);
}
},
isToggled: () => statusBar.isVisible
});

if (palette) {
palette.addItem({ command, category });
}
if (mainMenu) {
mainMenu.viewMenu.addGroup([{ command }], 1);
}

if (settingRegistry) {
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const visible = settings.get('visible').composite as boolean;
statusBar.setHidden(!visible);
};

Promise.all([settingRegistry.load(STATUSBAR_PLUGIN_ID), app.restored])
.then(([settings]) => {
updateSettings(settings);
settings.changed.connect(settings => {
updateSettings(settings);
});
})
.catch((reason: Error) => {
console.error(reason.message);
});
}

return statusBar;
},
optional: [ILabShell]
optional: [ILabShell, ISettingRegistry, IMainMenu, ICommandPalette]
};

/**
Expand Down
6 changes: 6 additions & 0 deletions packages/statusbar-extension/tsconfig.json
Expand Up @@ -18,12 +18,18 @@
{
"path": "../console"
},
{
"path": "../coreutils"
},
{
"path": "../docregistry"
},
{
"path": "../fileeditor"
},
{
"path": "../mainmenu"
},
{
"path": "../notebook"
},
Expand Down