Skip to content

Commit

Permalink
Merge pull request #5990 from mbektasbbg/issue-5982
Browse files Browse the repository at this point in the history
add ability to toggle status bar visibility
  • Loading branch information
ian-r-rose committed Feb 15, 2019
2 parents 26d2b4a + d56f41d commit bdd751b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
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

0 comments on commit bdd751b

Please sign in to comment.