From 04000dcf84706d2536941285ebb9b94e835204e2 Mon Sep 17 00:00:00 2001 From: Pavel Tsekov Date: Sun, 29 Jan 2006 20:26:05 +0000 Subject: [PATCH] * doc/mc.1.in: Update the documentation to reflect the fact that confirmation may be requested when deleting directory hotlist entries based on a user configurable setting. * src/file.h (safe_delete): Move declaration of `safe_delete' * src/main.h: ... here. (confirm_directory_hotlist_delete): Declare new global variable. * src/file.c (safe_delete): Move definition of `safe_delete' * src/main.c: ... here. (confirm_directory_hotlist_delete): Define new global variable. * src/hotlist.c (remove_from_hotlist): Based on a user configurable setting, request confirmation when removing directory hotlist entries. The confirmation dialog honours the `Safe delete' setting. Reorder the buttons in the hotlist group removal confirmation dialog so that it becomes consistent with other confirmation boxes. * src/setup.c (int_options): Add support for user configurable confirmation of directory hotlist entries removal. * src/boxes.c (conf_widgets): Likewise. (confirm_box): Likewise. (my_directory_hotlist_delete): New module variable. --- ChangeLog | 6 ++++++ doc/mc.1.in | 11 ++++++----- src/ChangeLog | 21 +++++++++++++++++++++ src/boxes.c | 7 ++++++- src/file.c | 3 --- src/file.h | 2 -- src/hotlist.c | 25 +++++++++++++++++++++++-- src/main.c | 6 ++++++ src/main.h | 2 ++ src/setup.c | 1 + 10 files changed, 71 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f17a5dba1..e83308751 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-29 Pavel Tsekov + + * doc/mc.1.in: Update the documentation to reflect the fact + that confirmation may be requested when deleting directory + hotlist entries based on a user configurable setting. + 2006-01-29 Julian Mehnle * doc/mc.1.in: Document support for VIEWER environment variable. diff --git a/doc/mc.1.in b/doc/mc.1.in index 913cd3eaf..a8d79bfa1 100644 --- a/doc/mc.1.in +++ b/doc/mc.1.in @@ -1731,10 +1731,10 @@ through a link will move you to the current directory's real parent and not to the directory where the link was present. .PP .I Safe delete. -If this option is enabled, deleting files unintentionally becomes more -difficult. The default selection in the confirmation dialogs for -deletion changes from "Yes" to "No". This option is disabled by -default. +If this option is enabled, deleting files and directory hotlist entries +unintentionally becomes more difficult. The default selection in the +confirmation dialogs for deletion changes from "Yes" to "No". +This option is disabled by default. .\"NODE " Layout" .SH " Layout" The layout dialog gives you a possibility to change the general layout @@ -1783,7 +1783,8 @@ option. .\"NODE " Confirmation" .SH " Confirmation" In this menu you configure the confirmation options for file deletion, -overwriting, execution by pressing enter and quitting the program. +directory hotlist entries deletion, overwriting, execution by pressing +enter and quitting the program. .\"NODE " Display bits" .SH " Display bits" This is used to configure the range of visible characters on the diff --git a/src/ChangeLog b/src/ChangeLog index c96526c12..9a390c0e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2006-01-29 Pavel Tsekov + + * file.h (safe_delete): Move declaration of `safe_delete' + * main.h: ... here. + (confirm_directory_hotlist_delete): Declare new global variable. + * file.c (safe_delete): Move definition of `safe_delete' + * main.c: ... here. + (confirm_directory_hotlist_delete): Define new global variable. + * hotlist.c (remove_from_hotlist): Based on a user configurable + setting, request confirmation when removing directory hotlist + entries. The confirmation dialog honours the `Safe delete' + setting. + Reorder the buttons in the hotlist group removal confirmation + dialog so that it becomes consistent with other confirmation + boxes. + * setup.c (int_options): Add support for user configurable + confirmation of directory hotlist entries removal. + * boxes.c (conf_widgets): Likewise. + (confirm_box): Likewise. + (my_directory_hotlist_delete): New module variable. + 2006-01-29 Pavel Tsekov * dir.c (do_sort): Do not try to reorder the entries so diff --git a/src/boxes.c b/src/boxes.c index 6066cedce..e7158d2e6 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -361,10 +361,11 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive) return result; } -#define CONFY 10 +#define CONFY 11 #define CONFX 46 static int my_delete; +static int my_directory_hotlist_delete; static int my_overwrite; static int my_execute; static int my_exit; @@ -375,6 +376,8 @@ static QuickWidget conf_widgets [] = { { quick_button, 4, 6, 3, CONFY, N_("&OK"), 0, B_ENTER, 0, 0, "o" }, +{ quick_checkbox, 1, 13, 7, CONFY, N_(" confirm di&Rectory hotlist delete "), + 11, 0, &my_directory_hotlist_delete, NULL, NULL }, { quick_checkbox, 1, 13, 6, CONFY, N_(" confirm &Exit "), 9, 0, &my_exit, 0, "e" }, { quick_checkbox, 1, 13, 5, CONFY, N_(" confirm e&Xecute "), @@ -440,12 +443,14 @@ confirm_box (void) my_overwrite = confirm_overwrite; my_execute = confirm_execute; my_exit = confirm_exit; + my_directory_hotlist_delete = confirm_directory_hotlist_delete; if (quick_dialog (&confirmation) != B_CANCEL){ confirm_delete = my_delete; confirm_overwrite = my_overwrite; confirm_execute = my_execute; confirm_exit = my_exit; + confirm_directory_hotlist_delete = my_directory_hotlist_delete; } } diff --git a/src/file.c b/src/file.c index 244c60cd0..f7e203561 100644 --- a/src/file.c +++ b/src/file.c @@ -86,9 +86,6 @@ int verbose = 1; */ int file_op_compute_totals = 1; -/* If on, default for "No" in delete operations */ -int safe_delete = 0; - /* This is a hard link cache */ struct link { struct link *next; diff --git a/src/file.h b/src/file.h index d61832377..97c38cf1e 100644 --- a/src/file.h +++ b/src/file.h @@ -3,8 +3,6 @@ #include "fileopctx.h" -extern int safe_delete; - struct link; int copy_file_file (FileOpContext *ctx, const char *s, const char *d, diff --git a/src/hotlist.c b/src/hotlist.c index 2e896386f..f986610dd 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -1054,6 +1054,27 @@ static void remove_group (struct hotlist *grp) static void remove_from_hotlist (struct hotlist *entry) { + if (confirm_directory_hotlist_delete) { + char *title; + int result; + + title = g_strconcat (N_(" Remove: "), + name_trunc (entry->label, 30), + " ", + NULL); + + if (safe_delete) + query_set_sel (1); + result = query_dialog (title, + _("\n Are you sure you want to remove this entry?"), + D_ERROR, 2, N_("&Yes"), N_("&No")); + + g_free (title); + + if (result == 1) + return; + } + if (entry->type == HL_TYPE_GROUP) { if (entry->head) { char *header; @@ -1065,10 +1086,10 @@ static void remove_from_hotlist (struct hotlist *entry) NULL); result = query_dialog (header, _("\n Group not empty.\n Remove it?"), D_ERROR, 2, - _("&No"), _("&Yes")); + _("&Yes"), _("&No")); g_free (header); - if (result != 1) + if (result == 1) return; } diff --git a/src/main.c b/src/main.c index 5a9bd0759..6812c616c 100644 --- a/src/main.c +++ b/src/main.c @@ -195,12 +195,18 @@ Mouse_Type use_mouse_p = MOUSE_NONE; /* If true, assume we are running on an xterm terminal */ static int force_xterm = 0; +/* If on, default for "No" in delete operations */ +int safe_delete = 0; + /* Controls screen clearing before an exec */ int clear_before_exec = 1; /* Asks for confirmation before deleting a file */ int confirm_delete = 1; +/* Asks for confirmation before deleting a hotlist entry */ +int confirm_directory_hotlist_delete = 1; + /* Asks for confirmation before overwriting a file */ int confirm_overwrite = 1; diff --git a/src/main.h b/src/main.h index 64631cd02..b023492c5 100644 --- a/src/main.h +++ b/src/main.h @@ -55,7 +55,9 @@ extern int cd_symlinks; extern int show_all_if_ambiguous; extern int slow_terminal; extern int update_prompt; /* To comunicate with subshell */ +extern int safe_delete; extern int confirm_delete; +extern int confirm_directory_hotlist_delete; extern int confirm_execute; extern int confirm_exit; extern int confirm_overwrite; diff --git a/src/setup.c b/src/setup.c index cf19aa751..a30d8ead3 100644 --- a/src/setup.c +++ b/src/setup.c @@ -158,6 +158,7 @@ static const struct { { "confirm_overwrite", &confirm_overwrite }, { "confirm_execute", &confirm_execute }, { "confirm_exit", &confirm_exit }, + { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete }, { "safe_delete", &safe_delete }, { "mouse_repeat_rate", &mou_auto_repeat }, { "double_click_speed", &double_click_speed },