[mistelix] Fixes related issues #582397, #583064, #584473, #584492 and handles exceptions when saving files



commit 9eb8b94c75848292297284d6f853348ca5f1e3a8
Author: Jordi Mas <jmas softcatala org>
Date:   Tue Jun 30 08:39:29 2009 +0200

    Fixes related issues #582397, #583064, #584473, #584492 and handles exceptions when saving files

 src/mistelix.cs    |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 src/mistelix.glade |   36 ++++++++++++++++++++++++++++++------
 2 files changed, 75 insertions(+), 11 deletions(-)
---
diff --git a/src/mistelix.cs b/src/mistelix.cs
index b89719c..ab5b3df 100644
--- a/src/mistelix.cs
+++ b/src/mistelix.cs
@@ -29,6 +29,7 @@ using System.Runtime.InteropServices;
 using System.Text;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using Mono.Unix;
 using Mono.Addins;
 using Mono.Addins.Setup;
@@ -408,7 +409,7 @@ namespace Mistelix
 		{
 			Logger.Debug ("Mistelix.OnSaveProject. Filename {0}", project.Details.Filename);
 			if (project.Details.Filename != null) {
-				project.Save (project.Details.Filename);
+				Save (project.Details.Filename);
 				return;
 			}
 
@@ -427,13 +428,52 @@ namespace Mistelix
 			chooser_dialog.DefaultResponse = ResponseType.Ok;
 			chooser_dialog.LocalOnly = true;
 
-			if(chooser_dialog.Run () == (int) ResponseType.Ok) {
-				Logger.Debug ("Mistelix.OnSaveProject. Selected file {0}", chooser_dialog.Uri);
-				project.Save (chooser_dialog.Filename);
+			while (true) {
+				if (chooser_dialog.Run () == (int) ResponseType.Ok) {
+					Logger.Debug ("Mistelix.OnSaveProject. Selected file {0}", chooser_dialog.Uri);
+					if (File.Exists (chooser_dialog.Filename) == true) {
+						String msg;
+
+						msg = Catalog.GetString ("The file already exist. Do you want to overwrite it?");
+						MessageDialog md = new MessageDialog (app_window,
+						      	DialogFlags.Modal, MessageType.Warning,
+						      	ButtonsType.YesNo, msg);
+
+						ResponseType result = (ResponseType)md.Run ();
+						md.Destroy ();
+
+						if (result != ResponseType.Yes)
+							continue;
+					}
+					Save (chooser_dialog.Filename);
+					break;
+				}
+				else 
+					break;
 			}
-
 			chooser_dialog.Destroy ();
 		}
+
+		void Save (string filename)
+		{
+			try 
+			{
+				project.Save (filename);
+				return;
+			} 
+			catch (Exception e)
+			{
+				String msg;
+
+				msg = String.Format (Catalog.GetString ("An error has occurred when saving the file.\nError: '{0}'"), e.Message);
+				MessageDialog md = new MessageDialog (app_window,
+		                      	DialogFlags.Modal, MessageType.Warning,
+		                      	ButtonsType.Ok, msg);
+
+				md.Run ();
+				md.Destroy ();
+			}
+		}
 		
 		void OnViewSafeArea (object sender, EventArgs args)
 		{
diff --git a/src/mistelix.glade b/src/mistelix.glade
index ffe06c5..da8d64a 100644
--- a/src/mistelix.glade
+++ b/src/mistelix.glade
@@ -49,7 +49,7 @@
 		      <signal name="activate" handler="OnNewProject" last_modification_time="Sat, 11 Oct 2008 15:55:34 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image29">
+			<widget class="GtkImage" id="image33">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-new</property>
 			  <property name="icon_size">1</property>
@@ -70,7 +70,7 @@
 		      <signal name="activate" handler="OnOpenProject" last_modification_time="Sat, 11 Oct 2008 15:55:34 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image30">
+			<widget class="GtkImage" id="image34">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-open</property>
 			  <property name="icon_size">1</property>
@@ -84,20 +84,44 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkMenuItem" id="save_project">
+		    <widget class="GtkImageMenuItem" id="save_project">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">_Save Project</property>
 		      <property name="use_underline">True</property>
 		      <signal name="activate" handler="OnSaveProject" last_modification_time="Sat, 11 Oct 2008 15:55:34 GMT"/>
+
+		      <child internal-child="image">
+			<widget class="GtkImage" id="image35">
+			  <property name="visible">True</property>
+			  <property name="stock">gtk-save</property>
+			  <property name="icon_size">1</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+		      </child>
 		    </widget>
 		  </child>
 
 		  <child>
 		    <widget class="GtkImageMenuItem" id="save_as">
 		      <property name="visible">True</property>
-		      <property name="label">gtk-save-as</property>
-		      <property name="use_stock">True</property>
-		      <signal name="activate" handler="OnSaveAs" last_modification_time="Sat, 11 Oct 2008 15:55:34 GMT"/>
+		      <property name="label" translatable="yes">Save _As Project...</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="OnSaveAs" last_modification_time="Tue, 30 Jun 2009 05:18:51 GMT"/>
+
+		      <child internal-child="image">
+			<widget class="GtkImage" id="image36">
+			  <property name="visible">True</property>
+			  <property name="stock">gtk-save-as</property>
+			  <property name="icon_size">1</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+		      </child>
 		    </widget>
 		  </child>
 



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