/*
5 * Authors: see git history
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
50 for (
auto &&filename : get_filenames(directory_path.first, {
".icc",
".icm"})) {
53 g_warning(
"System::load_profiles: '%s' is not an ICC file!", filename.c_str());
60 if (other->getName() == profile->getName() && other->getId() != profile->getId()) {
61 std::cerr <<
"System::load_profiles: Different ICC profile with duplicate name: "
62 << profile->getName() <<
":" << std::endl;
63 std::cerr <<
" " << profile->getPath() <<
" (" << profile->getId() <<
")" << std::endl;
64 std::cerr <<
" " << other->getPath() <<
" (" << other->getId() <<
")" << std::endl;
68 _profiles.emplace_back(std::move(profile));
78 paths.emplace_back(Glib::build_filename(Glib::get_user_data_dir(),
"color",
"icc"),
true);
84 paths.emplace_back(Glib::build_filename(Glib::get_user_data_dir(),
"icc"),
true);
85 paths.emplace_back(Glib::build_filename(Glib::get_home_dir(),
".color",
"icc"),
true);
88 paths.emplace_back(
"/var/lib/color/icc",
false);
89 paths.emplace_back(
"/var/lib/colord/icc",
false);
91 auto data_directories = Glib::get_system_data_dirs();
92 for (
auto const &data_directory : data_directories) {
93 paths.emplace_back(Glib::build_filename(data_directory,
"color",
"icc"),
false);
97 paths.emplace_back(
"/System/Library/ColorSync/Profiles",
false);
98 paths.emplace_back(
"/Library/ColorSync/Profiles",
false);
100 paths.emplace_back(Glib::build_filename(Glib::get_home_dir(),
"Library",
"ColorSync",
"Profiles"),
true);
104 wchar_t pathBuf[MAX_PATH + 1];
106 DWORD pathSize =
sizeof(pathBuf);
107 g_assert(
sizeof(
wchar_t) ==
sizeof(gunichar2));
108 if (GetColorDirectoryW(NULL, pathBuf, &pathSize)) {
109 auto utf8Path = g_utf16_to_utf8((gunichar2 *)(&pathBuf[0]), -1, NULL, NULL, NULL);
110 if (!g_utf8_validate(utf8Path, -1, NULL)) {
111 g_warning(
"GetColorDirectoryW() resulted in invalid UTF-8");
113 paths.emplace_back(utf8Path,
false);
146 _paths.emplace_back(std::move(path), is_user);
165 std::string uri = prefs->
getString(
"/options/displayprofile/uri");
169 if (!profile->isForDisplay()) {
170 g_warning(
"System::get_display_profile: Not a display (display) profile: %s", uri.c_str());
184 std::vector<std::shared_ptr<Profile>>
result;
188 if (profile->isForDisplay()) {
189 result.push_back(profile);
201 std::vector<std::shared_ptr<Profile>>
result;
205 if (profile->getProfileClass() == cmsSigOutputClass) {
206 result.push_back(profile);
224 if (
name == profile->getName() ||
name == profile->getId() ||
name == profile->getPath()) {
228 static std::shared_ptr<Profile>
not_found;
242 bool need_to_update =
false;
245 bool display = prefs->
getIntLimited(
"/options/displayprofile/enabled",
false);
246 int display_intent = prefs->
getIntLimited(
"/options/displayprofile/intent", 0, 0, 3);
249 need_to_update =
true;
256 if (need_to_update) {
257 if (display_profile) {
static bool isIccFile(std::string const &filepath)
static bool sortByName(std::shared_ptr< Profile > const &p1, std::shared_ptr< Profile > const &p2)
static std::shared_ptr< Profile > create_srgb()
Construct the default lcms sRGB color profile and return.
static std::shared_ptr< Profile > create_from_uri(std::string path, bool in_home=false)
Construct a color profile object from a uri.
Inkscape::PrefObserver _prefs_observer
void addDirectoryPath(std::string path, bool is_user)
Replace all generated profile paths with this single path, useful for testing.
const std::shared_ptr< Profile > & getProfile(std::string const &name) const
Return the profile object which is matched by the given name, id or path.
void clearDirectoryPaths()
Remove all directory paths that might have been generated (useful for refreshing)
std::vector< std::shared_ptr< Profile > > getDisplayProfiles() const
Returns a list of profiles that can apply to the display (display), sorted by their internal names.
std::vector< std::shared_ptr< Profile > > getOutputProfiles() const
Return vector of profiles which can be used for cms output.
std::vector< std::shared_ptr< Profile > > getProfiles() const
Returns a list of profiles sorted by their internal names.
const std::shared_ptr< Profile > & getDisplayProfile(bool &updated)
Get the user set display profile, if set.
std::shared_ptr< Profile > _display_profile
DirPaths const & getDirectoryPaths()
Create list of all directories where ICC profiles are expected to be found.
const std::shared_ptr< Transform > & getDisplayTransform()
Get the color managed trasform for the screen.
std::vector< std::shared_ptr< Profile > > _profiles
std::shared_ptr< Transform > _display_transform
void refreshProfiles()
Search for system ICC profile files and add them to list.
Preference storage class.
Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &def="")
Retrieve an UTF-8 string.
static Preferences * get()
Access the singleton Preferences object.
std::unique_ptr< PreferencesObserver > createObserver(Glib::ustring path, std::function< void(const Preferences::Entry &new_value)> callback)
Create an observer watching preference 'path' and calling provided function when preference changes.
int getIntLimited(Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX)
Retrieve a limited integer.
std::vector< std::pair< std::string, bool > > DirPaths
vector< vector< Point > > paths
static DirPaths get_directory_paths()
std::vector< std::string > get_filenames(Type type, std::vector< const char * > const &extensions, std::vector< const char * > const &exclusions)
Authors: see git history.
Inkscape::IO::Resource - simple resource API.