f-spot r4356 - in trunk: . src src/Cms src/Core src/Imaging src/UI.Dialog src/Widgets



Author: sdelcroix
Date: Tue Sep 16 08:20:41 2008
New Revision: 4356
URL: http://svn.gnome.org/viewvc/f-spot?rev=4356&view=rev

Log:
2008-09-16  Stephane Delcroix  <sdelcroix novell com>

	* Core/ColorManagement.cs:
	* AsyncPixbufLoader.cs:
	* Cms/NativeMethods.cs:
	* Cms/Profile.cs:
	* GPhotoCamera.cs:
	* Imaging/Tiff.cs:
	* MainWindow.cs:
	* Makefile.am:
	* PhotoImageView.cs:
	* Preferences.cs:
	* PrintOperation.cs:
	* TagCommands.cs:
	* TagSelectionWidget.cs:
	* TextureDisplay.cs:
	* UI.Dialog/PreferenceDialog.cs:
	* Widgets/Filmstrip.cs:
	* Widgets/IconView.cs:
	* Widgets/TagView.cs:
	* f-spot.glade: Color management patch developped by Wasja during the
	Google Summer of Code.


Added:
   trunk/src/Core/ColorManagement.cs
Modified:
   trunk/ChangeLog
   trunk/src/AsyncPixbufLoader.cs
   trunk/src/Cms/NativeMethods.cs
   trunk/src/Cms/Profile.cs
   trunk/src/GPhotoCamera.cs
   trunk/src/Imaging/Tiff.cs
   trunk/src/MainWindow.cs
   trunk/src/Makefile.am
   trunk/src/PhotoImageView.cs
   trunk/src/Preferences.cs
   trunk/src/PrintOperation.cs
   trunk/src/TagCommands.cs
   trunk/src/TagSelectionWidget.cs
   trunk/src/TextureDisplay.cs
   trunk/src/UI.Dialog/PreferenceDialog.cs
   trunk/src/Widgets/Filmstrip.cs
   trunk/src/Widgets/IconView.cs
   trunk/src/Widgets/TagView.cs
   trunk/src/f-spot.glade

Modified: trunk/src/AsyncPixbufLoader.cs
==============================================================================
--- trunk/src/AsyncPixbufLoader.cs	(original)
+++ trunk/src/AsyncPixbufLoader.cs	Tue Sep 16 08:20:41 2008
@@ -120,6 +120,15 @@
 					PixbufOrientation thumb_orientation = Accelerometer.GetViewOrientation (PixbufOrientation.TopLeft);
 					thumb = new Gdk.Pixbuf (ThumbnailGenerator.ThumbnailPath (uri));
 					thumb = PixbufUtils.TransformOrientation (thumb, thumb_orientation);
+					
+					if (FSpot.ColorManagement.IsEnabled && !thumb.HasAlpha) {
+						if (img.GetProfile () == null)
+							FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.StandartTransform ();
+						else
+							FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.CreateTransform (thumb, img.GetProfile ());
+					}
+					else
+						FSpot.ColorManagement.PhotoImageView.Transform = null;
 				} catch (System.Exception e) {
 					//FSpot.ThumbnailGenerator.Default.Request (uri.ToString (), 0, 256, 256);	
 					if (!(e is GLib.GException)) 

Modified: trunk/src/Cms/NativeMethods.cs
==============================================================================
--- trunk/src/Cms/NativeMethods.cs	(original)
+++ trunk/src/Cms/NativeMethods.cs	Tue Sep 16 08:20:41 2008
@@ -93,6 +93,9 @@
 	
 		[DllImport("liblcms-1.0.0.dll", EntryPoint = "cmsErrorAction")]
 		public static extern void CmsErrorAction (int action);
+		
+		[DllImport ("liblcms-1.0.0.dll", EntryPoint = "cmsGetColorSpace")]
+		public static extern uint cmsGetColorSpace (HandleRef hprofile);
 
 		[DllImport("liblcms-1.0.0.dll", EntryPoint = "cmsTakeProductDesc")]
 		public extern static IntPtr CmsTakeProductDesc (HandleRef handle);

Modified: trunk/src/Cms/Profile.cs
==============================================================================
--- trunk/src/Cms/Profile.cs	(original)
+++ trunk/src/Cms/Profile.cs	Tue Sep 16 08:20:41 2008
@@ -252,6 +252,12 @@
 			}				
 		}
 		
