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