[Monodevelop-patches-list] r2572 - in trunk/MonoDevelop/Core/src: MonoDevelop.Base MonoDevelop.Base/Gui/Workbench/Layouts MonoDevelop.Base/Services MonoDevelop.Core MonoDevelop.Core/Services

Jacob Ilsø Christensen <jacobilsoe@gmail.com> jacobilsoe at mono-cvs.ximian.com
Wed Jun 1 09:41:24 EDT 2005


Author: jacobilsoe
Date: 2005-06-01 09:41:24 -0400 (Wed, 01 Jun 2005)
New Revision: 2572

Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/MessageService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Core/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Core/Services/IMessageService.cs
Log:
Added a cancel option when trying to close a modified file

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-06-01 13:35:49 UTC (rev 2571)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-06-01 13:41:24 UTC (rev 2572)
@@ -1,5 +1,12 @@
 2005-06-01  Jacob Ilsø Christensen  <jacobilsoe at gmail.com>
 
+	* Services/MessageService.cs: Added methods to ask a question
+	with a cancel option.
+	* Gui/Workbench/Layouts/SdiWorkspaceWindow.cs: Added a cancel
+	option when trying to close a modified file.
+
+2005-06-01  Jacob Ilsø Christensen  <jacobilsoe at gmail.com>
+
 	* Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs:
 	* Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs:
 	* Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs:

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2005-06-01 13:35:49 UTC (rev 2571)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2005-06-01 13:41:24 UTC (rev 2572)
@@ -209,9 +209,13 @@
 		{
 			if (!force && ViewContent != null && ViewContent.IsDirty) {
 				
-				bool save = Runtime.MessageService.AskQuestion (GettextCatalog.GetString ("Do you want to save the current changes"));
+				QuestionResponse response = Runtime.MessageService.AskQuestionWithCancel (GettextCatalog.GetString ("Do you want to save the current changes"));
 				
-				if (save) {
+				if (response == QuestionResponse.Cancel) {
+					return;
+				}
+
+				if (response == QuestionResponse.Yes) {
 					if (content.ContentName == null) {
 						while (true) {
 							Runtime.FileService.SaveFileAs (this);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/MessageService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/MessageService.cs	2005-06-01 13:35:49 UTC (rev 2571)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/MessageService.cs	2005-06-01 13:41:24 UTC (rev 2572)
@@ -116,7 +116,50 @@
 		{
 			return AskQuestion(stringParserService.Parse(question), GettextCatalog.GetString ("Question"));
 		}
+
+		public QuestionResponse AskQuestionWithCancel(string question, string caption)
+		{
+			using (Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Question, Gtk.ButtonsType.None, question)) {
+				
+				md.AddActionWidget (new Button (Gtk.Stock.No), ResponseType.No);
+				md.AddActionWidget (new Button (Gtk.Stock.Cancel), ResponseType.Cancel);
+				md.AddActionWidget (new Button (Gtk.Stock.Yes), ResponseType.Yes);
+				md.ActionArea.ShowAll ();
+				
+				Gtk.ResponseType response = (Gtk.ResponseType)md.Run ();
+				md.Hide ();
+
+				if (response == Gtk.ResponseType.Yes) {
+					return QuestionResponse.Yes;
+				}
+
+				if (response == Gtk.ResponseType.No) {
+					return QuestionResponse.No;
+				}
+
+				if (response == Gtk.ResponseType.Cancel) {
+					return QuestionResponse.Cancel;
+				}
+
+				return QuestionResponse.Cancel;
+			}
+		}
 		
+		public QuestionResponse AskQuestionFormattedWithCancel(string caption, string formatstring, params string[] formatitems)
+		{
+			return AskQuestionWithCancel(String.Format(stringParserService.Parse(formatstring), formatitems), caption);
+		}
+		
+		public QuestionResponse AskQuestionFormattedWithCancel(string formatstring, params string[] formatitems)
+		{
+			return AskQuestionWithCancel(String.Format(stringParserService.Parse(formatstring), formatitems));
+		}
+		
+		public QuestionResponse AskQuestionWithCancel(string question)
+		{
+			return AskQuestionWithCancel(stringParserService.Parse(question), GettextCatalog.GetString ("Question"));
+		}
+		
 		public int ShowCustomDialog(string caption, string dialogText, params string[] buttontexts)
 		{
 			// TODO

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Core/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Core/ChangeLog	2005-06-01 13:35:49 UTC (rev 2571)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Core/ChangeLog	2005-06-01 13:41:24 UTC (rev 2572)
@@ -1,3 +1,8 @@
+2005-06-01  Jacob Ilsø Christensen  <jacobilsoe at gmail.com>
+
+	* Services/IMessageService.cs: Added methods to ask a question
+	with a cancel option.
+
 2005-04-25  Lluis Sanchez Gual  <lluis at novell.com>
 
 	* AddIns/AddIn.cs: Added GetType method.

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Core/Services/IMessageService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Core/Services/IMessageService.cs	2005-06-01 13:35:49 UTC (rev 2571)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Core/Services/IMessageService.cs	2005-06-01 13:41:24 UTC (rev 2572)
@@ -12,6 +12,13 @@
 
 namespace MonoDevelop.Core.Services
 {
+	public enum QuestionResponse
+	{
+		Yes,
+		No,
+		Cancel
+	}
+	
 	/// <summary>
 	/// This interface must be implemented by all services.
 	/// </summary>
@@ -41,6 +48,11 @@
 		bool AskQuestionFormatted(string formatstring, params string[] formatitems);
 		bool AskQuestion(string question, string caption);
 		bool AskQuestionFormatted(string caption, string formatstring, params string[] formatitems);
+
+		QuestionResponse AskQuestionWithCancel(string question);
+		QuestionResponse AskQuestionFormattedWithCancel(string formatstring, params string[] formatitems);
+		QuestionResponse AskQuestionWithCancel(string question, string caption);
+		QuestionResponse AskQuestionFormattedWithCancel(string caption, string formatstring, params string[] formatitems);
 		
 		// used to return text input from a user in response to a question
 		string GetTextResponse(string question, string caption, string initialValue);




More information about the Monodevelop-patches-list mailing list