mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 10:05:57 +08:00
desktop: Add "New Notebook" to system tray menu (#2247)
This commit is contained in:
parent
100d88041b
commit
ed6ae02ada
|
@ -370,6 +370,10 @@ defmodule Livebook.Utils do
|
|||
LivebookWeb.Endpoint.access_url()
|
||||
end
|
||||
|
||||
def expand_desktop_url("/new") do
|
||||
to_string(%{LivebookWeb.Endpoint.access_struct_url() | path: "/new"})
|
||||
end
|
||||
|
||||
def expand_desktop_url("/settings") do
|
||||
to_string(%{LivebookWeb.Endpoint.access_struct_url() | path: "/settings"})
|
||||
end
|
||||
|
|
|
@ -72,9 +72,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
menu.items = [
|
||||
NSMenuItem(title: "Open", action: #selector(open), keyEquivalent: "o"),
|
||||
NSMenuItem(title: "New Notebook", action: #selector(openNewNotebook), keyEquivalent: "n"),
|
||||
.separator(),
|
||||
copyURLItem,
|
||||
NSMenuItem(title: "View Logs", action: #selector(viewLogs), keyEquivalent: "l"),
|
||||
NSMenuItem(title: "Open .livebookdesktop.sh", action: #selector(openBootScript), keyEquivalent: ""),
|
||||
.separator(),
|
||||
NSMenuItem(title: "Settings", action: #selector(openSettings), keyEquivalent: ","),
|
||||
NSMenuItem(title: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||
]
|
||||
|
@ -116,6 +119,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
ElixirKit.API.publish("open", "")
|
||||
}
|
||||
|
||||
@objc
|
||||
func openNewNotebook() {
|
||||
ElixirKit.API.publish("open", "/new")
|
||||
}
|
||||
|
||||
@objc
|
||||
func copyURL() {
|
||||
let pasteboard = NSPasteboard.general
|
||||
|
|
|
@ -68,12 +68,15 @@ class LivebookApp : ApplicationContext
|
|||
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
menu.Items.Add("Open", null, openClicked);
|
||||
menu.Items.Add("New Notebook", null, openNewNotebookClicked);
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
var copyURLButton = menu.Items.Add("Copy URL", null, copyURLClicked);
|
||||
copyURLButton.Enabled = false;
|
||||
|
||||
menu.Items.Add("View Logs", null, viewLogsClicked);
|
||||
menu.Items.Add("Open .livebookdesktop.bat", null, openBootScriptClicked);
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
menu.Items.Add("Settings", null, openSettingsClicked);
|
||||
menu.Items.Add("Quit", null, quitClicked);
|
||||
notifyIcon = new NotifyIcon()
|
||||
|
@ -134,6 +137,11 @@ class LivebookApp : ApplicationContext
|
|||
ElixirKit.API.Publish("open", "");
|
||||
}
|
||||
|
||||
private void openNewNotebookClicked(object? sender, EventArgs e)
|
||||
{
|
||||
ElixirKit.API.Publish("open", "/new");
|
||||
}
|
||||
|
||||
private void copyURLClicked(object? sender, EventArgs e)
|
||||
{
|
||||
System.Windows.Forms.Clipboard.SetText(url!);
|
||||
|
|
Loading…
Reference in a new issue