[gnome-sound-recorder/issue_17: 5/6] Send file to trash instead of deleting from disk



commit da31ec0f05c4a49806c498534490212715c2a98b
Author: Meg Ford <megford gnome org>
Date:   Mon Feb 18 23:38:22 2019 -0600

    Send file to trash instead of deleting from disk

 src/listview.js   | 5 ++---
 src/mainWindow.js | 7 ++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/listview.js b/src/listview.js
index 1e44796..28466c4 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -260,9 +260,8 @@ var Listview = class Listview {
             Gio.Application.get_default().ensure_directory();
             this._saveDir = Gio.Application.get_default().saveDir;
         }
-        if ((eventType == Gio.FileMonitorEvent.MOVED_OUT) ||
-            (eventType == Gio.FileMonitorEvent.CHANGES_DONE_HINT
-                && MainWindow.recordPipeline == MainWindow.RecordPipelineStates.STOPPED) || (eventType == 
Gio.FileMonitorEvent.RENAMED)) {
+        else if ((eventType == Gio.FileMonitorEvent.DELETED) ||
+            (eventType == Gio.FileMonitorEvent.CHANGES_DONE_HINT  && MainWindow.recordPipeline == 
MainWindow.RecordPipelineStates.STOPPED) || (eventType == Gio.FileMonitorEvent.RENAMED)) {
             stopVal = EnumeratorState.ACTIVE;
             allFilesInfo.length = 0;
             fileInfo.length = 0;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2946cef..7c9fd7c 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -662,7 +662,12 @@ const MainView = GObject.registerClass(class MainView extends Gtk.Stack {
 
     _deleteFile(selected) {
         let fileToDelete = this._getFileFromRow(selected);
-        fileToDelete.trash_async(GLib.PRIORITY_DEFAULT, null, null);
+        fileToDelete.delete_async(GLib.PRIORITY_DEFAULT, null, (obj, res) => {
+            let done = obj.delete_finish(res);
+            if(!done) {
+                log("file not deleted")
+            }
+        });
     }
 
     loadPlay(selected) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]