UNPKG

2.8 kBTypeScriptView Raw
1import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
2import { Widget } from '@lumino/widgets';
3import { IMenuExtender } from './tokens';
4/**
5 * An interface for a File menu.
6 */
7export interface IFileMenu extends IRankedMenu {
8 /**
9 * Option to add a `Quit` entry in the File menu
10 */
11 quitEntry: boolean;
12 /**
13 * A submenu for creating new files/launching new activities.
14 */
15 readonly newMenu: IRankedMenu;
16 /**
17 * The close and cleanup extension point.
18 */
19 readonly closeAndCleaners: Set<IFileMenu.ICloseAndCleaner<Widget>>;
20 /**
21 * A set storing IConsoleCreators for the File menu.
22 */
23 readonly consoleCreators: Set<IFileMenu.IConsoleCreator<Widget>>;
24}
25/**
26 * An extensible FileMenu for the application.
27 */
28export declare class FileMenu extends RankedMenu implements IFileMenu {
29 constructor(options: IRankedMenu.IOptions);
30 /**
31 * The New submenu.
32 */
33 get newMenu(): RankedMenu;
34 /**
35 * The close and cleanup extension point.
36 */
37 readonly closeAndCleaners: Set<IFileMenu.ICloseAndCleaner<Widget>>;
38 /**
39 * A set storing IConsoleCreators for the Kernel menu.
40 */
41 readonly consoleCreators: Set<IFileMenu.IConsoleCreator<Widget>>;
42 /**
43 * Dispose of the resources held by the file menu.
44 */
45 dispose(): void;
46 /**
47 * Option to add a `Quit` entry in File menu
48 */
49 quitEntry: boolean;
50 private _newMenu;
51}
52/**
53 * Namespace for IFileMenu
54 */
55export declare namespace IFileMenu {
56 /**
57 * Interface for an activity that has some cleanup action associated
58 * with it in addition to merely closing its widget in the main area.
59 */
60 interface ICloseAndCleaner<T extends Widget> extends IMenuExtender<T> {
61 /**
62 * A function to create the label for the `closeAndCleanup`action.
63 *
64 * This function receives the number of items `n` to be able to provided
65 * correct pluralized forms of translations.
66 */
67 closeAndCleanupLabel?: (n: number) => string;
68 /**
69 * A function to perform the close and cleanup action.
70 */
71 closeAndCleanup: (widget: T) => Promise<void>;
72 }
73 /**
74 * Interface for a command to create a console for an activity.
75 */
76 interface IConsoleCreator<T extends Widget> extends IMenuExtender<T> {
77 /**
78 * A function to create the label for the `createConsole`action.
79 *
80 * This function receives the number of items `n` to be able to provided
81 * correct pluralized forms of translations.
82 */
83 createConsoleLabel?: (n: number) => string;
84 /**
85 * The function to create the console.
86 */
87 createConsole: (widget: T) => Promise<void>;
88 }
89}