Skip to content

TagSpaces is an offline, open source, document manager with tagging support

refactoring tray file operation

kristiyandd8157401db2ae
diff --git a/data/electron/electron.api.js b/data/electron/electron.api.js
index eff887530..f5996b652 100644
--- a/data/electron/electron.api.js
+++ b/data/electron/electron.api.js
@@ -380,31 +380,38 @@ define(function(require, exports, module) {
var menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
- ipcRenderer.on("new-file", function(event, arg) {
- if (arg === "text") {
- TSCORE.UI.createTXTFile();
- } else if (arg === "html") {
- TSCORE.UI.createHTMLFile();
- } else if (arg === "markdown") {
- TSCORE.UI.createMDFile();
- } else if (arg === "audio") {
- TSCORE.UI.showAudioRecordingDialog();
- }
- });
-
- ipcRenderer.on("next-file", function(event, arg) {
- if (TSCORE.selectedFiles[0]) {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(TSCORE.FileOpener.getOpenedFilePath()));
- } else {
- TSCORE.showAlertDialog($.i18n.t("ns.common:selectFile"));
- }
- });
-
- ipcRenderer.on("previous-file", function(event, arg) {
- if (TSCORE.selectedFiles[0]) {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(TSCORE.FileOpener.getOpenedFilePath()));
- } else {
- TSCORE.showAlertDialog($.i18n.t("ns.common:selectFile"));
+ ipcRenderer.on("file", function(event, arg) {
+ switch (arg) {
+ case "text":
+ TSCORE.UI.createTXTFile();
+ break;
+ case "html":
+ TSCORE.UI.createHTMLFile();
+ break;
+ case "markdown":
+ TSCORE.UI.createMDFile();
+ break;
+ case "audio":
+ TSCORE.UI.showAudioRecordingDialog();
+ break;
+ case "next-file":
+ if (TSCORE.selectedFiles[0]) {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(TSCORE.selectedFiles[0]));
+ TSCORE.PerspectiveManager.selectFile(TSCORE.FileOpener.getOpenedFilePath());
+ } else {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:selectFile"));
+ }
+ break;
+ case "previous-file":
+ if (TSCORE.selectedFiles[0]) {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(TSCORE.selectedFiles[0]));
+ TSCORE.PerspectiveManager.selectFile(TSCORE.FileOpener.getOpenedFilePath());
+ } else {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:selectFile"));
+ }
+ break;
+ default:
+ return false;
}
});
diff --git a/data/electron/main.js b/data/electron/main.js
index 109224244..1615cbb66 100644
--- a/data/electron/main.js
+++ b/data/electron/main.js
@@ -140,6 +140,7 @@ app.on('ready', function(event) {
trayIconPath = 'Contents/Resources/app/assets/trayicon.png';
} else if (process.platform === 'win32') {
trayIconPath = 'resources/app/assets/trayicon.png';
+ trayIconPath = 'assets/trayicon.png';
} else {
trayIconPath = 'resources/app/assets/trayicon.png';
}
@@ -245,60 +246,60 @@ app.on('ready', function(event) {
function newTextFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "text");
+ mainWindow.webContents.send("file", "text");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "text");
+ newWindow.webContents.send("file", "text");
}
}
function newHTMLFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "html");
+ mainWindow.webContents.send("file", "html");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "html");
+ newWindow.webContents.send("file", "html");
}
}
function newMDFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "markdown");
+ mainWindow.webContents.send("file", "markdown");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "markdown");
+ newWindow.webContents.send("file", "markdown");
}
}
function newAudioFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "audio");
+ mainWindow.webContents.send("file", "audio");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "audio");
+ newWindow.webContents.send("file", "audio");
}
}
function getNextFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "next");
+ mainWindow.webContents.send("file", "next-file");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "next");
+ newWindow.webContents.send("file", "next-file");
}
}
function getPreviousFile() {
if (mainWindow) {
mainWindow.show();
- mainWindow.webContents.send("new-file", "previous");
+ mainWindow.webContents.send("file", "previous-file");
} else {
newWindow.show();
- newWindow.webContents.send("new-file", "previous");
+ newWindow.webContents.send("file", "previous-filesss");
}
}