[f-spot/FSPOT_0_6_0_STABLE] Only list applicable ICC profiles



commit f06f5f4398aa89de50dd566e170205ced2e12872
Author: Stephane Delcroix <stephane delcroix org>
Date:   Tue Jan 5 12:17:42 2010 +0100

    Only list applicable ICC profiles
    
    Only list Display profiles for displaying, and Output ones for printing. Based on a patch from Pascal de Bruijn.
    
    Fixes bgo#606045

 src/Cms/IccProfileClass.cs        |   21 +++++++++++++++++++++
 src/Cms/NativeMethods.cs          |    5 ++++-
 src/Cms/Profile.cs                |   19 +++++++++++--------
 src/Makefile.am                   |    1 +
 src/UI.Dialog/PreferenceDialog.cs |   24 +++++++++++++++++-------
 5 files changed, 54 insertions(+), 16 deletions(-)
---
diff --git a/src/Cms/IccProfileClass.cs b/src/Cms/IccProfileClass.cs
new file mode 100644
index 0000000..9f92988
--- /dev/null
+++ b/src/Cms/IccProfileClass.cs
@@ -0,0 +1,21 @@
+/*
+ * Cms.IccProfileClass.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ *	Pascal de Bruijn  <pmjdebruijn pcode nl>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace Cms {
+	public enum IccProfileClass : uint {
+		Input      = 0x73636e72,  /* 'scnr' */
+		Display    = 0x6D6e7472,  /* 'mntr' */
+		Output     = 0x70727472,  /* 'prtr' */
+		Link       = 0x6c696e6b,  /* 'link' */
+		Abstract   = 0x61627374,  /* 'abst' */
+		ColorSpace = 0x73706163,  /* 'spac' */
+		NamedColor = 0x6e6d636c,  /* 'nmcl' */
+		Max        = 0xffffffff, 
+	}
+}
diff --git a/src/Cms/NativeMethods.cs b/src/Cms/NativeMethods.cs
index 71800b7..acf11a7 100644
--- a/src/Cms/NativeMethods.cs
+++ b/src/Cms/NativeMethods.cs
@@ -95,7 +95,10 @@ namespace Cms
 		public static extern void CmsErrorAction (int action);
 		
 		[DllImport ("liblcms-1.0.0.dll", EntryPoint = "cmsGetColorSpace")]
-		public static extern uint cmsGetColorSpace (HandleRef hprofile);
+		public static extern uint CmsGetColorSpace (HandleRef hprofile);
+
+		[DllImport ("liblcms-1.0.0.dll", EntryPoint = "cmsGetDeviceClass")]
+		public static extern uint CmsGetDeviceClass (HandleRef hprofile);
 
 		[DllImport("liblcms-1.0.0.dll", EntryPoint = "cmsTakeProductDesc")]
 		public extern static IntPtr CmsTakeProductDesc (HandleRef handle);
diff --git a/src/Cms/Profile.cs b/src/Cms/Profile.cs
index 56c9201..d86ae56 100644
--- a/src/Cms/Profile.cs
+++ b/src/Cms/Profile.cs
@@ -3,6 +3,10 @@
  *
  * Author(s):
  *	Larry Ewing  <lewing novell com>
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * Copyright (c) 2005-2008 Novell, Inc.
+ * Copyright (c) 2010 Stephane Delcroix
  *
  * This is free software. See COPYING for details.
  */
@@ -25,14 +29,11 @@ namespace Cms {
 
 		private HandleRef handle;
 		public HandleRef Handle {
-			get {
-				return handle;
-			}
+			get { return handle; }
 		}
 
 		private Profile () : this (NativeMethods.CmsCreateProfilePlaceholder ())
 		{
-			
 		}
 
 		public static Profile CreateSRgb () 
@@ -261,10 +262,12 @@ namespace Cms {
 			}				
 		}
 		
