f-spot r3756 - in trunk: . src



Author: thomasvm
Date: Thu Mar 13 20:28:43 2008
New Revision: 3756
URL: http://svn.gnome.org/viewvc/f-spot?rev=3756&view=rev

Log:
2008-03-13  Thomas Van Machelen <thomas vamachelen gmail com>

	* configure.in:
	* src/ControlOverlay.cs:
	* src/Loupe.cs: Only require Mono.Cairo 1.2.4 and use higher if
	available


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/ControlOverlay.cs
   trunk/src/Loupe.cs

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Mar 13 20:28:43 2008
@@ -64,7 +64,7 @@
 BEAGLE_REQUIRED=0.3.0
 NDESK_DBUS_REQUIRED=0.4.2
 NDESK_DBUS_GLIB_REQUIRED=0.3.0
-MONO_CAIRO_REQUIRED=1.2.5
+MONO_CAIRO_REQUIRED=1.2.4
 dnl -- this check is 	
 LCMS_REQUIRED=1.12
 dnl -- LIBGPHOTO2_REQUIRED=2.1.4
@@ -94,7 +94,9 @@
    CSC_DEFINES="$CSC_DEFINES -d:MONO_2_0"
 fi
 
-
+if pkg-config --atleast-version=1.2.5 mono-cairo; then
+   CSC_DEFINES="$CSC_DEFINES -d:CAIRO_1_2_5"
+fi
 
 dnl - Choose PreferenceBackend (default to gconf)
 AC_ARG_ENABLE([gconf],[AC_HELP_STRING([--disable-gconf], [build without gconf preference backend])],,)

Modified: trunk/src/ControlOverlay.cs
==============================================================================
--- trunk/src/ControlOverlay.cs	(original)
+++ trunk/src/ControlOverlay.cs	Thu Mar 13 20:28:43 2008
@@ -8,7 +8,11 @@
  *
  * See COPYING for license information.
  */
-extern alias MCairo;
+#if CAIRO_1_2_5
+	extern alias MCairo;
+#else
+	using Cairo;
+#endif		
 
 using System;
 using Gtk;
@@ -130,17 +134,29 @@
 			Visibility = VisibilityType.None;
 			return false;
 		}
