|
@@ -2,7 +2,7 @@
|
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
import {
|
|
|
- indexOf, upperBound
|
|
|
+ find, indexOf, upperBound
|
|
|
} from 'phosphor/lib/algorithm/searching';
|
|
|
|
|
|
import {
|
|
@@ -21,25 +21,6 @@ import {
|
|
|
MenuBar
|
|
|
} from 'phosphor/lib/ui/menubar';
|
|
|
|
|
|
-import {
|
|
|
- Widget
|
|
|
-} from 'phosphor/lib/ui/widget';
|
|
|
-
|
|
|
-import {
|
|
|
- JupyterLab, JupyterLabPlugin
|
|
|
-} from '../application';
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * The class name for all main area portrait tab icons.
|
|
|
- */
|
|
|
-const PORTRAIT_ICON_CLASS = 'jp-MainAreaPortraitIcon';
|
|
|
-
|
|
|
-/**
|
|
|
- * The class name for the jupyter icon from the default theme.
|
|
|
- */
|
|
|
-const JUPYTER_ICON_CLASS = 'jp-JupyterIcon';
|
|
|
-
|
|
|
|
|
|
/* tslint:disable */
|
|
|
/**
|
|
@@ -78,12 +59,12 @@ interface IAddMenuOptions {
|
|
|
* The main menu class. It is intended to be used as a singleton.
|
|
|
*/
|
|
|
export
|
|
|
-class MainMenu implements IMainMenu {
|
|
|
+class MainMenu extends MenuBar implements IMainMenu {
|
|
|
/**
|
|
|
* Add a new menu to the main menu bar.
|
|
|
*/
|
|
|
addMenu(menu: Menu, options: IAddMenuOptions = {}): void {
|
|
|
- if (indexOf(Private.menuBar.menus, menu) > -1) {
|
|
|
+ if (indexOf(this.menus, menu) > -1) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -95,59 +76,17 @@ class MainMenu implements IMainMenu {
|
|
|
menu.disposed.connect(() => this._items.remove(rankItem));
|
|
|
|
|
|
this._items.insert(index, rankItem);
|
|
|
- Private.menuBar.insertMenu(index, menu);
|
|
|
+ this.insertMenu(index, menu);
|
|
|
}
|
|
|
|
|
|
private _items = new Vector<Private.IRankItem>();
|
|
|
}
|
|
|
|
|
|
|
|
|
-/**
|
|
|
- * A service providing an interface to the main menu.
|
|
|
- */
|
|
|
-export
|
|
|
-const mainMenuProvider: JupyterLabPlugin<IMainMenu> = {
|
|
|
- id: 'jupyter.services.main-menu',
|
|
|
- provides: IMainMenu,
|
|
|
- activate: activateMainMenu
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Activate the main menu extension.
|
|
|
- */
|
|
|
-function activateMainMenu(app: JupyterLab): IMainMenu {
|
|
|
- Private.menuBar = new MenuBar({ keymap: app.keymap });
|
|
|
- Private.menuBar.id = 'jp-MainMenu';
|
|
|
-
|
|
|
- let logo = new Widget();
|
|
|
- logo.node.className = `${PORTRAIT_ICON_CLASS} ${JUPYTER_ICON_CLASS}`;
|
|
|
- logo.id = 'jp-MainLogo';
|
|
|
-
|
|
|
- app.shell.addToTopArea(logo);
|
|
|
- app.shell.addToTopArea(Private.menuBar);
|
|
|
-
|
|
|
- return Private.mainMenu;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* A namespace for private data.
|
|
|
*/
|
|
|
namespace Private {
|
|
|
- /**
|
|
|
- * The singleton menu bar instance.
|
|
|
- */
|
|
|
- export
|
|
|
- let menuBar: MenuBar;
|
|
|
-
|
|
|
- /**
|
|
|
- * The singleton main menu instance.
|
|
|
- */
|
|
|
- export
|
|
|
- const mainMenu = new MainMenu();
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* An object which holds a menu and its sort rank.
|
|
|
*/
|