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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
||
|
@@ -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'; | ||
|
@@ -46,8 +50,15 @@ export const STATUSBAR_PLUGIN_ID = '@jupyterlab/statusbar-extension:plugin'; | |
const statusBar: JupyterFrontEndPlugin<IStatusBar> = { | ||
id: STATUSBAR_PLUGIN_ID, | ||
provides: IStatusBar, | ||
requires: [ISettingRegistry, IMainMenu, ICommandPalette], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make the menu optional, and maybe even the command palette? Like in the |
||
autoStart: true, | ||
activate: (app: JupyterFrontEnd, labShell: ILabShell | null) => { | ||
activate: ( | ||
app: JupyterFrontEnd, | ||
settingRegistry: ISettingRegistry, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ever since #5845 we have been trying to make the core plugins less interdependent by making a lot of these tokens optional. Can you move |
||
mainMenu: IMainMenu, | ||
palette: ICommandPalette, | ||
labShell: ILabShell | null | ||
) => { | ||
const statusBar = new StatusBar(); | ||
statusBar.id = 'jp-main-statusbar'; | ||
app.shell.add(statusBar, 'bottom'); | ||
|
@@ -59,6 +70,41 @@ const statusBar: JupyterFrontEndPlugin<IStatusBar> = { | |
}); | ||
} | ||
|
||
const category: string = 'Main Area'; | ||
const command: string = 'toggle-jp-main-statusbar'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our convention for command IDs has been to use something like |
||
|
||
app.commands.addCommand(command, { | ||
label: 'Show Status Bar', | ||
execute: (args: any) => { | ||
statusBar.setHidden(statusBar.isVisible); | ||
settingRegistry.set( | ||
STATUSBAR_PLUGIN_ID, | ||
'visible', | ||
statusBar.isVisible | ||
); | ||
}, | ||
isToggled: () => statusBar.isVisible | ||
}); | ||
|
||
palette.addItem({ command, category }); | ||
mainMenu.viewMenu.addGroup([{ command }], 1); | ||
|
||
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] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's any time, so I would delete "at launch"