-		
+#if CAIRO_1_2_5		
 		protected virtual void ShapeSurface (MCairo::Cairo.Context cr, MCairo::Cairo.Color color)
 		{
 			cr.Operator = MCairo::Cairo.Operator.Source;
 			MCairo::Cairo.Pattern p = new MCairo::Cairo.SolidPattern (new MCairo::Cairo.Color (0, 0, 0, 0));
+#else
+		protected virtual void ShapeSurface (Context cr, Cairo.Color color)
+		{
+			cr.Operator = Operator.Source;
+			Cairo.Pattern p = new Cairo.SolidPattern (new Cairo.Color (0, 0, 0, 0));
+#endif						
 			cr.Source = p;
 			p.Destroy ();
 			cr.Paint ();
+#if CAIRO_1_2_5			
 			cr.Operator = MCairo::Cairo.Operator.Over;
 
 			MCairo::Cairo.Pattern r = new MCairo::Cairo.SolidPattern (color);
+#else
+			cr.Operator = Operator.Over;
+
+			Cairo.Pattern r = new SolidPattern (color);
+#endif						
 			cr.Source = r;
 			r.Destroy ();
 			cr.MoveTo (round, 0);
@@ -174,10 +190,17 @@
 			Gdk.Pixmap bitmap = new Gdk.Pixmap (GdkWindow, 
 							    Allocation.Width, 
 							    Allocation.Height, 1);
-			
+
+#if CAIRO_1_2_5			
 			MCairo::Cairo.Context cr = Gdk.CairoHelper.Create (bitmap);
 			ShapeCombineMask (bitmap, 0, 0);
 			ShapeSurface (cr, new MCairo::Cairo.Color (1, 1, 1));
+#else			
+			Context cr = CairoUtils.CreateContext (bitmap);
+			ShapeCombineMask (bitmap, 0, 0);
+			ShapeSurface (cr, new Cairo.Color (1, 1, 1));
+
+#endif			
 			ShapeCombineMask (bitmap, 0, 0);
 			((IDisposable)cr).Dispose ();
 			bitmap.Dispose ();
@@ -187,12 +210,22 @@
 		protected override bool OnExposeEvent (Gdk.EventExpose args)
 		{
 			Gdk.Color c = Style.Background (State);
+#if CAIRO_1_2_5			
 			MCairo::Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow);
 
 			ShapeSurface (cr, new MCairo::Cairo.Color (c.Red / (double) ushort.MaxValue,
 							   c.Blue / (double) ushort.MaxValue, 
 							   c.Green / (double) ushort.MaxValue,
 							   0.8));
+#else
+			Cairo.Context cr = CairoUtils.CreateContext (GdkWindow);
+
+			ShapeSurface (cr, new Cairo.Color (c.Red / (double) ushort.MaxValue,
+							   c.Blue / (double) ushort.MaxValue, 
+							   c.Green / (double) ushort.MaxValue,
+							   0.8));
+			
+#endif						
 
 			((IDisposable)cr).Dispose ();
 			return base.OnExposeEvent (args);

Modified: trunk/src/Loupe.cs
==============================================================================
--- trunk/src/Loupe.cs	(original)
+++ trunk/src/Loupe.cs	Thu Mar 13 20:28:43 2008
@@ -1,4 +1,9 @@
+#if CAIRO_1_2_5
 extern alias MCairo;
+#else
+using Cairo;
+#endif
+
 using Gtk;
 using Gdk;
 using System;
@@ -303,14 +308,23 @@
 							    Allocation.Width, 
 							    Allocation.Height, 1);
 			
+#if CAIRO_1_2_5
 			MCairo::Cairo.Context g = CairoHelper.Create (bitmap);
+#else			
+			Context g = CairoUtils.CreateContext (bitmap);
+#endif			
 			DrawShape (g, Allocation.Width, Allocation.Height);
+			
 			((IDisposable)g).Dispose ();
 
 			if (use_shape_ext)
 				ShapeCombineMask (bitmap, 0, 0);
 			else {
+#if CAIRO_1_2_5			 
 				MCairo::Cairo.Context rgba = CairoHelper.Create (GdkWindow);
+#else				
+				Context rgba = CairoUtils.CreateContext (GdkWindow);
+#endif				
 				DrawShape (rgba, Allocation.Width, Allocation.Height);
 				((IDisposable)rgba).Dispose ();
 				try {
@@ -341,33 +355,52 @@
 			hotspot.X = (int) Math.Ceiling (Center.X + x_proj);
 			hotspot.Y = (int) Math.Ceiling (Center.Y + y_proj);
 		}
-		
+	
+#if CAIRO_1_2_5		
 		private void DrawShape (MCairo::Cairo.Context g, int width, int height)
+#else
+		private void DrawShape (Context g, int width, int height)
+#endif				
 		{
 			int inner_x = radius + border + inner;
 			int cx = Center.X;
 			int cy = Center.Y;
-			
+		
+#if CAIRO_1_2_5			
 			g.Operator = MCairo::Cairo.Operator.Source;
 			g.Source = new MCairo::Cairo.SolidPattern (new MCairo::Cairo.Color (0,0,0,0));
+#else
+			g.Operator = Operator.Source;
+			g.Source = new SolidPattern (new Cairo.Color (0,0,0,0));
+#endif						
 			g.Rectangle (0, 0, width, height);
 			g.Paint ();
 
 			g.NewPath ();
 			g.Translate (cx, cy);
 			g.Rotate (angle);
-			
+
+#if CAIRO_1_2_5			
 			g.Source = new MCairo::Cairo.SolidPattern (new MCairo::Cairo.Color (0.2, 0.2, 0.2, .6));
 			g.Operator = MCairo::Cairo.Operator.Over;
+#else
+			g.Source = new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6));
+			g.Operator = Operator.Over;
+#endif						
 			g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
 			g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
 			g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
 			g.Fill ();
 
+#if CAIRO_1_2_5
 			g.Source = new MCairo::Cairo.SolidPattern (new MCairo::Cairo.Color (0, 0, 0, 1.0));
 			g.Operator = MCairo::Cairo.Operator.DestOut;
+#else
+			g.Source = new SolidPattern (new Cairo.Color (0, 0, 0, 1.0));
+			g.Operator = Operator.DestOut;
+#endif						
 			g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
-#if true
+#if true			
 			g.Fill ();
 #else
 			g.FillPreserve ();
@@ -381,28 +414,65 @@
 			g.Fill ();
 			rg.Destroy ();
 #endif
+#if CAIRO_1_2_5			
 			g.Operator = MCairo::Cairo.Operator.Over;
 			g.Matrix = new MCairo::Cairo.Matrix ();
+#else			
+			g.Operator = Operator.Over;
+			g.Matrix = new Matrix ();
+#endif			
 			g.Translate (cx, cy);
 			if (source != null)
+#if CAIRO_1_2_5			 
 				CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);
