[f-spot] new Pref Dialog by mpt
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Subject: [f-spot] new Pref Dialog by mpt
- Date: Thu, 16 Jul 2009 10:01:40 +0000 (UTC)
commit 859d3370be5bf9bbf7f486a3a5e3576e8343c46e
Author: Stephane Delcroix <stephane delcroix org>
Date: Thu Jul 16 11:58:36 2009 +0200
new Pref Dialog by mpt
implement the new PreferenceDialog contributed by Matthew Paul Thomas.
reactor, clean and simplify all the ColorManagement stuffs making it understandable.
some other minor fixes while wandering into the code.
src/Core/ColorManagement.cs | 217 +++---------
src/GPhotoCamera.cs | 5 +-
src/MainWindow.cs | 26 +-
src/Makefile.am | 2 +-
src/PhotoImageView.cs | 5 +-
src/Preferences.cs | 4 +-
src/PrintOperation.cs | 6 +-
src/TagSelectionWidget.cs | 14 +-
src/TextureDisplay.cs | 4 +-
src/UI.Dialog/DateRangeDialog.cs | 3 -
src/UI.Dialog/EditTagDialog.cs | 13 +-
src/UI.Dialog/EditTagIconDialog.cs | 10 +-
src/UI.Dialog/PreferenceDialog.cs | 492 +++++++++++----------------
src/UI.Dialog/ui/PreferenceDialog.glade | 572 -------------------------------
src/Widgets/Filmstrip.cs | 10 +-
src/Widgets/IconView.cs | 14 +-
src/Widgets/TagView.cs | 4 +-
17 files changed, 308 insertions(+), 1093 deletions(-)
---
diff --git a/src/Core/ColorManagement.cs b/src/Core/ColorManagement.cs
index 59d84dc..064f02e 100644
--- a/src/Core/ColorManagement.cs
+++ b/src/Core/ColorManagement.cs
@@ -3,6 +3,9 @@
*
* Author(s):
* Vasiliy Kirilichev <vasyok gmail com>
+ * Stephane Delcroix <stephane delcroix org>
+ *
+ * Copyright (c) 2008-2009 Novell, Inc.
*
* This is free software. See COPYING for details.
*
@@ -10,48 +13,40 @@
using System;
using System.IO;
-using System.Collections;
+using System.Collections.Generic;
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 standard_transform;
-
- 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 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);
+ public static class ColorManagement {
+ static string [] search_dir = { "/usr/share/color/icc", "~/.color/icc", "/usr/local/share/color/icc " };
+
+ static Dictionary<string, Cms.Profile> profiles;
+ public static IDictionary<string, Cms.Profile> Profiles {
+ get {
+ if (profiles == null) {
+ profiles = new Dictionary<string, Cms.Profile> ();
+ Cms.Profile p = Cms.Profile.CreateStandardRgb ();
+ profiles.Add (p.ProductName, p);
+ p = Cms.Profile.CreateAlternateRgb ();
+ profiles.Add (p.ProductName, p);
+ foreach (var path in search_dir)
+ AddProfiles (path, profiles);
+ if (XProfile != null)
+ profiles.Add ("_x_profile_", XProfile);
+ }
+ return profiles;
}
- 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);
+ static Cms.Profile x_profile;
+ public static Cms.Profile XProfile {
+ get {
+ if (x_profile == null)
+ x_profile = Cms.Profile.GetScreenProfile (Gdk.Screen.Default);
+ return x_profile;
}
- get { return destination_profile; }
}
-
- private static void GetStandardProfiles ()
- {
- Profiles.Add (Cms.Profile.CreateStandardRgb ());
- Profiles.Add (Cms.Profile.CreateAlternateRgb ());
- }
-
- private static void GetProfiles (string path)
+
+ private static void AddProfiles (string path, IDictionary<string, Cms.Profile> profs)
{
//recursive search, only RGB color profiles would be added
if (Directory.Exists (path)) {
@@ -59,157 +54,37 @@ public class ColorManagement {
foreach (string ColorProfilePath in IccColorProfilList) {
Cms.Profile profile = new Cms.Profile (ColorProfilePath);
if ((Cms.IccColorSpace)profile.ColorSpace == Cms.IccColorSpace.Rgb)
- Profiles.Add(profile);
+ profs.Add(profile.ProductName, 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);
+ profs.Add(profile.ProductName, profile);
}
string[] DirList = System.IO.Directory.GetDirectories (path);
foreach (string dir in DirList)
- GetProfiles (dir);
+ AddProfiles (dir, profs);
}
}
- private static void GetXProfile ()
+ public static void ApplyProfile (Gdk.Pixbuf pixbuf, Cms.Profile destination_profile)
{
- 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);
- }
+ ApplyProfile (pixbuf, Cms.Profile.CreateStandardRgb (), destination_profile);
}
-
- 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 ();
- GetStandardProfiles ();
- foreach (string dir in search_dir)
- GetProfiles (dir);
- GetXProfile ();
- GetSettings ();
- CreateStandardTransform ();
- }
-
- public static void ReloadSettings()
- {
- GetXProfile ();
- GetSettings ();
- CreateStandardTransform ();
- }
-
- private static void CreateStandardTransform ()
+ public static void ApplyProfile (Gdk.Pixbuf pixbuf, Cms.Profile image_profile, Cms.Profile destination_profile)
{
- Cms.Profile [] list = new Cms.Profile [] { Cms.Profile.CreateStandardRgb (), display_profile };
-
- standard_transform = new Cms.Transform (list,
- Cms.Format.Rgb8,
- Cms.Format.Rgb8,
- Cms.Intent.Perceptual, 0x0000);
- }
-
- //it returns the cached transformation
- public static Cms.Transform StandardTransform ()
- {
- if (IsEnabled)
- return standard_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 _standard_ image profile and current display profile
- public static void ApplyScreenProfile (Gdk.Pixbuf pixbuf)
- {
- if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha)
- PixbufUtils.ColorAdjust (pixbuf, pixbuf, standard_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, standard_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);
- }
+ if (pixbuf == null || pixbuf.HasAlpha)
+ return;
+
+ 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);
}
}
}
diff --git a/src/GPhotoCamera.cs b/src/GPhotoCamera.cs
index 2bce7d1..14ef388 100644
--- a/src/GPhotoCamera.cs
+++ b/src/GPhotoCamera.cs
@@ -4,6 +4,7 @@ using System.Collections;
using LibGPhoto2;
using Gdk;
using FSpot.Utils;
+using FSpot;
public class GPhotoCamera
{
@@ -185,7 +186,9 @@ public class GPhotoCamera
MemoryStream dataStream = new MemoryStream (bytedata);
try {
Gdk.Pixbuf temp = new Pixbuf (dataStream);
- FSpot.ColorManagement.ApplyScreenProfile (temp);
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (temp, screen_profile);
return temp;
} catch (Exception e) {
// Actual errors with the data libgphoto gives us have been
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index 251cce1..c91182b 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -259,10 +259,6 @@ public class MainWindow {
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();
-
pagesetup_menu_item.Activated += HandlePageSetupActivated;
toolbar = new Gtk.Toolbar ();
@@ -1060,13 +1056,11 @@ public class MainWindow {
Pixbuf thumbnail = null;
if (entry != null) {
- if (FSpot.ColorManagement.IsEnabled) {
- //FIXME
- thumbnail = entry.ShallowCopyPixbuf ();
- thumbnail = thumbnail.Copy ();
- FSpot.ColorManagement.ApplyScreenProfile (thumbnail);
- }
- else
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
+ thumbnail = entry.Pixbuf.Copy ();
+ FSpot.ColorManagement.ApplyProfile (thumbnail, screen_profile);
+ } else
thumbnail = entry.ShallowCopyPixbuf ();
}
@@ -1549,7 +1543,9 @@ public class MainWindow {
public void HandlePreferences (object sender, EventArgs args)
{
- PreferenceDialog.Show ();
+ var pref = new PreferenceDialog (GetToplevel (sender));
+ pref.Run ();
+ pref.Destroy ();
}
public void HandleManageExtensions (object sender, EventArgs args)
@@ -2544,12 +2540,6 @@ public class MainWindow {
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;
diff --git a/src/Makefile.am b/src/Makefile.am
index 040e20f..354a015 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -411,7 +411,7 @@ F_SPOT_DISTRESOURCES = \
$(srcdir)/UI.Dialog/ui/DateRangeDialog.ui \
$(srcdir)/UI.Dialog/ui/EditTagDialog.ui \
$(srcdir)/UI.Dialog/ui/EditTagIconDialog.ui \
- $(srcdir)/UI.Dialog/ui/PreferenceDialog.glade \
+ $(srcdir)/UI.Dialog/ui/PreferenceDialog.ui \
$(srcdir)/FSpot.addin.xml
F_SPOT_RESOURCES = \
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index 18d2971..84d48b2 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -397,7 +397,6 @@ namespace FSpot.Widgets {
{
switch (key) {
case Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE:
- case Preferences.COLOR_MANAGEMENT_ENABLED:
Reload ();
break;
}
@@ -405,7 +404,9 @@ namespace FSpot.Widgets {
protected override void ApplyColorTransform (Pixbuf pixbuf)
{
- FSpot.ColorManagement.ApplyScreenProfile (pixbuf);
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (pixbuf, screen_profile);
}
bool crop_helpers = true;
diff --git a/src/Preferences.cs b/src/Preferences.cs
index b7e7bf8..d4c0669 100644
--- a/src/Preferences.cs
+++ b/src/Preferences.cs
@@ -34,8 +34,6 @@ namespace FSpot
public const string VIEWER_TRANSPARENCY = APP_FSPOT + "viewer/transparency";
public const string CUSTOM_CROP_RATIOS = APP_FSPOT + "viewer/custom_crop_ratios";
- public const string COLOR_MANAGEMENT_ENABLED = APP_FSPOT + "ui/color_management_enabled";
- public const string COLOR_MANAGEMENT_USE_X_PROFILE = APP_FSPOT + "ui/color_management_use_x_profile";
public const string COLOR_MANAGEMENT_DISPLAY_PROFILE = APP_FSPOT + "ui/color_management_display_profile";
public const string COLOR_MANAGEMENT_OUTPUT_PROFILE = APP_FSPOT + "ui/color_management_output_profile";
@@ -163,6 +161,8 @@ namespace FSpot
return -15;
case GTK_RC:
+ case COLOR_MANAGEMENT_DISPLAY_PROFILE:
+ case COLOR_MANAGEMENT_OUTPUT_PROFILE:
return String.Empty;
default:
return null;
diff --git a/src/PrintOperation.cs b/src/PrintOperation.cs
index e9026f6..2b29827 100644
--- a/src/PrintOperation.cs
+++ b/src/PrintOperation.cs
@@ -114,8 +114,10 @@ namespace FSpot
{
Gdk.Pixbuf pixbuf;
try {
- pixbuf = img.Load ((int) mx, (int) my);
- FSpot.ColorManagement.ApplyPrinterProfile (pixbuf, img.GetProfile ());
+ pixbuf = img.Load ((int) mx, (int) my);
+ Cms.Profile printer_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE), out printer_profile))
+ FSpot.ColorManagement.ApplyProfile (pixbuf, img.GetProfile (), printer_profile);
} 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
diff --git a/src/TagSelectionWidget.cs b/src/TagSelectionWidget.cs
index e9294ce..4a89f5d 100644
--- a/src/TagSelectionWidget.cs
+++ b/src/TagSelectionWidget.cs
@@ -185,18 +185,16 @@ namespace FSpot {
SetBackground (renderer, tag);
- // FIXME I can't set the Pixbuf to null, not sure if it's a GTK# bug...
if (tag.SizedIcon != null) {
- if (FSpot.ColorManagement.IsEnabled) {
- //FIXME
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
+ //FIXME, we're leaking a pixbuf here
Gdk.Pixbuf temp = tag.SizedIcon.Copy();
- FSpot.ColorManagement.ApplyScreenProfile (temp);
+ FSpot.ColorManagement.ApplyProfile (temp, screen_profile);
(renderer as CellRendererPixbuf).Pixbuf = temp;
- }
- else
+ } else
(renderer as CellRendererPixbuf).Pixbuf = tag.SizedIcon;
- }
- else
+ } else
(renderer as CellRendererPixbuf).Pixbuf = empty_pixbuf;
}
diff --git a/src/TextureDisplay.cs b/src/TextureDisplay.cs
index 4fb2f7c..a1a8ce2 100644
--- a/src/TextureDisplay.cs
+++ b/src/TextureDisplay.cs
@@ -164,7 +164,9 @@ namespace FSpot {
try {
using (ImageFile img = ImageFile.Create (item.Current.DefaultVersionUri)) {
using (Gdk.Pixbuf pixbuf = img.Load ()) {
- FSpot.ColorManagement.ApplyScreenProfile (pixbuf, img.GetProfile ());
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (pixbuf, img.GetProfile (), screen_profile);
tex = new Texture (pixbuf);
}
}
diff --git a/src/UI.Dialog/DateRangeDialog.cs b/src/UI.Dialog/DateRangeDialog.cs
index 386e1b7..80a6592 100644
--- a/src/UI.Dialog/DateRangeDialog.cs
+++ b/src/UI.Dialog/DateRangeDialog.cs
@@ -86,9 +86,6 @@ namespace FSpot.UI.Dialog
(cell as CellRendererText).Text = name;
}
-
-
-
private static string GetString(int index)
{
return GetString (ranges [index]);
diff --git a/src/UI.Dialog/EditTagDialog.cs b/src/UI.Dialog/EditTagDialog.cs
index b678b64..1a482c4 100644
--- a/src/UI.Dialog/EditTagDialog.cs
+++ b/src/UI.Dialog/EditTagDialog.cs
@@ -41,10 +41,10 @@ namespace FSpot.UI.Dialog
tag_name_entry.Text = t.Name;
icon_image.Pixbuf = t.Icon;
- //FIXME
- if (FSpot.ColorManagement.IsEnabled && icon_image.Pixbuf != null) {
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
icon_image.Pixbuf = icon_image.Pixbuf.Copy();
- FSpot.ColorManagement.ApplyScreenProfile (icon_image.Pixbuf);
+ FSpot.ColorManagement.ApplyProfile (icon_image.Pixbuf, screen_profile);
}
PopulateCategoryOptionMenu (t);
@@ -120,10 +120,11 @@ namespace FSpot.UI.Dialog
}
} else if (response == (ResponseType)1)
tag.Icon = null;
-
- if (FSpot.ColorManagement.IsEnabled && tag.Icon != null) {
+
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
icon_image.Pixbuf = tag.Icon.Copy();
- FSpot.ColorManagement.ApplyScreenProfile(icon_image.Pixbuf);
+ FSpot.ColorManagement.ApplyProfile(icon_image.Pixbuf, screen_profile);
} else
icon_image.Pixbuf = tag.Icon;
diff --git a/src/UI.Dialog/EditTagIconDialog.cs b/src/UI.Dialog/EditTagIconDialog.cs
index 366de74..6bb5cea 100644
--- a/src/UI.Dialog/EditTagIconDialog.cs
+++ b/src/UI.Dialog/EditTagIconDialog.cs
@@ -46,9 +46,10 @@ namespace FSpot.UI.Dialog
Title = String.Format (Catalog.GetString ("Edit Icon for Tag {0}"), t.Name);
preview_pixbuf = t.Icon;
- if (preview_pixbuf != null && ColorManagement.IsEnabled) {
+ Cms.Profile screen_profile;
+ if (preview_pixbuf != null && FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
preview_image.Pixbuf = preview_pixbuf.Copy ();
- ColorManagement.ApplyScreenProfile (preview_image.Pixbuf);
+ ColorManagement.ApplyProfile (preview_image.Pixbuf, screen_profile);
} else
preview_image.Pixbuf = preview_pixbuf;
@@ -123,9 +124,10 @@ namespace FSpot.UI.Dialog
set {
icon_name = null;
preview_pixbuf = value;
- if (value != null && ColorManagement.IsEnabled) {
+ Cms.Profile screen_profile;
+ if (value!= null && FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
preview_image.Pixbuf = value.Copy ();
- ColorManagement.ApplyScreenProfile (preview_image.Pixbuf);
+ ColorManagement.ApplyProfile (preview_image.Pixbuf, screen_profile);
} else
preview_image.Pixbuf = value;
diff --git a/src/UI.Dialog/PreferenceDialog.cs b/src/UI.Dialog/PreferenceDialog.cs
index d4b49ef..7aa01fd 100644
--- a/src/UI.Dialog/PreferenceDialog.cs
+++ b/src/UI.Dialog/PreferenceDialog.cs
@@ -5,6 +5,9 @@
* Larry Ewing <lewing novell com>
* Stephane Delcroix <stephane delcroix org>
*
+ * Copyright (c) 2005-2009 Novell, Inc.
+ * Copyright (c) 2007 Stephane Delcroix <stephane delcroix org>
+ *
* This is free software. See COPYING for details.
*/
@@ -12,357 +15,262 @@ using System;
using System.IO;
using System.Collections.Generic;
using Gtk;
+using Mono.Unix;
using FSpot.Widgets;
namespace FSpot.UI.Dialog {
- public class ProfileList : TreeStore {
- public ProfileList () : base (typeof (Cms.Profile))
- {
- 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)
- {
- 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 = "";
- }
- }
+ public class PreferenceDialog : BuilderDialog
+ {
+ [GtkBeans.Builder.Object] FileChooserButton photosdir_chooser;
- public class PreferenceDialog : GladeDialog {
- [Glade.Widget] private CheckButton metadata_check;
- [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;
- [Glade.Widget] private HBox tagselectionhbox;
- [Glade.Widget] private Button set_saver_button;
- [Glade.Widget] private FileChooserButton photosdir_chooser;
- [Glade.Widget] private RadioButton screensaverall_radio;
- [Glade.Widget] private RadioButton screensavertagged_radio;
- [Glade.Widget] private CheckButton dbus_check;
- [Glade.Widget] private RadioButton themenone_radio;
- [Glade.Widget] private RadioButton themecustom_radio;
- [Glade.Widget] private Label themelist_label;
- [Glade.Widget] private Label restartlabel;
- [Glade.Widget] private Label themefile_label;
- [Glade.Widget] private FileChooserButton theme_filechooser;
- [Glade.Widget] private Table theme_table;
- [Glade.Widget] private Button refreshtheme_button;
- private ComboBox themelist_combo;
- private MenuButton tag_button;
+ [GtkBeans.Builder.Object] RadioButton writemetadata_radio;
+ [GtkBeans.Builder.Object] RadioButton dontwrite_radio;
+ [GtkBeans.Builder.Object] ComboBox theme_combo;
+ [GtkBeans.Builder.Object] ComboBox screenprofile_combo;
+ [GtkBeans.Builder.Object] ComboBox printprofile_combo;
- private static PreferenceDialog prefs = null;
- int screensaver_tag;
- private const string SaverCommand = "screensavers-f-spot-screensaver";
- private const string SaverMode = "single";
- Dictionary<string, string> theme_list;
-
- public PreferenceDialog () : base ("main_preferences", "PreferenceDialog.glade")
+#region public API (ctor)
+ public PreferenceDialog (Window parent) : base ("PreferenceDialog.ui", "preference_dialog")
{
- 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);
+ TransientFor = parent;
+
+ //Photos Folder
if (Global.PhotoDirectory == Preferences.Get<string> (Preferences.STORAGE_PATH)) {
- photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
photosdir_chooser.SetCurrentFolder (Global.PhotoDirectory);
+ photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
} else {
photosdir_chooser.SetCurrentFolder(Global.PhotoDirectory);
photosdir_chooser.Sensitive = false;
}
- Gtk.CellRendererText name_cell = new Gtk.CellRendererText ();
- Gtk.CellRendererText desc_cell = new Gtk.CellRendererText ();
-
- 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));
- //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.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);
-
- tag_button.Menu = tagmenu;
- tag_button.ShowAll ();
- tagselectionhbox.Add (tag_button);
-
- tagmenu.TagSelected += HandleTagMenuSelected;
- set_saver_button.Clicked += HandleUseFSpot;
- screensaverall_radio.Toggled += ToggleTagRadio;
+ //Write Metadata
+ LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
- themelist_combo = ComboBox.NewText ();
- themenone_radio.Toggled += ToggleThemeRadio;
- theme_list = new Dictionary<string, string> ();
- string gtkrc = Path.Combine ("gtk-2.0", "gtkrc");
- string [] search = {Path.Combine (Global.HomeDirectory, ".themes"), "/usr/share/themes"};
+ //Screen profile
+ ListStore sprofiles = new ListStore (typeof (string), typeof (int));
+ sprofiles.AppendValues (Catalog.GetString ("None"), 0);
+ 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);
+ CellRendererText profilecellrenderer = new CellRendererText ();
+ profilecellrenderer.Ellipsize = Pango.EllipsizeMode.End;
+
+ screenprofile_combo.Model = sprofiles;
+ screenprofile_combo.PackStart (profilecellrenderer, true);
+ screenprofile_combo.RowSeparatorFunc = ProfileSeparatorFunc;
+ screenprofile_combo.SetCellDataFunc (profilecellrenderer, ProfileCellFunc);
+ LoadPreference (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE);
+
+ //Print profile
+ 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);
+ printprofile_combo.Model = pprofiles;
+ printprofile_combo.PackStart (profilecellrenderer, true);
+ printprofile_combo.RowSeparatorFunc = ProfileSeparatorFunc;
+ printprofile_combo.SetCellDataFunc (profilecellrenderer, ProfileCellFunc);
+ LoadPreference (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE);
+
+ //Theme chooser
+ ListStore themes = new ListStore (typeof (string), typeof (string));
+ themes.AppendValues (Catalog.GetString ("Standard theme"), null);
+ themes.AppendValues (null, null); //Separator
+ string gtkrc = System.IO.Path.Combine ("gtk-2.0", "gtkrc");
+ string [] search = {System.IO.Path.Combine (Global.HomeDirectory, ".themes"), "/usr/share/themes"};
foreach (string path in search)
- if (Directory.Exists (path))
- foreach (string dir in Directory.GetDirectories (path))
- if (File.Exists (Path.Combine (dir, gtkrc)) && !theme_list.ContainsKey (Path.GetFileName (dir)))
- theme_list.Add (Path.GetFileName (dir), Path.Combine (dir, gtkrc));
-
- string active_theme = Preferences.Get<string> (Preferences.GTK_RC);
- int it = 0;
- foreach (string theme in theme_list.Keys) {
- themelist_combo.AppendText (Path.GetFileName (theme));
- if (active_theme.Contains (Path.DirectorySeparatorChar + Path.GetFileName (theme) + Path.DirectorySeparatorChar))
- themelist_combo.Active = it;
- it ++;
- }
-
- theme_table.Attach (themelist_combo, 2, 3, 0, 1);
- themelist_combo.Changed += HandleThemeComboChanged;
- themelist_combo.Show ();
- theme_filechooser.Visible = themefile_label.Visible = FSpot.Utils.Log.Debugging;
-
- themelist_combo.Sensitive = theme_filechooser.Sensitive = themecustom_radio.Active;
- if (File.Exists (active_theme))
- theme_filechooser.SetFilename (Preferences.Get<string> (Preferences.GTK_RC));
- theme_filechooser.SelectionChanged += HandleThemeFileActivated;
- themecustom_radio.Active = (active_theme != String.Empty);
-
- restartlabel.Visible = false;
-
-#if DEBUGTHEMES
- refreshtheme_button = true;
-#endif
+ if (System.IO.Directory.Exists (path))
+ foreach (string dir in System.IO.Directory.GetDirectories (path))
+ if (File.Exists (System.IO.Path.Combine (dir, gtkrc)))
+ themes.AppendValues (System.IO.Path.GetFileName (dir), System.IO.Path.Combine (dir, gtkrc));
+ CellRenderer themecellrenderer = new CellRendererText ();
+ theme_combo.Model = themes;
+ theme_combo.PackStart (themecellrenderer, true);
+ theme_combo.RowSeparatorFunc = ThemeSeparatorFunc;
+ theme_combo.SetCellDataFunc (themecellrenderer, ThemeCellFunc);
+ LoadPreference (Preferences.GTK_RC);
Preferences.SettingChanged += OnPreferencesChanged;
- this.Dialog.Destroyed += HandleDestroyed;
}
+#endregion
- 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)
+#region preferences
+ void OnPreferencesChanged (object sender, NotifyEventArgs 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();
- }
+ LoadPreference (args.Key);
}
- private void HandleDisplayChanged (object sender, System.EventArgs args)
+ void LoadPreference (string key)
{
- TreeIter iter;
-// 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();
+ string pref;
+ int i;
+ switch (key) {
+ case Preferences.STORAGE_PATH:
+ photosdir_chooser.SetCurrentFolder (Preferences.Get<string> (key));
+ break;
+ case Preferences.METADATA_EMBED_IN_IMAGE:
+ bool embed_active = Preferences.Get<bool> (key);
+ if (writemetadata_radio.Active != embed_active) {
+ if (embed_active)
+ writemetadata_radio.Active = true;
+ else
+ dontwrite_radio.Active = true;
+ }
+ break;
+ case Preferences.GTK_RC:
+ pref = Preferences.Get<string> (key);
+ if (String.IsNullOrEmpty (pref)) {
+ theme_combo.Active = 0;
+ break;
+ }
+ i = 0;
+ foreach (object [] row in theme_combo.Model as ListStore) {
+ if (pref == (string)row [1]) {
+ theme_combo.Active = i;
+ break;
+ }
+ i++;
+ }
+ break;
+ case Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE:
+ pref = Preferences.Get<string> (key);
+ if (String.IsNullOrEmpty (pref)) {
+ screenprofile_combo.Active = 0;
+ break;
+ }
+ if (pref == "_x_profile_" && FSpot.ColorManagement.XProfile != null) {
+ screenprofile_combo.Active = 1;
+ break;
+ }
+ i = 0;
+ foreach (object [] row in screenprofile_combo.Model as ListStore) {
+ if (pref == (string)row [0]) {
+ screenprofile_combo.Active = i;
+ break;
+ }
+ i++;
+ }
+ break;
+ case Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE:
+ pref = Preferences.Get<string> (key);
+ if (String.IsNullOrEmpty (pref)) {
+ printprofile_combo.Active = 0;
+ break;
+ }
+ i = 0;
+ foreach (object [] row in printprofile_combo.Model as ListStore) {
+ if (pref == (string)row [0]) {
+ printprofile_combo.Active = i;
+ break;
+ }
+ i++;
+ }
+ break;
}
}
-
- private void HandleDestinationChanged (object sender, System.EventArgs args)
- {
- TreeIter iter;
- if (destination_combo.GetActiveIter (out iter))
- FSpot.ColorManagement.DestinationProfile = (Cms.Profile) destination_combo.Model.GetValue (iter, 0);
- }
-
- private void HandleTagMenuSelected (Tag t)
- {
- tag_button.Label = t.Name;
- screensaver_tag = (int) t.Id;
- Preferences.Set (Preferences.SCREENSAVER_TAG, (int) t.Id);
- }
-
- private void HandleUseFSpot (object sender, EventArgs args)
- {
- Preferences.Set (Preferences.GNOME_SCREENSAVER_MODE, SaverMode);
- Preferences.Set (Preferences.GNOME_SCREENSAVER_THEME, new string [] { SaverCommand });
- }
+#endregion
- private void ToggleTagRadio (object o, System.EventArgs e)
+#region event handlers
+ void HandlePhotosdirChanged (object sender, System.EventArgs args)
{
- tag_button.Sensitive = (screensavertagged_radio.Active);
- if (screensaverall_radio.Active)
- Preferences.Set (Preferences.SCREENSAVER_TAG, 0);
- else
- HandleTagMenuSelected (((tag_button.Menu as Menu).Active as TagMenu.TagMenuItem).Value);
+ photosdir_chooser.CurrentFolderChanged -= HandlePhotosdirChanged;
+ Preferences.Set (Preferences.STORAGE_PATH, photosdir_chooser.Filename);
+ photosdir_chooser.CurrentFolderChanged += HandlePhotosdirChanged;
+ Global.PhotoDirectory = photosdir_chooser.Filename;
}
- void ToggleThemeRadio (object o, EventArgs e)
+ void HandleWritemetadataGroupChanged (object sender, System.EventArgs args)
{
- themelist_combo.Sensitive = theme_filechooser.Sensitive = themecustom_radio.Active;
- if (themenone_radio.Active) {
- Preferences.Set (Preferences.GTK_RC, String.Empty);
- Gtk.Rc.DefaultFiles = Global.DefaultRcFiles;
- Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
- } else {
- TreeIter iter;
- if (themelist_combo.GetActiveIter (out iter)) {
- Preferences.Set (Preferences.GTK_RC, theme_list [(themelist_combo.Model.GetValue (iter, 0)) as string]);
- Gtk.Rc.DefaultFiles = Global.DefaultRcFiles;
- Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
- Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
- }
- }
+ Preferences.Set (Preferences.METADATA_EMBED_IN_IMAGE, writemetadata_radio.Active);
}
- void HandleThemeComboChanged (object o, EventArgs e)
+ void HandleThemeComboChanged (object sender, EventArgs e)
{
- if (o == null)
+ ComboBox combo = sender as ComboBox;
+ if (combo == null)
return;
TreeIter iter;
- if ((o as ComboBox).GetActiveIter (out iter))
- Preferences.Set (Preferences.GTK_RC, theme_list [((o as ComboBox).Model.GetValue (iter, 0)) as string]);
+ if (combo.GetActiveIter (out iter)) {
+ string gtkrc = (string)combo.Model.GetValue (iter, 1);
+ if (!String.IsNullOrEmpty (gtkrc))
+ Preferences.Set (Preferences.GTK_RC, gtkrc);
+ else
+ Preferences.Set (Preferences.GTK_RC, String.Empty);
+ }
Gtk.Rc.DefaultFiles = Global.DefaultRcFiles;
Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
}
- void HandleThemeFileActivated (object o, EventArgs e)
+ void HandleScreenProfileComboChanged (object sender, EventArgs e)
{
- if (theme_filechooser.Filename != null && theme_filechooser.Filename != Preferences.Get<string> (Preferences.GTK_RC)) {
- Preferences.Set (Preferences.GTK_RC, theme_filechooser.Filename);
- Gtk.Rc.DefaultFiles = Global.DefaultRcFiles;
- Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
- Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
+ ComboBox combo = sender as ComboBox;
+ if (combo == null)
+ return;
+ TreeIter iter;
+ if (combo.GetActiveIter (out iter)) {
+ switch ((int)combo.Model.GetValue (iter, 1)) {
+ case 0:
+ Preferences.Set (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE, String.Empty);
+ break;
+ case -1:
+ Preferences.Set (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE, "_x_profile_");
+ break;
+ case 1:
+ Preferences.Set (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE, (string)combo.Model.GetValue (iter, 0));
+ break;
+ }
}
}
- void OnPreferencesChanged (object sender, NotifyEventArgs args)
- {
- LoadPreference (args.Key);
- }
-
- void MetadataToggled (object sender, System.EventArgs args)
- {
- Preferences.Set (Preferences.METADATA_EMBED_IN_IMAGE, metadata_check.Active);
- }
-
- void HandlePhotosdirChanged (object sender, System.EventArgs args)
+ void HandlePrintProfileComboChanged (object sender, EventArgs e)
{
- Preferences.Set (Preferences.STORAGE_PATH, photosdir_chooser.Filename);
- Global.PhotoDirectory = photosdir_chooser.Filename;
- }
-
-
- void HandleRefreshTheme (object o, EventArgs e)
- {
- Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
+ ComboBox combo = sender as ComboBox;
+ if (combo == null)
+ return;
+ TreeIter iter;
+ if (combo.GetActiveIter (out iter)) {
+ switch ((int)combo.Model.GetValue (iter, 1)) {
+ case 0:
+ Preferences.Set (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE, String.Empty);
+ break;
+ case 1:
+ Preferences.Set (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE, (string)combo.Model.GetValue (iter, 0));
+ break;
+ }
+ }
}
+#endregion
- void LoadPreference (string key)
+#region Gtk widgetry
+ void ThemeCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
- switch (key) {
- case Preferences.METADATA_EMBED_IN_IMAGE:
- bool embed_active = Preferences.Get<bool> (key);
- if (metadata_check.Active != embed_active)
- metadata_check.Active = embed_active;
- break;
- case Preferences.COLOR_MANAGEMENT_ENABLED:
- bool color_active = Preferences.Get<bool> (key);
- if (colormanagement_check.Active != color_active)
- colormanagement_check.Active = color_active;
- break;
- case Preferences.COLOR_MANAGEMENT_USE_X_PROFILE:
- bool use_x_active = Preferences.Get<bool> (key);
- if (use_x_profile_check.Active != use_x_active)
- use_x_profile_check.Active = use_x_active;
- break;
- case Preferences.SCREENSAVER_TAG:
- screensaver_tag = Preferences.Get<int> (key);
- Tag t = MainWindow.Toplevel.Database.Tags.GetTagById (screensaver_tag);
- if (screensaver_tag == 0 || t == null) {
- screensaverall_radio.Active = true;
- tag_button.Sensitive = false;
- } else {
- screensavertagged_radio.Active = true;
- tag_button.Label = t.Name;
- }
- break;
- case Preferences.GNOME_SCREENSAVER_THEME:
- case Preferences.GNOME_SCREENSAVER_MODE:
- string [] theme = Preferences.Get<string []> (Preferences.GNOME_SCREENSAVER_THEME);
- string mode = Preferences.Get<string> (Preferences.GNOME_SCREENSAVER_MODE);
-
- bool sensitive = mode != SaverMode;
- sensitive |= (theme == null || theme.Length != 1 || theme [0] != SaverCommand);
-
- set_saver_button.Sensitive = sensitive;
- break;
- case Preferences.STORAGE_PATH:
- photosdir_chooser.SetCurrentFolder (Preferences.Get<string> (key));
- break;
- case Preferences.GTK_RC:
- themenone_radio.Active = (Preferences.Get<string> (key) == String.Empty);
- themecustom_radio.Active = (Preferences.Get<string> (key) != String.Empty);
- if (theme_filechooser.Sensitive)
- theme_filechooser.SetFilename (Preferences.Get<string> (key));
- break;
- }
+ string name = (string)tree_model.GetValue (iter, 0);
+ (cell as CellRendererText).Text = name;
}
- void HandleClose (object sender, EventArgs args)
+ bool ThemeSeparatorFunc (TreeModel tree_model, TreeIter iter)
{
- this.Dialog.Destroy ();
+ return tree_model.GetValue (iter, 0) == null;
}
- private void HandleDestroyed (object sender, EventArgs args)
+ void ProfileCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
- prefs = null;
+ string name = (string)tree_model.GetValue (iter, 0);
+ (cell as CellRendererText).Text = name;
}
- public static void Show ()
+ bool ProfileSeparatorFunc (TreeModel tree_model, TreeIter iter)
{
- if (prefs == null)
- prefs = new PreferenceDialog ();
-
- prefs.Dialog.Present ();
+ return tree_model.GetValue (iter, 0) == null;
}
+#endregion
}
}
diff --git a/src/Widgets/Filmstrip.cs b/src/Widgets/Filmstrip.cs
index 57a5555..4427a74 100644
--- a/src/Widgets/Filmstrip.cs
+++ b/src/Widgets/Filmstrip.cs
@@ -548,10 +548,12 @@ namespace FSpot.Widgets
}
- //FIXME
- if (FSpot.ColorManagement.IsEnabled) {
- current = current.Copy ();
- FSpot.ColorManagement.ApplyScreenProfile (current);
+ //FIXME: we might end up leaking a pixbuf here
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
+ Pixbuf t = current.Copy ();
+ current = t;
+ FSpot.ColorManagement.ApplyProfile (current, screen_profile);
}
if (!highlighted)
diff --git a/src/Widgets/IconView.cs b/src/Widgets/IconView.cs
index 45f0f63..7ea6a6f 100644
--- a/src/Widgets/IconView.cs
+++ b/src/Widgets/IconView.cs
@@ -863,10 +863,12 @@ namespace FSpot.Widgets
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);
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
+ Pixbuf t = temp_thumbnail.Copy ();
+ temp_thumbnail.Dispose ();
+ temp_thumbnail = t;
+ FSpot.ColorManagement.ApplyProfile (temp_thumbnail, screen_profile);
}
temp_thumbnail.RenderToDrawable (BinWindow, Style.WhiteGC,
draw.X - region.X,
@@ -988,7 +990,9 @@ namespace FSpot.Widgets
InterpType.Bilinear);
}
- FSpot.ColorManagement.ApplyScreenProfile (scaled_icon);
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (scaled_icon, screen_profile);
scaled_icon.RenderToDrawable (BinWindow, Style.WhiteGC,
region.X - tag_bounds.X,
diff --git a/src/Widgets/TagView.cs b/src/Widgets/TagView.cs
index 3c701b4..d97f7a9 100644
--- a/src/Widgets/TagView.cs
+++ b/src/Widgets/TagView.cs
@@ -95,7 +95,9 @@ public class TagView : EventBox {
} else {
scaled_icon = icon.ScaleSimple (thumbnail_size, thumbnail_size, InterpType.Bilinear);
}
- FSpot.ColorManagement.ApplyScreenProfile (scaled_icon);
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (scaled_icon, screen_profile);
scaled_icon.RenderToDrawable (GdkWindow, Style.WhiteGC,
0, 0, tag_x, tag_y, thumbnail_size, thumbnail_size,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]