summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b73e696)
raw | patch | inline | side by side (parent: b73e696)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 1 Oct 2007 03:55:20 +0000 (03:55 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 1 Oct 2007 03:55:20 +0000 (03:55 +0000) |
index 21e6002ee58a812915acf8d0fa0541a0e043044c..93d327f423c159d68292cdaf9fe3566555b137b2 100644 (file)
--- a/src/color-profile-fns.h
+++ b/src/color-profile-fns.h
#include <glib-object.h>
#include <glib/gtypes.h>
#if ENABLE_LCMS
+#include <vector>
+#include <glibmm/ustring.h>
#include <lcms.h>
#endif // ENABLE_LCMS
cmsHPROFILE colorprofile_get_system_profile_handle();
+std::vector<Glib::ustring> colorprofile_get_display_names();
+
+Glib::ustring get_path_for_profile(Glib::ustring const& name);
+
#endif
} // namespace Inkscape
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index dbd212bd619fe911f891f640342c5d5005878211..03a975a0cac248d922a1acf4a3b683dd35cd5881 100644 (file)
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -369,12 +369,132 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte
}
+#include <io/sys.h>
+
+class ProfileInfo
+{
+public:
+ ProfileInfo( cmsHPROFILE, Glib::ustring const & path );
+
+ Glib::ustring const& getName() {return _name;}
+ Glib::ustring const& getPath() {return _path;}
+ icColorSpaceSignature getSpace() {return _profileSpace;}
+ icProfileClassSignature getClass() {return _profileClass;}
+
+private:
+ Glib::ustring _path;
+ Glib::ustring _name;
+ icColorSpaceSignature _profileSpace;
+ icProfileClassSignature _profileClass;
+};
+
+
+ProfileInfo::ProfileInfo( cmsHPROFILE prof, Glib::ustring const & path )
+{
+ _path = path;
+ _name = cmsTakeProductName(prof);
+ _profileSpace = cmsGetColorSpace( prof );
+ _profileClass = cmsGetDeviceClass( prof );
+}
+
+
+
+static std::vector<ProfileInfo> knownProfiles;
+
+std::vector<Glib::ustring> Inkscape::colorprofile_get_display_names()
+{
+ std::vector<Glib::ustring> result;
+
+ for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
+ if ( it->getClass() == icSigDisplayClass && it->getSpace() == icSigRgbData ) {
+ result.push_back( it->getName() );
+ }
+ }
+
+ return result;
+}
+
+Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name)
+{
+ Glib::ustring result;
+
+ for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
+ if ( name == it->getName() ) {
+ result = it->getPath();
+ break;
+ }
+ }
+
+ return result;
+}
+
+static void findThings() {
+ std::list<gchar *> sources;
+
+ gchar* base = profile_path("XXX");
+ {
+ gchar* base2 = g_path_get_dirname(base);
+ g_free(base);
+ base = base2;
+ base2 = g_path_get_dirname(base);
+ g_free(base);
+ base = base2;
+ }
+
+ sources.push_back(g_build_filename( base, ".color", "icc", NULL )); // first try user's local dir
+ sources.push_back(g_strdup("/usr/local/share/color/icc"));
+ sources.push_back(g_strdup("/usr/share/color/icc"));
+
+ while (!sources.empty()) {
+ gchar *dirname = sources.front();
+ if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
+ GError *err = 0;
+ GDir *dir = g_dir_open(dirname, 0, &err);
+
+ if (dir) {
+ for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) {
+ gchar *filepath = g_build_filename(dirname, file, NULL);
+ cmsHPROFILE prof = cmsOpenProfileFromFile( filepath, "r" );
+ if ( prof ) {
+ ProfileInfo info( prof, Glib::filename_to_utf8( filepath ) );
+ cmsCloseProfile( prof );
+
+ bool sameName = false;
+ for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
+ if ( it->getName() == info.getName() ) {
+ sameName = true;
+ break;
+ }
+ }
+
+ if ( !sameName ) {
+ knownProfiles.push_back(info);
+ }
+ }
+
+ g_free(filepath);
+ }
+ }
+ }
+
+ // toss the dirname
+ g_free(dirname);
+ sources.pop_front();
+ }
+}
+
cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle()
{
static cmsHPROFILE theOne = 0;
static std::string lastURI;
+ static bool init = false;
+ if ( !init ) {
+ findThings();
+ init = true;
+ }
+
long long int which = prefs_get_int_attribute_limited( "options.displayprofile", "enable", 0, 0, 1 );
gchar const * uri = prefs_get_string_attribute("options.displayprofile", "uri");
index 436d5cce676b2a02c83326720ae03b8883bfc8f6..59132349f423f6e8c4efff6233768bcbb759804d 100644 (file)
#include "xml/repr.h"
#include "ui/widget/style-swatch.h"
#include "display/nr-filter-gaussian.h"
+#include "color-profile-fns.h"
namespace Inkscape {
namespace UI {
(*it)->requestRedraw();
}
}
+
+static void profileComboChanged( Gtk::ComboBoxText* combo )
+{
+ Glib::ustring active = combo->get_active_text();
+
+ Glib::ustring path = get_path_for_profile(active);
+ if ( !path.empty() ) {
+ prefs_set_string_attribute( "options.displayprofile", "uri", path.c_str() );
+ forceUpdates();
+ }
+}
#endif // ENABLE_LCMS
+
void InkscapePreferences::initPageMisc()
{
_misc_comment.init( _("Add label comments to printing output"), "printing.debug", "show-label-comments", false);
_misc_cms_display.init( _("Enable display calibration"), "options.displayprofile", "enable", false);
_page_misc.add_line( false, "", _misc_cms_display, "",
_("Enables application of the display using an ICC profile."), true);
- _misc_cms_display_profile.init("options.displayprofile", "uri");
+
_page_misc.add_line( false, _("Display profile:"), _misc_cms_display_profile, "",
- _("The ICC profile to use to calibrate display output."), true);
+ _("The ICC profile to use to calibrate display output."), true);
#if ENABLE_LCMS
- _misc_cms_display.signal_toggled().connect( sigc::ptr_fun(forceUpdates) );
+ {
+ std::vector<Glib::ustring> names = ::Inkscape::colorprofile_get_display_names();
+ Glib::ustring current = prefs_get_string_attribute( "options.displayprofile", "uri" );
+
+ gint index = 0;
+ for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) {
+ _misc_cms_display_profile.append_text( *it );
+ Glib::ustring path = get_path_for_profile(*it);
+ if ( !path.empty() && path == current ) {
+ _misc_cms_display_profile.set_active(index);
+ }
+ index++;
+ }
+ }
- _misc_cms_display_profile.signal_selection_changed().connect( sigc::ptr_fun(forceUpdates) );
+ _misc_cms_display.signal_toggled().connect( sigc::ptr_fun(forceUpdates) );
+ _misc_cms_display_profile.signal_changed().connect( sigc::bind( sigc::ptr_fun(profileComboChanged), &_misc_cms_display_profile) );
#else
// disable it, but leave it visible
_misc_cms_display.set_sensitive( false );
index eff0685691f1741a5fe1cf220f9eb0edd459e11b..5dafd40516722e9d1d366820897d35fda74bb2bb 100644 (file)
PrefCheckButton _misc_small_toolbar;
PrefCombo _misc_overs_bitmap;
- PrefCheckButton _misc_cms_display;
- PrefFileButton _misc_cms_display_profile;
+ PrefCheckButton _misc_cms_display;
+ Gtk::ComboBoxText _misc_cms_display_profile;
PrefEntryButtonHBox _importexport_ocal_url;
PrefEntry _importexport_ocal_username;