1 | import { BrowserWindowConstructorOptions, LoadURLOptions, Tray } from 'electron';
|
2 | /**
|
3 | * Options for creating a menubar application
|
4 | */
|
5 | export interface Options {
|
6 | /**
|
7 | * Listen on `app.on('activate')` to open menubar when app is activated.
|
8 | * @default `true`
|
9 | */
|
10 | activateWithApp?: boolean;
|
11 | /**
|
12 | * An Electron BrowserWindow instance, or an options object to be passed into
|
13 | * the BrowserWindow constructor.
|
14 | * @example
|
15 | * ```typescript
|
16 | * const options = { height: 640, width: 480 };
|
17 | *
|
18 | * const mb = new Menubar({
|
19 | * browserWindow: options
|
20 | * });
|
21 | * ```
|
22 | */
|
23 | browserWindow: BrowserWindowConstructorOptions;
|
24 | /**
|
25 | * The app source directory.
|
26 | */
|
27 | dir: string;
|
28 | /**
|
29 | * The png icon to use for the menubar. A good size to start with is 20x20.
|
30 | * To support retina, supply a 2x sized image (e.g. 40x40) with @2x added to
|
31 | * the end of the name, so icon.png and icon@2x.png and Electron will
|
32 | * automatically use your @2x version on retina screens.
|
33 | */
|
34 | icon?: string | Electron.NativeImage;
|
35 | /**
|
36 | * The URL to load the menubar's browserWindow with. The url can be a remote
|
37 | * address (e.g. `http://`) or a path to a local HTML file using the
|
38 | * `file://` protocol. If false, then menubar won't call `loadURL` on
|
39 | * start.
|
40 | * @default `file:// + options.dir + index.html`
|
41 | * @see https://electronjs.org/docs/api/browser-window#winloadurlurl-options
|
42 | */
|
43 | index: string | false;
|
44 | /**
|
45 | * The options passed when loading the index URL in the menubar's
|
46 | * browserWindow. Everything browserWindow.loadURL supports is supported;
|
47 | * this object is simply passed onto browserWindow.loadURL
|
48 | * @default `{}`
|
49 | * @see https://electronjs.org/docs/api/browser-window#winloadurlurl-options
|
50 | */
|
51 | loadUrlOptions?: LoadURLOptions;
|
52 | /**
|
53 | * Create BrowserWindow instance before it is used -- increasing resource
|
54 | * usage, but making the click on the menubar load faster.
|
55 | */
|
56 | preloadWindow?: boolean;
|
57 | /**
|
58 | * Configure the visibility of the application dock icon, macOS only. Calls
|
59 | * [`app.dock.hide`](https://electronjs.org/docs/api/app#appdockhide-macos).
|
60 | */
|
61 | showDockIcon?: boolean;
|
62 | /**
|
63 | * Makes the window available on all OS X workspaces. Calls
|
64 | * [`setVisibleOnAllWorkspaces`](https://electronjs.org/docs/api/browser-window#winsetvisibleonallworkspacesvisible-options).
|
65 | */
|
66 | showOnAllWorkspaces?: boolean;
|
67 | /**
|
68 | * Show the window on 'right-click' event instead of regular 'click'.
|
69 | */
|
70 | showOnRightClick?: boolean;
|
71 | /**
|
72 | * Menubar tray icon tooltip text. Calls [`tray.setTooltip`](https://electronjs.org/docs/api/tray#traysettooltiptooltip).
|
73 | */
|
74 | tooltip: string;
|
75 | /**
|
76 | * An electron Tray instance. If provided, `options.icon` will be ignored.
|
77 | */
|
78 | tray?: Tray;
|
79 | /**
|
80 | * Sets the window position (x and y will still override this), check
|
81 | * electron-positioner docs for valid values.
|
82 | */
|
83 | windowPosition?: 'trayLeft' | 'trayBottomLeft' | 'trayRight' | 'trayBottomRight' | 'trayCenter' | 'trayBottomCenter' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter' | 'leftCenter' | 'rightCenter' | 'center';
|
84 | }
|