-		public uint ColorSpace {
-			get {
-				return NativeMethods.cmsGetColorSpace (this.handle);
-			}
+		public IccColorSpace ColorSpace {
+			get { return (IccColorSpace) NativeMethods.CmsGetColorSpace (this.handle); }
+		}
+
+		public IccProfileClass DeviceClass {
+			get { return (IccProfileClass) NativeMethods.CmsGetDeviceClass (this.handle); }
 		}
 		
 		public string Model {
diff --git a/src/Makefile.am b/src/Makefile.am
index e87613c..52c7940 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ CMS_CSDISTFILES =				\
 	$(srcdir)/Cms/Format.cs			\
 	$(srcdir)/Cms/GammaTable.cs		\
 	$(srcdir)/Cms/IccColorSpace.cs		\
+	$(srcdir)/Cms/IccProfileClass.cs	\
 	$(srcdir)/Cms/Intent.cs			\
 	$(srcdir)/Cms/NativeMethods.cs		\
 	$(srcdir)/Cms/Profile.cs		\
diff --git a/src/UI.Dialog/PreferenceDialog.cs b/src/UI.Dialog/PreferenceDialog.cs
index 7aa01fd..c0191bd 100644
--- a/src/UI.Dialog/PreferenceDialog.cs
+++ b/src/UI.Dialog/PreferenceDialog.cs
@@ -6,7 +6,7 @@
  *	Stephane Delcroix  <stephane delcroix org>
  *
  * Copyright (c) 2005-2009 Novell, Inc.
- * Copyright (c) 2007 Stephane Delcroix <stephane delcroix org>
+ * Copyright (c) 2007,2010 Stephane Delcroix
  *
  * This is free software. See COPYING for details.
  */
@@ -14,6 +14,7 @@
 using System;
 using System.IO;
 using System.Collections.Generic;
+using System.Linq;
 using Gtk;
 using Mono.Unix;
 
@@ -54,9 +55,14 @@ namespace FSpot.UI.Dialog {
 			if (FSpot.ColorManagement.XProfile != null)
 				sprofiles.AppendValues (Catalog.GetString ("System profile"), -1);
 			sprofiles.AppendValues (null, 0);
-			foreach (string profile_name in FSpot.ColorManagement.Profiles.Keys)
-				if (profile_name != "_x_profile_") //avoid adding the XProfile twice
-					sprofiles.AppendValues (profile_name, 1);
+			
+			//Pick the display profiles from the full list, avoid _x_profile_
+			var dprofs = from profile in FSpot.ColorManagement.Profiles
+				where (profile.Value.DeviceClass == Cms.IccProfileClass.Display && profile.Key != "_x_profile_")
+				select profile;
+			foreach (var p in dprofs)
+				sprofiles.AppendValues (p.Key, 1);
+
 			CellRendererText profilecellrenderer = new CellRendererText ();
 			profilecellrenderer.Ellipsize = Pango.EllipsizeMode.End;
 
@@ -70,9 +76,13 @@ namespace FSpot.UI.Dialog {
 			ListStore pprofiles = new ListStore (typeof (string), typeof (int));
 			pprofiles.AppendValues (Catalog.GetString ("None"), 0);
 			pprofiles.AppendValues (null, 0);
-			foreach (string profile_name in FSpot.ColorManagement.Profiles.Keys)
-				if (profile_name != "_x_profile_") //don't list XProfile for printers
-					pprofiles.AppendValues (profile_name, 1);
+
+			var pprofs = from profile in FSpot.ColorManagement.Profiles
+				where (profile.Value.DeviceClass == Cms.IccProfileClass.Output && profile.Key != "_x_profile_")
+				select profile;
+			foreach (var p in pprofs)
+				pprofiles.AppendValues (p.Key, 1);
+			
 			printprofile_combo.Model = pprofiles;
 			printprofile_combo.PackStart (profilecellrenderer, true);
 			printprofile_combo.RowSeparatorFunc = ProfileSeparatorFunc;



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