Re: confirm deleting from hotlist



Hello Oswald,

On Sat, 2004-11-13 at 10:48 +0100, Oswald Buddenhagen wrote:
> moin,
> 
> it happens quite often that i accidentally delete items from the hotlist
> - take the wrong angle when blindly moving up from the cursor block, and
> you hit del instead of enter.
> i think it would make sense if the hotlist obeyed the "confirm delete"
> option as well.
> alternatively, don't make del the delete action (but use f8 instead),
> but i think this sucks more.

The attached patch adds dialog prompting an user to confirm removal of
selected entry. It also introduces the "Don't ask" button. When pressed,
it deletes actual entry and user won't be prompted for entry deletion
any more so the 'del' key will act in the same fashion as up to now.

greetings,
Jindrich Novy

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1-20041115/src/hotlist.c.hotdel	2004-11-10 12:02:23.000000000 +0100
+++ mc-4.6.1-20041115/src/hotlist.c	2004-11-15 09:54:10.369229000 +0100
@@ -1050,7 +1050,10 @@
 	
 static void remove_from_hotlist (struct hotlist *entry)
 {
-    if (entry->type == HL_TYPE_GROUP) {
+    static int ask_if_remove = 1;
+
+    switch (entry->type) {
+    case HL_TYPE_GROUP:	
 	if (entry->head) {
 	    char *header;
 	    int   result;
@@ -1067,8 +1070,32 @@
 	    if (result != 1)
 		return;
 	}
-
+	    
 	remove_group (entry);
+	break;
+    case HL_TYPE_ENTRY:
+	if (ask_if_remove) {
+	    char *header;
+	    int   result;
+
+	    header = g_strconcat (_(" Remove: "),
+				   name_trunc (entry->label, 30),
+				   " ",
+				   NULL);
+	    result = query_dialog (header, _("\n Are you sure to remove this entry?"),
+				   D_ERROR, 3,
+				   _("&No"), _("&Yes"), _("&Don't ask again"));
+	    g_free (header);
+
+	    if (result == 2)
+	        ask_if_remove = 0;
+
+	    if (result == 0)
+		return;
+	}
+	break;
+    default:
+	break;
     }
 
     unlink_entry (entry);


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