From ff40102fbe96eeb744ffcc094e35d188785028c3 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 18 Dec 2015 17:15:53 +0100 Subject: [PATCH] GUI: allow deletion of non-empty directories --- src/GUI/Gtk/Gui.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/GUI/Gtk/Gui.hs b/src/GUI/Gtk/Gui.hs index b9fc503..cc42af1 100644 --- a/src/GUI/Gtk/Gui.hs +++ b/src/GUI/Gtk/Gui.hs @@ -236,12 +236,16 @@ open row mygui myview = case row of -- |Supposed to be used with `withRow`. Deletes a file or directory. del :: DTInfoZipper -> MyGUI -> MyView -> IO () del row mygui myview = case row of - dz@(Dir {}, _) -> do - let fp = getFullPath dz - cmsg = "Really delete directory \"" ++ fp ++ "\"?" - withConfirmationDialog cmsg - $ withErrorDialog (deleteDir dz - >> refreshTreeView mygui myview Nothing) + dz@(Dir _ cs _, _) -> do + let fp = getFullPath dz + cmsg = "Really delete directory \"" ++ fp ++ "\"?" + cmsg2 = "Directory \"" ++ fp ++ "\" is not empty! Delete all contents?" + withConfirmationDialog cmsg $ + if null cs + then withErrorDialog (deleteDir dz + >> refreshTreeView mygui myview Nothing) + else withConfirmationDialog cmsg2 $ withErrorDialog + (deleteDirRecursive dz >> refreshTreeView mygui myview Nothing) dz@(File {}, _) -> do let fp = getFullPath dz cmsg = "Really delete file \"" ++ fp ++ "\"?"