+		public uint ColorSpace {
+			get {
+				return NativeMethods.cmsGetColorSpace (this.handle);
+			}
+		}
+		
 		public string Model {
 			get {
 				lock (srgb) {

Added: trunk/src/Core/ColorManagement.cs
==============================================================================
--- (empty file)
+++ trunk/src/Core/ColorManagement.cs	Tue Sep 16 08:20:41 2008
@@ -0,0 +1,226 @@
+/*
+ * FSpot.Core.ColorManagement.cs
+ *
+ * Author(s):
+ * 	Vasiliy Kirilichev <vasyok gmail com>
+ *
+ * This is free software. See COPYING for details.
+ *
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+
+namespace FSpot {
+public class ColorManagement {
+		public static bool IsEnabled;
+		public static bool UseXProfile;
+		
+		private static Cms.Profile XProfile;		
+		private static Cms.Profile display_profile;
+		private static Cms.Profile destination_profile;
+		private static Cms.Transform standart_transform;
+		
+		private static FSpot.PhotoImageView photo_image_view;
+
+		private static string [] search_dir = { "/usr/share/color/icc", "~/.color/icc", "/usr/local/share/color/icc " }; //the main directory list to find a profiles
+		public static ArrayList Profiles = new ArrayList();
+		
+		public static FSpot.PhotoImageView PhotoImageView {
+			set {
+				if (photo_image_view == null)
+					photo_image_view = value;
+			}
+			get { return photo_image_view; }
+		}
+		
+		public static Cms.Profile DisplayProfile {
+			set {
+				display_profile = value;
+				foreach (Cms.Profile profile in Profiles)
+					if (profile.ProductName == display_profile.ProductName)
+						Preferences.Set (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE, profile.ProductName);
+			}
+			get { return display_profile; }
+		}
+
+		public static Cms.Profile DestinationProfile {
+			set {
+				destination_profile = value;
+				foreach (Cms.Profile profile in Profiles)
+					if (profile.ProductName == destination_profile.ProductName)
+						Preferences.Set (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE, profile.ProductName);
+			}
+			get { return destination_profile; }
+		}
+		
+		private static void GetStandartProfiles ()
+		{
+			Profiles.Add (Cms.Profile.CreateStandardRgb ());
+			Profiles.Add (Cms.Profile.CreateAlternateRgb ());
+		}
+		
+		private static void GetProfiles (string path)
+		{
+			//recursive search, only RGB color profiles would be added
+			if (Directory.Exists (path)) {
+				string[] IccColorProfilList = System.IO.Directory.GetFiles (path, "*.icc");
+				foreach (string ColorProfilePath in IccColorProfilList) {
+					Cms.Profile profile = new Cms.Profile (ColorProfilePath);
+					if ((Cms.IccColorSpace)profile.ColorSpace == Cms.IccColorSpace.Rgb)
+						Profiles.Add(profile);
+				}
+				string[] IcmColorProfilList = System.IO.Directory.GetFiles (path, "*.icm");
+				foreach (string ColorProfilePath in IcmColorProfilList) {
+					Cms.Profile profile = new Cms.Profile (ColorProfilePath);
+					if ((Cms.IccColorSpace)profile.ColorSpace == Cms.IccColorSpace.Rgb)
+						Profiles.Add(profile);
+				}
+				string[] DirList = System.IO.Directory.GetDirectories (path);
+					foreach (string dir in DirList)
+						GetProfiles (dir);
+			}
+		}
+		
+		private static void GetXProfile ()
+		{
+			Gdk.Screen screen = Gdk.Screen.Default;
+			XProfile = Cms.Profile.GetScreenProfile (screen);
+			
+			if (XProfile != null && (Cms.IccColorSpace)XProfile.ColorSpace == Cms.IccColorSpace.Rgb) {
+				int a = 0;
+				foreach (Cms.Profile profile in Profiles) {
+					if (profile.ProductName == XProfile.ProductName)
+						break;
+					a++;
+				}
+				if (a == Profiles.Count)
+					Profiles.Add (XProfile);
+			}	
+		}
+		
+		private static void GetSettings ()
+		{	
+			//Display
+			if (UseXProfile && XProfile != null  && (Cms.IccColorSpace)XProfile.ColorSpace == Cms.IccColorSpace.Rgb)
+				display_profile = XProfile;
+			else {
+				foreach (Cms.Profile profile in Profiles)
+					if (profile.ProductName == Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE))
+						display_profile = profile;
+				if (display_profile == null)
+					display_profile = Cms.Profile.CreateStandardRgb ();
+			}
+
+			//Output
+			foreach (Cms.Profile profile in Profiles)
+				if (profile.ProductName == Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE))
+					destination_profile = profile;
+			if (destination_profile == null)
+				destination_profile = Cms.Profile.CreateStandardRgb ();
+		}
+		
+		public static void LoadSettings ()
+		{
+			Profiles.Clear ();
+			GetStandartProfiles ();
+			foreach (string dir in search_dir)
+				GetProfiles (dir);
+			GetXProfile ();
+			GetSettings ();
+			CreateStandartTransform ();
+		}
+		
+		public static void ReloadSettings()
+		{
+			GetXProfile ();
+			GetSettings ();
+			CreateStandartTransform ();
+			PhotoImageView.Reload ();
+		}
+		
+		private static void CreateStandartTransform ()
+		{
+			Cms.Profile [] list = new Cms.Profile [] { Cms.Profile.CreateStandardRgb (), display_profile };
+			
+			standart_transform = new Cms.Transform (list,
+			                                        Cms.Format.Rgb8,
+			                                        Cms.Format.Rgb8,
+			                                        Cms.Intent.Perceptual, 0x0000);
+		}
+		
+		//it returns the cached transformation
+		public static Cms.Transform StandartTransform ()
+		{
+			if (IsEnabled)
+				return standart_transform;
+			else
+				return null;
+		}
+		
+		//this method create the Cms.Transform using image_profile and current screen profile
+		public static Cms.Transform CreateTransform (Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
+		{
+			if (IsEnabled && pixbuf != null) {
+				if (image_profile == null)
+					image_profile = Cms.Profile.CreateStandardRgb ();
+		
+				Cms.Profile [] list = new Cms.Profile [] { image_profile, display_profile };
+				
+				Cms.Transform transform = new Cms.Transform (list,
+				                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+				                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+				                                             Cms.Intent.Perceptual, 0x0000);
+				return transform;
+			}
+			else
+				return null;
+		}
+		
+		//the main apply color profile method. it use the _standart_ image profile and current display profile
+		public static void ApplyScreenProfile (Gdk.Pixbuf pixbuf)
+		{
+			if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha)
+				PixbufUtils.ColorAdjust (pixbuf, pixbuf, standart_transform);
+		}
+		
+		//it works also but it uses the image_profile too
+		public static void ApplyScreenProfile (Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
+		{
+			if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha) {
+				if (image_profile == null)
+					ApplyScreenProfile (pixbuf);
+				else {
+					Cms.Profile [] list = new Cms.Profile [] { image_profile, display_profile };
+					Cms.Transform transform = new Cms.Transform (list,
+					                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+					                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+					                                             Cms.Intent.Perceptual, 0x0000);
+					PixbufUtils.ColorAdjust (pixbuf, pixbuf, transform);
+				}
+			}
+		}
+		
+//		public static void ApplyScreenProfile (Gdk.Pixbuf src, Gdk.Pixbuf dest)
+//		{
+//			PixbufUtils.ColorAdjust (src, dest, standart_transform);
+//		}
+		
+		public static void ApplyPrinterProfile (Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
+		{
+			if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha) {
+				if (image_profile == null)
+					image_profile = Cms.Profile.CreateStandardRgb ();
+				
+				Cms.Profile [] list = new Cms.Profile [] { image_profile, destination_profile };
+				
+				Cms.Transform transform = new Cms.Transform (list,
+				                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+				                                             PixbufUtils.PixbufCmsFormat (pixbuf),
+				                                             Cms.Intent.Perceptual, 0x0000);
+				PixbufUtils.ColorAdjust (pixbuf, pixbuf, transform);
+			}
+		}
+	}
+}

Modified: trunk/src/GPhotoCamera.cs
==============================================================================
--- trunk/src/GPhotoCamera.cs	(original)
+++ trunk/src/GPhotoCamera.cs	Tue Sep 16 08:20:41 2008
@@ -183,7 +183,9 @@
 			if (bytedata.Length > 0) {
 				MemoryStream dataStream = new MemoryStream (bytedata);
 				try {
-					return new Pixbuf (dataStream);
+					Gdk.Pixbuf temp = new Pixbuf (dataStream);
+					FSpot.ColorManagement.ApplyScreenProfile (temp);
+					return temp;
 				} catch (Exception e) {
 					// Actual errors with the data libgphoto gives us have been
 					// observed here see b.g.o #357569. 

Modified: trunk/src/Imaging/Tiff.cs
==============================================================================
--- trunk/src/Imaging/Tiff.cs	(original)
+++ trunk/src/Imaging/Tiff.cs	Tue Sep 16 08:20:41 2008
@@ -2287,6 +2287,14 @@
 
 		public Cr2File (Uri uri) : base (uri)
 		{
+//							Gtk.MessageDialog md = new Gtk.MessageDialog (null, 
+//							                                              Gtk.DialogFlags.DestroyWithParent,
+//							                                              Gtk.MessageType.Error, 
+//							                                              Gtk.ButtonsType.Close,
+//							                                              "bca");
+//	
+//							int result = md.Run ();
+//							md.Destroy();
 		}
 
 		/*

Modified: trunk/src/MainWindow.cs
==============================================================================
--- trunk/src/MainWindow.cs	(original)
+++ trunk/src/MainWindow.cs	Tue Sep 16 08:20:41 2008
@@ -262,7 +262,11 @@
 
 		LoadPreference (Preferences.SIDEBAR_POSITION);
 		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
-		
+
+		LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
+ 		LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
+ 		FSpot.ColorManagement.LoadSettings();
+	
 #if GTK_2_10
 		pagesetup_menu_item.Activated += HandlePageSetupActivated;
 #else
@@ -1251,8 +1255,16 @@
 				FSpot.PixbufCache.CacheEntry entry = icon_view.Cache.Lookup (thumbnail_path);
 
 				Pixbuf thumbnail = null;
-				if (entry != null)
-					thumbnail = entry.ShallowCopyPixbuf ();
+				if (entry != null) {
+					if (FSpot.ColorManagement.IsEnabled) {
+						//FIXME
+						thumbnail = entry.ShallowCopyPixbuf ();
+						thumbnail = thumbnail.Copy ();
+						FSpot.ColorManagement.ApplyScreenProfile (thumbnail);
+					}
+					else
+						thumbnail = entry.ShallowCopyPixbuf ();
+				}
 				
 				if (thumbnail != null) {
 					Pixbuf small = PixbufUtils.ScaleToMaxSize (thumbnail, size, size);				
@@ -2756,6 +2768,12 @@
 		case Preferences.METADATA_EMBED_IN_IMAGE:
 			write_metadata =Preferences.Get<bool> (key) ;
 			break;
+		case Preferences.COLOR_MANAGEMENT_ENABLED:
+			FSpot.ColorManagement.IsEnabled = Preferences.Get<bool> (key);
+			break;
+		case Preferences.COLOR_MANAGEMENT_USE_X_PROFILE:
+			FSpot.ColorManagement.UseXProfile = Preferences.Get<bool> (key);
+			break;
 		case Preferences.GNOME_MAILTO_ENABLED:
 			send_mail.Visible = Preferences.Get<bool> (key);
 			break;

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Sep 16 08:20:41 2008
@@ -74,8 +74,7 @@
 	$(srcdir)/Widgets/MenuButton.cs		\
 	$(srcdir)/Widgets/Rating.cs		\
 	$(srcdir)/Widgets/SaneTreeView.cs	\
-	$(srcdir)/Widgets/ScrolledView.cs	\
-	$(srcdir)/Widgets/TagView.cs
+	$(srcdir)/Widgets/ScrolledView.cs
 
 F_SPOT_CSDISTFILES =				\
 	$(srcdir)/AsyncPixbufLoader.cs		\
@@ -91,6 +90,7 @@
 	$(srcdir)/CompatFileChooser.cs		\
 	$(srcdir)/ControlOverlay.cs		\
 	$(srcdir)/Core.cs			\
+	$(srcdir)/Core/ColorManagement.cs	\
 	$(srcdir)/Core/Photo.cs			\
 	$(srcdir)/Core/PhotoVersion.cs		\
 	$(srcdir)/DateCommands.cs		\
@@ -265,6 +265,7 @@
 	$(srcdir)/Widgets/Sidebar.cs		\
 	$(srcdir)/Widgets/TagEntry.cs		\
 	$(srcdir)/Widgets/TagMenu.cs		\
+	$(srcdir)/Widgets/TagView.cs		\
 	$(srcdir)/Widgets/TrayView.cs		\
 	$(srcdir)/Widgets/ViewContext.cs		\
 	$(srcdir)/Widgets/Wipe.cs		\

Modified: trunk/src/PhotoImageView.cs
==============================================================================
--- trunk/src/PhotoImageView.cs	(original)
+++ trunk/src/PhotoImageView.cs	Tue Sep 16 08:20:41 2008
@@ -23,6 +23,7 @@
 
 		public PhotoImageView (IBrowsableCollection query) : this (new BrowsablePointer (query, -1))
 		{
+			FSpot.ColorManagement.PhotoImageView = this;
 		}
 
 		public PhotoImageView (BrowsablePointer item)
@@ -31,6 +32,9 @@
 			loader.AreaUpdated += HandlePixbufAreaUpdated;
 			loader.AreaPrepared += HandlePixbufPrepared;
 			loader.Done += HandleDone;
+			
+			FSpot.ColorManagement.PhotoImageView = this;
+			this.Transform = FSpot.ColorManagement.StandartTransform (); //for preview windows
 
 			Accelerometer.OrientationChanged += HandleOrientationChanged;
 

Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs	(original)
+++ trunk/src/Preferences.cs	Tue Sep 16 08:20:41 2008
@@ -33,6 +33,11 @@
 		public const string VIEWER_TRANSPARENCY = "/apps/f-spot/viewer/transparency";
 		public const string CUSTOM_CROP_RATIOS = "/apps/f-spot/viewer/custom_crop_ratios";
 		
+		public const string COLOR_MANAGEMENT_ENABLED = "/apps/f-spot/ui/color_management_enabled";
+		public const string COLOR_MANAGEMENT_USE_X_PROFILE = "/apps/f-spot/ui/color_management_use_x_profile";
+		public const string COLOR_MANAGEMENT_DISPLAY_PROFILE = "/apps/f-spot/ui/color_management_display_profile";
+		public const string COLOR_MANAGEMENT_OUTPUT_PROFILE = "/apps/f-spot/ui/color_management_output_profile";
+		
 		public const string SHOW_TOOLBAR = "/apps/f-spot/ui/show_toolbar";
 		public const string SHOW_SIDEBAR = "/apps/f-spot/ui/show_sidebar";
 		public const string SHOW_TIMELINE = "/apps/f-spot/ui/show_timeline";

Modified: trunk/src/PrintOperation.cs
==============================================================================
--- trunk/src/PrintOperation.cs	(original)
+++ trunk/src/PrintOperation.cs	Tue Sep 16 08:20:41 2008
@@ -108,6 +108,7 @@
 						Gdk.Pixbuf pixbuf;
 						try {
 							pixbuf = img.Load ();
+							FSpot.ColorManagement.ApplyPrinterProfile (pixbuf, img.GetProfile ());
 						} catch (Exception e) {
 							Log.Exception ("Unable to load image " + selected_photos[p_index].DefaultVersionUri + "\n", e);
 							// If the image is not found load error pixbuf

Modified: trunk/src/TagCommands.cs
==============================================================================
--- trunk/src/TagCommands.cs	(original)
+++ trunk/src/TagCommands.cs	Tue Sep 16 08:20:41 2008
@@ -238,8 +238,15 @@
 		private void HandleIconButtonClicked (object sender, EventArgs args)
 		{
 			TagCommands.EditIcon command = new TagCommands.EditIcon (db, parent_window);
-			if (command.Execute (tag))
-				icon_image.Pixbuf = tag.Icon;
+			//FIXME
+			if (command.Execute (tag)) {
+				if (FSpot.ColorManagement.IsEnabled && tag.Icon != null) {
+					icon_image.Pixbuf = tag.Icon.Copy();
+					FSpot.ColorManagement.ApplyScreenProfile(icon_image.Pixbuf);
+				}
+				else
+					icon_image.Pixbuf = tag.Icon;
+			}
 		}
 
 		private void PopulateCategoryOptionMenu (Tag t)
@@ -283,6 +290,11 @@
 			tag_name_entry.Text = t.Name;
 
 			icon_image.Pixbuf = t.Icon;
+			//FIXME
+			if (FSpot.ColorManagement.IsEnabled && icon_image.Pixbuf != null) {
+				icon_image.Pixbuf = icon_image.Pixbuf.Copy();
+				FSpot.ColorManagement.ApplyScreenProfile (icon_image.Pixbuf);
+			}
 			PopulateCategoryOptionMenu  (t);
 			
 			icon_button.Clicked += HandleIconButtonClicked;
@@ -338,6 +350,8 @@
 		[Glade.Widget] SpinButton photo_spin_button;
 		[Glade.Widget] HBox external_photo_chooser_hbox;
 		[Glade.Widget] Button noicon_button;
+		
+		private Gdk.Pixbuf PreviewPixbuf_WithoutProfile;
 
 		private Gdk.Pixbuf PreviewPixbuf {
 			get { return preview_image.Pixbuf; }
@@ -381,6 +395,8 @@
 				using (FSpot.ImageFile img = FSpot.ImageFile.Create(new Uri(external_photo_chooser.Uri))) {
 					using (Gdk.Pixbuf external_image = img.Load ()) {
 						PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (external_image);
+						PreviewPixbuf_WithoutProfile = PreviewPixbuf.Copy();
+						FSpot.ColorManagement.ApplyScreenProfile (PreviewPixbuf);
 					}
 				}
 			} catch (Exception) {
@@ -411,11 +427,17 @@
 				if (width > 0 && height > 0) {
 					tmp = new Gdk.Pixbuf (image_view.Pixbuf, x, y, width, height);
 					
+					//FIXME
 					PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (tmp);
+					PreviewPixbuf_WithoutProfile = PreviewPixbuf.Copy();
+					FSpot.ColorManagement.ApplyScreenProfile (PreviewPixbuf);
 					
 					tmp.Dispose ();
 				} else {
+					//FIXME
 					PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (image_view.Pixbuf);
+					PreviewPixbuf_WithoutProfile = PreviewPixbuf.Copy();
+					FSpot.ColorManagement.ApplyScreenProfile (PreviewPixbuf);
 				}
 			}
 		}
@@ -527,7 +549,7 @@
 						t.ThemeIconName = IconName;
 					} else {
 						t.ThemeIconName = null;
-						t.Icon = PreviewPixbuf;
+						t.Icon = PreviewPixbuf_WithoutProfile;
 					}
 					//db.Tags.Commit (t);
 					success = true;

Modified: trunk/src/TagSelectionWidget.cs
==============================================================================
--- trunk/src/TagSelectionWidget.cs	(original)
+++ trunk/src/TagSelectionWidget.cs	Tue Sep 16 08:20:41 2008
@@ -192,8 +192,16 @@
 		SetBackground (renderer, tag);
 
 		// FIXME I can't set the Pixbuf to null, not sure if it's a GTK# bug...
-		if (tag.Icon != null)
-			(renderer as CellRendererPixbuf).Pixbuf = tag.SizedIcon;
+		if (tag.Icon != null) {
+			if (FSpot.ColorManagement.IsEnabled) {
+				//FIXME
+				Gdk.Pixbuf temp = tag.SizedIcon.Copy();
+				FSpot.ColorManagement.ApplyScreenProfile (temp);
+				(renderer as CellRendererPixbuf).Pixbuf = temp;
+			}
+			else
+				(renderer as CellRendererPixbuf).Pixbuf = tag.SizedIcon;
+		}
 		else
 			(renderer as CellRendererPixbuf).Pixbuf = empty_pixbuf;
 	}

Modified: trunk/src/TextureDisplay.cs
==============================================================================
--- trunk/src/TextureDisplay.cs	(original)
+++ trunk/src/TextureDisplay.cs	Tue Sep 16 08:20:41 2008
@@ -164,7 +164,8 @@
 			try {
 				using (ImageFile img = ImageFile.Create (item.Current.DefaultVersionUri)) {
 					using (Gdk.Pixbuf pixbuf = img.Load ()) {
-					        tex = new Texture (pixbuf);
+						FSpot.ColorManagement.ApplyScreenProfile (pixbuf, img.GetProfile ());
+						tex = new Texture (pixbuf);
 					}
 				}
 			} catch (Exception) {

Modified: trunk/src/UI.Dialog/PreferenceDialog.cs
==============================================================================
--- trunk/src/UI.Dialog/PreferenceDialog.cs	(original)
+++ trunk/src/UI.Dialog/PreferenceDialog.cs	Tue Sep 16 08:20:41 2008
@@ -16,33 +16,34 @@
 using FSpot.Widgets;
 
 namespace FSpot.UI.Dialog {
-#if FALSE
 	public class ProfileList : TreeStore {
-		public ProfileList () : base (typeof (Profile))
+		public ProfileList () : base (typeof (Cms.Profile))
 		{
-			this.AppendValues (Profile.CreateStandardRgb ());
-			this.AppendValues (Profile.CreateAlternateRgb ());
+			foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles)
+				this.AppendValues (profile);
 		}
 
+		private const int NameLenth = 50;
 		public static void ProfileNameDataFunc (CellLayout layout, CellRenderer renderer, TreeModel model, TreeIter iter)
 		{
-			Profile profile = (Profile) model.GetValue (iter, 0);
-			(renderer as Gtk.CellRendererText).Text = profile.ProductName;
-		}
-
-		public static void ProfileDescriptionDataFunc (CellLayout layout, CellRenderer renderer, TreeModel model, TreeIter iter)
-		{
-			Profile profile = (Profile) model.GetValue (iter, 0);
-			(renderer as Gtk.CellRendererText).Text = profile.ProductDescription;
+			if (model.GetValue (iter, 0) != null) {
+				Cms.Profile profile = (Cms.Profile) model.GetValue (iter, 0);
+				if (profile.ProductName.Length < NameLenth)
+					(renderer as Gtk.CellRendererText).Text = profile.ProductName;
+				else
+					(renderer as Gtk.CellRendererText).Text = profile.ProductName.Substring(0, NameLenth) + "...";
+			}
+			else
+				(renderer as Gtk.CellRendererText).Text = "";
 		}
 	}
-#endif
+
 	public class PreferenceDialog : GladeDialog {
 		[Glade.Widget] private CheckButton metadata_check;
-#if FALSE
+		[Glade.Widget] private CheckButton colormanagement_check;
+		[Glade.Widget] private CheckButton use_x_profile_check;
 		[Glade.Widget] private ComboBox display_combo;
 		[Glade.Widget] private ComboBox destination_combo;
-#endif
 		[Glade.Widget] private HBox tagselectionhbox;
 		[Glade.Widget] private Button set_saver_button;
 		[Glade.Widget] private FileChooserButton photosdir_chooser;
@@ -71,6 +72,8 @@
 		{
 			tag_button = new MenuButton ();
 			LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
+			LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
+			LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
 			LoadPreference (Preferences.SCREENSAVER_TAG);
 			LoadPreference (Preferences.GNOME_SCREENSAVER_THEME);
 			if (Global.PhotoDirectory == Preferences.Get<string> (Preferences.STORAGE_PATH)) {
@@ -80,24 +83,41 @@
 				photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
 				photosdir_chooser.Sensitive = false;
 			}
-#if FALSE
+
 			Gtk.CellRendererText name_cell = new Gtk.CellRendererText ();
 			Gtk.CellRendererText desc_cell = new Gtk.CellRendererText ();
 			
-			display_combo.Model = new ProfileList ();
+			use_x_profile_check.Sensitive = colormanagement_check.Active;
+			
+			display_combo.Sensitive = colormanagement_check.Active;
+			display_combo.Model = new ProfileList ();                                                                                    
 			display_combo.PackStart (desc_cell, false);
 			display_combo.PackStart (name_cell, true);
 			display_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
-			display_combo.SetCellDataFunc (desc_cell, new CellLayoutDataFunc (ProfileList.ProfileDescriptionDataFunc));
+			//FIXME
+			int it_ = 0;
+			foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles) {
+				if (profile.ProductName == Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE))
+					display_combo.Active = it_;
+				it_++;
+			}
+
 			display_combo.Changed += HandleDisplayChanged;
 
+			destination_combo.Sensitive = colormanagement_check.Active;
 			destination_combo.Model = new ProfileList ();
 			destination_combo.PackStart (desc_cell, false);
 			destination_combo.PackStart (name_cell, true);
 			destination_combo.SetCellDataFunc (name_cell, new CellLayoutDataFunc (ProfileList.ProfileNameDataFunc));
-			destination_combo.SetCellDataFunc (desc_cell, new CellLayoutDataFunc (ProfileList.ProfileDescriptionDataFunc));
-			destination_combo.Changed += HandleDisplayChanged;
-#endif
+			destination_combo.Changed += HandleDestinationChanged;
+			//FIXME
+			it_ = 0;
+			foreach (Cms.Profile profile in FSpot.ColorManagement.Profiles) {
+				if (profile.ProductName ==  Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE))
+					destination_combo.Active = it_;
+				it_++;
+			}
+
 			TagMenu tagmenu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
 	
 			tagmenu.Populate (false);
@@ -153,21 +173,47 @@
 			this.Dialog.Destroyed += HandleDestroyed;
 		}
 
-#if FALSE
+		private void ColorManagementEnabledToggled (object sender, System.EventArgs args)
+		{
+			Preferences.Set (Preferences.COLOR_MANAGEMENT_ENABLED, colormanagement_check.Active);
+
+			if (FSpot.ColorManagement.IsEnabled != colormanagement_check.Active) {
+				FSpot.ColorManagement.IsEnabled = colormanagement_check.Active;
+				FSpot.ColorManagement.ReloadSettings();
+			}
+			
+			use_x_profile_check.Sensitive = colormanagement_check.Active;
+			display_combo.Sensitive = colormanagement_check.Active;
+			destination_combo.Sensitive = colormanagement_check.Active;
+		}
+		
+		private void UseXProfileToggled (object sender, System.EventArgs args)
+		{
+			Preferences.Set (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE, use_x_profile_check.Active);
+			if (FSpot.ColorManagement.UseXProfile != use_x_profile_check.Active) {
+				FSpot.ColorManagement.UseXProfile = use_x_profile_check.Active;
+				FSpot.ColorManagement.ReloadSettings();
+			}
+		}
+
 		private void HandleDisplayChanged (object sender, System.EventArgs args)
 		{
 			TreeIter iter;
-			if (display_combo.GetActiveIter (out iter))
-				FSpot.Global.DisplayProfile = (Profile) display_combo.Model.GetValue (iter, 0);
+			Gdk.Screen screen = Gdk.Screen.Default;
+			if (display_combo.GetActiveIter (out iter)) {
+				FSpot.ColorManagement.DisplayProfile = (Cms.Profile) display_combo.Model.GetValue (iter, 0);
+//				FSpot.Widgets.CompositeUtils.SetScreenProfile(screen, FSpot.ColorManagement.DisplayProfile);
+				FSpot.ColorManagement.ReloadSettings();
+			}
 		}
 		
 		private void HandleDestinationChanged (object sender, System.EventArgs args)
 		{
 			TreeIter iter;
 			if (destination_combo.GetActiveIter (out iter))
-				FSpot.Global.DestinationProfile = (Profile) destination_combo.Model.GetValue (iter, 0);
+				FSpot.ColorManagement.DestinationProfile = (Cms.Profile) destination_combo.Model.GetValue (iter, 0);
 		}
-#endif
+
 		private void HandleTagMenuSelected (Tag t)
 		{
 			tag_button.Label = t.Name;
@@ -276,6 +322,16 @@
 				if (metadata_check.Active != active)
 					metadata_check.Active = active;
 				break;
+case Preferences.COLOR_MANAGEMENT_ENABLED:
+				active = Preferences.Get<bool> (key);
+				if (colormanagement_check.Active != active)
+					colormanagement_check.Active = active;
+				break;
+			case Preferences.COLOR_MANAGEMENT_USE_X_PROFILE:
+				active = Preferences.Get<bool> (key);
+				if (use_x_profile_check.Active != active)
+					use_x_profile_check.Active = active;
+				break;
 			case Preferences.SCREENSAVER_TAG:
 				try {
 					screensaver_tag = Preferences.Get<int> (key);

Modified: trunk/src/Widgets/Filmstrip.cs
==============================================================================
--- trunk/src/Widgets/Filmstrip.cs	(original)
+++ trunk/src/Widgets/Filmstrip.cs	Tue Sep 16 08:20:41 2008
@@ -562,6 +562,12 @@
 
 			}
 			
+			//FIXME
+			if (FSpot.ColorManagement.IsEnabled) {
+				current = current.Copy ();
+				FSpot.ColorManagement.ApplyScreenProfile (current);
+			}
+			
 			if (!highlighted)
 				return current;
 

Modified: trunk/src/Widgets/IconView.cs
==============================================================================
--- trunk/src/Widgets/IconView.cs	(original)
+++ trunk/src/Widgets/IconView.cs	Tue Sep 16 08:20:41 2008
@@ -869,6 +869,11 @@
 						draw.Width, draw.Height);
 
 				if (region.Intersect (area, out draw)) {
+					//FIXME
+					if (FSpot.ColorManagement.IsEnabled) {
+						temp_thumbnail = temp_thumbnail.Copy();
+						FSpot.ColorManagement.ApplyScreenProfile (temp_thumbnail);
+					}
 					temp_thumbnail.RenderToDrawable (BinWindow, Style.WhiteGC,
 							draw.X - region.X,
 							draw.Y - region.Y,
@@ -988,6 +993,8 @@
 									tag_bounds.Height,
 									InterpType.Bilinear);
 						}
+						
+						FSpot.ColorManagement.ApplyScreenProfile (scaled_icon);
 
 						scaled_icon.RenderToDrawable (BinWindow, Style.WhiteGC,
 								region.X - tag_bounds.X,

Modified: trunk/src/Widgets/TagView.cs
==============================================================================
--- trunk/src/Widgets/TagView.cs	(original)
+++ trunk/src/Widgets/TagView.cs	Tue Sep 16 08:20:41 2008
@@ -90,6 +90,7 @@
 			} else {
 				scaled_icon = icon.ScaleSimple (thumbnail_size, thumbnail_size, InterpType.Bilinear);
 			}
+				FSpot.ColorManagement.ApplyScreenProfile (scaled_icon);
 
 			scaled_icon.RenderToDrawable (GdkWindow, Style.WhiteGC,
 						      0, 0, tag_x, tag_y, thumbnail_size, thumbnail_size,

Modified: trunk/src/f-spot.glade
==============================================================================
--- trunk/src/f-spot.glade	(original)
+++ trunk/src/f-spot.glade	Tue Sep 16 08:20:41 2008
@@ -5855,6 +5855,7 @@
             </child>
             <child>
               <widget class="GtkFrame" id="frame41">
+		<property name="visible">True</property>
                 <property name="label_xalign">0</property>
                 <property name="shadow_type">GTK_SHADOW_NONE</property>
                 <child>
@@ -5864,7 +5865,7 @@
                     <child>
                       <widget class="GtkTable" id="table24">
                         <property name="visible">True</property>
-                        <property name="n_rows">4</property>
+                        <property name="n_rows">5</property>
                         <property name="n_columns">3</property>
                         <property name="column_spacing">6</property>
                         <property name="row_spacing">6</property>
@@ -5892,6 +5893,41 @@
                         <child>
                           <placeholder/>
                         </child>
+			<child>
+                          <widget class="GtkCheckButton" id="colormanagement_check">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="label" translatable="yes">Enable</property>
+                            <property name="use_underline">True</property>
+                            <property name="response_id">0</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="ColorManagementEnabledToggled"/>
+                          </widget>
+                          <packing>
+ 			    <property name="top_attach">0</property>
+                            <property name="bottom_attach">1</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+			</child>
+			<child>
+                          <widget class="GtkCheckButton" id="use_x_profile_check">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="label" translatable="yes">Try to use the system display profile</property>
+                            <property name="use_underline">True</property>
+                            <property name="response_id">0</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="UseXProfileToggled"/>
+                          </widget>
+                          <packing>
+			    <property name="left_attach">1</property>
+ 			    <property name="top_attach">0</property>
+                            <property name="bottom_attach">1</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+			</child>
                         <child>
                           <widget class="GtkLabel" id="label185">
                             <property name="visible">True</property>
@@ -5923,8 +5959,6 @@
                         <child>
                           <widget class="GtkComboBox" id="display_combo">
                             <property name="visible">True</property>
-                            <property name="items" translatable="yes">From Screen
-Standard RGB</property>
                           </widget>
                           <packing>
                             <property name="left_attach">1</property>
@@ -5937,10 +5971,6 @@
                         <child>
                           <widget class="GtkComboBox" id="destination_combo">
                             <property name="visible">True</property>
-                            <property name="items" translatable="yes">Standard RGB
-Image Profile
-Custom
-</property>
                           </widget>
                           <packing>
                             <property name="left_attach">1</property>



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