[tomboy] Add hidden preference for disabling delete confirmation dialog



commit f11c053746c356b5d75fd327d3b2a8e403614f86
Author: Jeff Stoner <jeff jeffstoner com>
Date:   Mon Jun 7 14:28:02 2010 -0700

    Add hidden preference for disabling delete confirmation dialog
    
    If this is a popular enough feature, we should expose it in
    the UI of both the dialog and the Preferences.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=585040

 Tomboy/Note.cs         |   68 ++++++++++++++++++++++++++---------------------
 Tomboy/Preferences.cs  |    4 +++
 data/tomboy.schemas.in |   14 ++++++++++
 3 files changed, 56 insertions(+), 30 deletions(-)
---
diff --git a/Tomboy/Note.cs b/Tomboy/Note.cs
index 317c312..bda7823 100644
--- a/Tomboy/Note.cs
+++ b/Tomboy/Note.cs
@@ -1561,46 +1561,54 @@ namespace Tomboy
 		public static void ShowDeletionDialog (List<Note> notes, Gtk.Window parent)
 		{
 			string message;
+
+			if ((bool) Preferences.Get (Preferences.ENABLE_DELETE_CONFIRM)) {
+				// show confirmation dialog
+				if (notes.Count == 1)
+					message = Catalog.GetString ("Really delete this note?");
+				else
+					message = string.Format (Catalog.GetPluralString (
+						"Really delete this {0} note?",
+						"Really delete these {0} notes?",
+						notes.Count), notes.Count);
 			
-			if (notes.Count == 1)
-				message = Catalog.GetString ("Really delete this note?");
-			else
-				message = string.Format (Catalog.GetPluralString (
-					"Really delete this {0} note?",
-					"Really delete these {0} notes?",
-					notes.Count), notes.Count);
-			
-			HIGMessageDialog dialog =
-			        new HIGMessageDialog (
-			        parent,
-			        Gtk.DialogFlags.DestroyWithParent,
-			        Gtk.MessageType.Question,
-			        Gtk.ButtonsType.None,
-			        message,
-			        Catalog.GetString ("If you delete a note it is " +
+				HIGMessageDialog dialog =
+				        new HIGMessageDialog (
+				        parent,
+				        Gtk.DialogFlags.DestroyWithParent,
+				        Gtk.MessageType.Question,
+				        Gtk.ButtonsType.None,
+				        message,
+				        Catalog.GetString ("If you delete a note it is " +
 			                           "permanently lost."));
 
-			Gtk.Button button;
+				Gtk.Button button;
 
-			button = new Gtk.Button (Gtk.Stock.Cancel);
-			button.CanDefault = true;
-			button.Show ();
-			dialog.AddActionWidget (button, Gtk.ResponseType.Cancel);
-			dialog.DefaultResponse = Gtk.ResponseType.Cancel;
+				button = new Gtk.Button (Gtk.Stock.Cancel);
+				button.CanDefault = true;
+				button.Show ();
+				dialog.AddActionWidget (button, Gtk.ResponseType.Cancel);
+				dialog.DefaultResponse = Gtk.ResponseType.Cancel;
 
-			button = new Gtk.Button (Gtk.Stock.Delete);
-			button.CanDefault = true;
-			button.Show ();
-			dialog.AddActionWidget (button, 666);
+				button = new Gtk.Button (Gtk.Stock.Delete);
+				button.CanDefault = true;
+				button.Show ();
+				dialog.AddActionWidget (button, 666);
 
-			int result = dialog.Run ();
-			if (result == 666) {
+				int result = dialog.Run ();
+				if (result == 666) {
+					foreach (Note note in notes) {
+						note.Manager.Delete (note);
+					}
+				}
+
+				dialog.Destroy();
+			} else {
+				// no confirmation dialog, just delete
 				foreach (Note note in notes) {
 					note.Manager.Delete (note);
 				}
 			}
-
-			dialog.Destroy();
 		}
 		
 		public static void ShowIOErrorDialog (Gtk.Window parent)
diff --git a/Tomboy/Preferences.cs b/Tomboy/Preferences.cs
index ab1996c..a13ca1d 100644
--- a/Tomboy/Preferences.cs
+++ b/Tomboy/Preferences.cs
@@ -15,6 +15,7 @@ namespace Tomboy
 		public const string ENABLE_AUTO_BULLETED_LISTS = "/apps/tomboy/enable_bulleted_lists";
 		public const string ENABLE_ICON_PASTE = "/apps/tomboy/enable_icon_paste";
 		public const string ENABLE_CLOSE_NOTE_ON_ESCAPE = "/apps/tomboy/enable_close_note_on_escape";
+		public const string ENABLE_DELETE_CONFIRM = "/apps/tomboy/enable_delete_confirm";
 
 		public const string START_NOTE_URI = "/apps/tomboy/start_note";
 		public const string CUSTOM_FONT_FACE = "/apps/tomboy/custom_font_face";
@@ -86,6 +87,9 @@ namespace Tomboy
 			case ENABLE_CLOSE_NOTE_ON_ESCAPE:
 				return true;
 
+			case ENABLE_DELETE_CONFIRM:
+				return true;
+
 			case START_NOTE_URI:
 				return String.Empty;
 
diff --git a/data/tomboy.schemas.in b/data/tomboy.schemas.in
index 2692923..b2ce1d0 100644
--- a/data/tomboy.schemas.in
+++ b/data/tomboy.schemas.in
@@ -107,6 +107,20 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/tomboy/enable_delete_confirm</key>
+      <applyto>/apps/tomboy/enable_delete_confirm</applyto>
+      <owner>tomboy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Enable the Delete Note confirmation dialog</short>
+         <long>
+	  If disabled, the "Delete Note" confirmation dialog will be suppressed.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/tomboy/start_note</key>
       <applyto>/apps/tomboy/start_note</applyto>
       <owner>tomboy</owner>



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