+#else
+				SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);
+#endif								
 
 			g.Arc (0, 0, radius, 0, 2 * Math.PI);
 			g.Fill ();
 
 			if (overlay != null) {
+#if CAIRO_1_2_5			 
 				CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
+#else
+				SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
+
+#endif
 				g.Arc (0, 0, radius, angle, angle + Math.PI);
 				g.ClosePath ();
 				g.FillPreserve ();
+#if CAIRO_1_2_5				
 				g.Source = new MCairo::Cairo.SolidPattern (new MCairo::Cairo.Color (1.0, 1.0, 1.0, 1.0));
+#else
+				g.Source = new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0));
+#endif								
 				g.Stroke ();
 			}
 		}
 
+#if !CAIRO_1_2_5
+		[DllImport("libgdk-2.0-0.dll")] 	 
+	        extern static void gdk_cairo_set_source_pixbuf (IntPtr handle, 	 
+	                                                        IntPtr pixbuf, 	 
+	                                                        double        pixbuf_x, 	 
+	                                                        double        pixbuf_y); 	 
+	  	 
+	        [Obsolete ("use Gdk.CairoHelper.SetSourcePixbuf instead")] 	 
+	        static void SetSourcePixbuf (Context ctx, Gdk.Pixbuf pixbuf, double x, double y) 	 
+	        { 	 
+	                gdk_cairo_set_source_pixbuf (ctx.Handle, pixbuf.Handle, x, y); 	 
+	        } 	 
+#endif				
+
 		protected override bool OnExposeEvent (Gdk.EventExpose args)
 		{
+#if CAIRO_1_2_5		 
 			MCairo::Cairo.Context g = CairoHelper.Create (GdkWindow);
+#else
+			Context g = CairoUtils.CreateContext (GdkWindow);			
+#endif						
+			
 			DrawShape (g, Allocation.Width, Allocation.Height);
 			//base.OnExposeEvent (args);
 			((IDisposable)g).Dispose ();
@@ -410,6 +480,19 @@
 
 		}
 		
+                [DllImport ("libcairo-2.dll")]
+                static extern void cairo_user_to_device (IntPtr cr, ref double x, ref double y);
+
+#if CAIRO_1_2_5
+		static void UserToDevice (MCairo::Cairo.Context ctx, ref double x, ref double y)
+#else		
+		static void UserToDevice (Context ctx, ref double x, ref double y)
+#endif		
+		{
+			cairo_user_to_device (ctx.Handle, ref x, ref y);
+		}
+
+		
 		bool dragging = false;
 		bool rotate = false;
 		Delay drag;
@@ -558,15 +641,6 @@
 			return widget;
 		}
 		
-		
-                [DllImport ("libcairo-2.dll")]
-                static extern void cairo_user_to_device (IntPtr cr, ref double x, ref double y);
-
-		static void UserToDevice (MCairo::Cairo.Context ctx, ref double x, ref double y)
-		{
-			cairo_user_to_device (ctx.Handle, ref x, ref y);
-		}
-
 		protected override void OnSizeRequested (ref Requisition requisition) 
 		{
 			Layout ();



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