f-spot r3795 - in trunk: . src



Author: sdelcroix
Date: Fri Mar 28 09:49:07 2008
New Revision: 3795
URL: http://svn.gnome.org/viewvc/f-spot?rev=3795&view=rev

Log:
2008-03-28  Lorenzo Milesi <maxxer yetopen it>

	* src/PhotoView.cs: Add constraint "Same as photo". Fix	bgo#399302.
	Reordered constraint menu: no constraint first, then custom user
	constraints and default constraints in the end.


Modified:
   trunk/ChangeLog
   trunk/src/PhotoView.cs

Modified: trunk/src/PhotoView.cs
==============================================================================
--- trunk/src/PhotoView.cs	(original)
+++ trunk/src/PhotoView.cs	Fri Mar 28 09:49:07 2008
@@ -65,8 +65,12 @@
 	
 		private List<SelectionRatioDialog.SelectionConstraint> custom_constraints;
 	
+		private const double NO_CONSTRAINT = 0.0;
+		private const double CUSTOM_CONSTRAINT = -1.0;
+		private const double SAME_AS_PHOTO = -2.0;
+
 		private static SelectionRatioDialog.SelectionConstraint [] default_constraints = {
-			new SelectionRatioDialog.SelectionConstraint (Catalog.GetString ("No Constraint"), 0.0),
+			new SelectionRatioDialog.SelectionConstraint (Catalog.GetString ("Same as photo"), SAME_AS_PHOTO),
 			new SelectionRatioDialog.SelectionConstraint (Catalog.GetString ("4 x 3 (Book)"), 4.0 / 3.0),
 			new SelectionRatioDialog.SelectionConstraint (Catalog.GetString ("4 x 6 (Postcard)"), 6.0 / 4.0),
 			new SelectionRatioDialog.SelectionConstraint (Catalog.GetString ("5 x 7 (L, 2L)"), 7.0 / 5.0),
@@ -82,7 +86,6 @@
 			get { return photo_view.Item; }
 		}
 	
-	
 		private IBrowsableCollection query;
 		public IBrowsableCollection Query {
 			get { return query; }
@@ -183,6 +186,11 @@
 			UpdateCountLabel ();
 			UpdateDescriptionEntry ();
 			UpdateRating ();
+			// If the selected constraint is "Same as photo" reset to "No Constraint"
+			TreeIter iter;
+			if (constraints_combo.GetActiveIter (out iter) && (double)constraints_store.GetValue(iter, 2) == SAME_AS_PHOTO) 
+				constraints_combo.Active = 0;
+			
 	
 			if (UpdateFinished != null)
 				UpdateFinished (this);
@@ -225,7 +233,6 @@
 			View.Item.MovePrevious ();
 		}
 	
-	
 		private void HandleRedEyeButtonClicked (object sender, EventArgs args)
 		{
 			ProcessImage (true);
@@ -607,11 +614,12 @@
 		{
 			constraints_store = new TreeStore (typeof (string), typeof (string), typeof (double));
 			constraints_combo.Model = constraints_store;
-			foreach (SelectionRatioDialog.SelectionConstraint constraint in default_constraints)
-				constraints_store.AppendValues (null, constraint.Label, constraint.XyRatio);
+			constraints_store.AppendValues (null, "No Constraint", NO_CONSTRAINT);
 			foreach (SelectionRatioDialog.SelectionConstraint constraint in custom_constraints)
 				constraints_store.AppendValues (null, constraint.Label, constraint.XyRatio);
-			constraints_store.AppendValues (Stock.Edit, Catalog.GetString ("Custom Ratios..."), -1.0);
+			foreach (SelectionRatioDialog.SelectionConstraint constraint in default_constraints)
+				constraints_store.AppendValues (null, constraint.Label, constraint.XyRatio);
+			constraints_store.AppendValues (Stock.Edit, Catalog.GetString ("Custom Ratios..."), CUSTOM_CONSTRAINT);
 			constraints_combo.Active = 0;
 		}
 
@@ -637,9 +645,12 @@
 				double ratio = ((double)constraints_store.GetValue(iter, 2));
 				if (ratio >= 0.0)
 					photo_view.SelectionXyRatio = ratio;
-				else {
+				else if (ratio == CUSTOM_CONSTRAINT) {
 					SelectionRatioDialog dialog = new SelectionRatioDialog ();
 					dialog.Dialog.Run ();
+				} else if (ratio == SAME_AS_PHOTO) {
+					Pixbuf pb = photo_view.CompletePixbuf ();
+					photo_view.SelectionXyRatio = (double)pb.Width / (double)pb.Height;
 				}
 			}	
 		}



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