f-spot r3801 - in trunk: . src src/UI.Dialog



Author: sdelcroix
Date: Mon Mar 31 10:40:39 2008
New Revision: 3801
URL: http://svn.gnome.org/viewvc/f-spot?rev=3801&view=rev

Log:
2008-03-31  Stephane Delcroix  <sdelcroix novell com>

	* src/Preferences.cs:
	* src/UI.Dialog/SelectionRatioDialog.cs:
	* src/PhotoView.cs: handle edge cases and olg gconf bindings in storing
	crop ratios to gconf. Sould fix bgo #525164.


Modified:
   trunk/ChangeLog
   trunk/src/PhotoView.cs
   trunk/src/Preferences.cs
   trunk/src/UI.Dialog/SelectionRatioDialog.cs

Modified: trunk/src/PhotoView.cs
==============================================================================
--- trunk/src/PhotoView.cs	(original)
+++ trunk/src/PhotoView.cs	Mon Mar 31 10:40:39 2008
@@ -592,15 +592,13 @@
 		{
 			object val = Preferences.Get (key);
 	
-			if (val == null)
-				return;
-	
 			switch (key) {
 			case Preferences.CUSTOM_CROP_RATIOS:
 				custom_constraints = new List<SelectionRatioDialog.SelectionConstraint> ();
-				XmlSerializer serializer = new XmlSerializer (typeof(SelectionRatioDialog.SelectionConstraint));
-				foreach (string xml in val as string[]) {
-					custom_constraints.Add ((SelectionRatioDialog.SelectionConstraint)serializer.Deserialize (new StringReader (xml)));
+				if (val != null && val is string[]) {
+					XmlSerializer serializer = new XmlSerializer (typeof(SelectionRatioDialog.SelectionConstraint));
+					foreach (string xml in val as string[])
+						custom_constraints.Add ((SelectionRatioDialog.SelectionConstraint)serializer.Deserialize (new StringReader (xml)));
 				}
 				PopulateConstraints ();
 				break;

Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs	(original)
+++ trunk/src/Preferences.cs	Mon Mar 31 10:40:39 2008
@@ -201,8 +201,6 @@
 			case PROXY_USER:
 			case PROXY_PASSWORD:
 				return String.Empty;
-			case CUSTOM_CROP_RATIOS:
-				return new string [] {};
 			default:
 				return null;
 			}

Modified: trunk/src/UI.Dialog/SelectionRatioDialog.cs
==============================================================================
--- trunk/src/UI.Dialog/SelectionRatioDialog.cs	(original)
+++ trunk/src/UI.Dialog/SelectionRatioDialog.cs	Mon Mar 31 10:40:39 2008
@@ -72,10 +72,12 @@
 			constraints_store = new ListStore (typeof (string), typeof (double));
 			content_treeview.Model = constraints_store;
 			XmlSerializer serializer = new XmlSerializer (typeof(SelectionConstraint));
-			foreach (string xml in Preferences.Get (Preferences.CUSTOM_CROP_RATIOS) as string[]) {
-				SelectionConstraint constraint = (SelectionConstraint)serializer.Deserialize (new StringReader (xml));
-				constraints_store.AppendValues (constraint.Label, constraint.XyRatio);
-			}	
+			string [] vals = Preferences.Get (Preferences.CUSTOM_CROP_RATIOS) as string[];
+			if (vals != null) 
+				foreach (string xml in vals) {
+					SelectionConstraint constraint = (SelectionConstraint)serializer.Deserialize (new StringReader (xml));
+					constraints_store.AppendValues (constraint.Label, constraint.XyRatio);
+				}	
 		}
 
 		private void OnPreferencesChanged (object sender, NotifyEventArgs args)
@@ -87,9 +89,6 @@
 		{
 			object val = Preferences.Get (key);
 	
-			if (val == null)
-				return;
-	
 			switch (key) {
 			case Preferences.CUSTOM_CROP_RATIOS:
 				Populate ();
@@ -106,8 +105,16 @@
 				serializer.Serialize (sw, new SelectionConstraint ((string)row[0], (double)row[1]));
 				sw.Close ();
 				prefs.Add (sw.ToString ());
-				Preferences.Set (Preferences.CUSTOM_CROP_RATIOS, prefs.ToArray());
 			}
+
+#if !GCONF_SHARP_2_18		
+			if (prefs.Count != 0)
+#endif
+				Preferences.Set (Preferences.CUSTOM_CROP_RATIOS, prefs.ToArray());
+#if !GCONF_SHARP_2_18		
+			else
+				Preferences.Set (Preferences.CUSTOM_CROP_RATIOS, -1);
+#endif
 		}
 
 		public void HandleLabelEdited (object sender, EditedArgs args)



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