Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: add dock menu on macos

Abdullah Attae334698e3bc0
diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js
index d5f369333..cd036ca08 100644
--- a/apps/web/desktop/electron.js
+++ b/apps/web/desktop/electron.js
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* global MAC_APP_STORE, RELEASE */
import "isomorphic-fetch";
-import { app, BrowserWindow, Menu, nativeTheme, shell, Tray } from "electron";
+import { app, BrowserWindow, nativeTheme, shell } from "electron";
import { APP_ICON_PATH, isDevelopment } from "./utils";
import { registerProtocol, PROTOCOL_URL } from "./protocol";
import { configureAutoUpdater } from "./autoupdate";
@@ -34,11 +34,8 @@ import "./ipc/index.js";
import getPrivacyMode from "./ipc/calls/getPrivacyMode";
import setPrivacyMode from "./ipc/actions/setPrivacyMode";
import { getIsSpellCheckerEnabled } from "./config/spellChecker";
-import yargs from "yargs";
-import { hideBin } from "yargs/helpers";
import { getDesktopIntegration } from "./config/desktopIntegration";
import { AutoLaunch } from "./autolaunch";
-import bringToFront from "./ipc/actions/bringToFront";
import { setupJumplist } from "./jumplist";
import { setupTray } from "./tray";
import { parseArguments } from "./cli";
diff --git a/apps/web/desktop/jumplist.ts b/apps/web/desktop/jumplist.ts
index 7f496b551..7b773d9a2 100644
--- a/apps/web/desktop/jumplist.ts
+++ b/apps/web/desktop/jumplist.ts
@@ -17,16 +17,21 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { app } from "electron";
+import { app, Menu } from "electron";
import { AssetManager } from "./asset-manager";
+import { EVENTS } from "./events";
+import bringToFront from "./ipc/actions/bringToFront";
+import { sendMessageToRenderer } from "./ipc/utils";
export function setupJumplist() {
if (process.platform === "win32") {
- windows();
+ setJumplistOnWindows();
+ } else if (process.platform === "darwin") {
+ setDockMenuOnMacOs();
}
}
-function windows() {
+function setJumplistOnWindows() {
app.setJumpList([
{
type: "custom",
@@ -63,3 +68,51 @@ function windows() {
}
]);
}
+
+function setDockMenuOnMacOs() {
+ const contextMenu = Menu.buildFromTemplate([
+ {
+ label: "New note",
+ type: "normal",
+ icon: AssetManager.icon("note-add", { size: 16 }),
+ click: () => {
+ bringToFront();
+ sendMessageToRenderer(EVENTS.createItem, { itemType: "note" });
+ }
+ },
+ {
+ label: "New notebook",
+ type: "normal",
+ icon: AssetManager.icon("notebook-add", { size: 16 }),
+ click: () => {
+ bringToFront();
+ sendMessageToRenderer(EVENTS.createItem, { itemType: "notebook" });
+ }
+ },
+ {
+ label: "New reminder",
+ type: "normal",
+ icon: AssetManager.icon("reminder-add", { size: 16 }),
+ click: () => {
+ bringToFront();
+ sendMessageToRenderer(EVENTS.createItem, { itemType: "reminder" });
+ }
+ },
+ { type: "separator" },
+ {
+ label: "Hide",
+ type: "normal",
+ icon: AssetManager.appIcon({ size: 16 }),
+ click: () => app.hide()
+ },
+ {
+ label: "Quit",
+ icon: AssetManager.icon("quit", { size: 16 }),
+ type: "normal",
+ click: () => {
+ app.exit(0);
+ }
+ }
+ ]);
+ app.dock.setMenu(contextMenu);
+}