From d73b552f48151c57c1cc2c50e6e7bddbea61372f Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 4 Feb 2021 10:14:01 +0100 Subject: [PATCH] Set the notebook name in the browser tab title --- jupyterlab_classic/app.py | 1 + packages/application-extension/src/index.ts | 27 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/jupyterlab_classic/app.py b/jupyterlab_classic/app.py index dfa8976c2..a7fca1743 100644 --- a/jupyterlab_classic/app.py +++ b/jupyterlab_classic/app.py @@ -106,6 +106,7 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp): description = "JupyterLab Classic - A JupyterLab Distribution with the Classic Notebook look and feel" app_version = version extension_url = "/classic/tree" + default_url = "/classic/tree" load_other_extensions = True app_dir = app_dir app_settings_dir = pjoin(app_dir, "settings") diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index c6df1306d..b477725d2 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -284,6 +284,32 @@ const spacer: JupyterFrontEndPlugin = { } }; +/** + * A plugin to display the document title in the browser tab title + */ +const tabTitle: JupyterFrontEndPlugin = { + id: '@jupyterlab-classic/application-extension:tab-title', + autoStart: true, + requires: [IClassicShell], + activate: (app: JupyterFrontEnd, shell: IClassicShell) => { + const setTabTitle = () => { + const current = shell.currentWidget; + if (!(current instanceof DocumentWidget)) { + return; + } + const update = () => { + const basename = PathExt.basename(current.context.path); + document.title = basename; + }; + current.context.pathChanged.connect(update); + update(); + }; + + shell.currentChanged.connect(setTabTitle); + setTabTitle(); + } +}; + /** * A plugin to display and rename the title of a file */ @@ -472,6 +498,7 @@ const plugins: JupyterFrontEndPlugin[] = [ sessionDialogs, shell, spacer, + tabTitle, title, topVisibility, translator,