summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2017-07-05 14:11:31 +0000
committerMartin Owens <doctormo@gmail.com>2017-07-05 14:11:31 +0000
commit23b717b1fbb4e25d424a08d2f663143be0e72a09 (patch)
tree4f20d1191e9911947c7106d37477f5e819ff870c /src/ui
parentFix 'direction' gui. (diff)
parentUse std::transform instead of a for loop (diff)
downloadinkscape-23b717b1fbb4e25d424a08d2f663143be0e72a09.tar.gz
inkscape-23b717b1fbb4e25d424a08d2f663143be0e72a09.zip
Merge branch 'houz/inkscape-color-profiles-cleanup'
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/document-properties.cpp35
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp5
-rw-r--r--src/ui/widget/color-icc-selector.cpp16
3 files changed, 35 insertions, 21 deletions
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 1b074bb0c..0fff45762 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -386,26 +386,25 @@ void DocumentProperties::populate_available_profiles(){
_AvailableProfilesListStore->clear(); // Clear any existing items in the combo box
// Iterate through the list of profiles and add the name to the combo box.
- std::vector<std::pair<std::pair<Glib::ustring, bool>, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames();
bool home = true; // initial value doesn't matter, it's just to avoid a compiler warning
- for ( std::vector<std::pair<std::pair<Glib::ustring, bool>, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) {
+ bool first = true;
+ for (auto &profile: ColorProfile::getProfileFilesWithNames()) {
Gtk::TreeModel::Row row;
- Glib::ustring file = it->first.first;
- Glib::ustring name = it->second;
// add a separator between profiles from the user's home directory and system profiles
- if (it != pairs.begin() && it->first.second != home)
+ if (!first && profile.isInHome != home)
{
row = *(_AvailableProfilesListStore->append());
row[_AvailableProfilesListColumns.fileColumn] = "<separator>";
row[_AvailableProfilesListColumns.nameColumn] = "<separator>";
row[_AvailableProfilesListColumns.separatorColumn] = true;
}
- home = it->first.second;
+ home = profile.isInHome;
+ first = false;
row = *(_AvailableProfilesListStore->append());
- row[_AvailableProfilesListColumns.fileColumn] = file;
- row[_AvailableProfilesListColumns.nameColumn] = name;
+ row[_AvailableProfilesListColumns.fileColumn] = profile.filename;
+ row[_AvailableProfilesListColumns.nameColumn] = profile.name;
row[_AvailableProfilesListColumns.separatorColumn] = false;
}
}
@@ -459,10 +458,11 @@ void DocumentProperties::linkSelectedProfile()
g_warning("No color profile available.");
return;
}
-
+
// Read the filename and description from the list of available profiles
Glib::ustring file = (*iter)[_AvailableProfilesListColumns.fileColumn];
Glib::ustring name = (*iter)[_AvailableProfilesListColumns.nameColumn];
+
std::vector<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" );
for (std::vector<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) {
SPObject* obj = *it;
@@ -514,6 +514,9 @@ struct _cmp {
}
};
+template <typename From, typename To>
+struct static_caster { To * operator () (From * value) const { return static_cast<To *>(value); } };
+
void DocumentProperties::populate_linked_profiles_box()
{
_LinkedProfilesListStore->clear();
@@ -521,12 +524,16 @@ void DocumentProperties::populate_linked_profiles_box()
if (! current.empty()) {
_emb_profiles_observer.set((*(current.begin()))->parent);
}
- std::set<SPObject *, _cmp> _current (current.begin(), current.end());
- for (std::set<SPObject *, _cmp>::const_iterator it = _current.begin(); it != _current.end(); ++it) {
- SPObject* obj = *it;
- Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
+
+ std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current;
+ std::transform(current.begin(),
+ current.end(),
+ std::inserter(_current, _current.begin()),
+ static_caster<SPObject, Inkscape::ColorProfile>());
+
+ for (auto &profile: _current) {
Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append());
- row[_LinkedProfilesListColumns.nameColumn] = prof->name;
+ row[_LinkedProfilesListColumns.nameColumn] = profile->name;
// row[_LinkedProfilesListColumns.previewColumn] = "Color Preview";
}
}
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 1ad44941f..d946bac82 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -986,9 +986,8 @@ void InkscapePreferences::initPageIO()
_page_cms.add_group_header( _("Display adjustment"));
Glib::ustring tmpStr;
- std::vector<std::pair<Glib::ustring, bool> > sources = ColorProfile::getBaseProfileDirs();
- for ( std::vector<std::pair<Glib::ustring, bool> >::const_iterator it = sources.begin(); it != sources.end(); ++it ) {
- gchar* part = g_strdup_printf( "\n%s", it->first.c_str() );
+ for (auto &profile: ColorProfile::getBaseProfileDirs()) {
+ gchar* part = g_strdup_printf( "\n%s", profile.filename.c_str() );
tmpStr += part;
g_free(part);
}
diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp
index 616e9afa8..f1dd92746 100644
--- a/src/ui/widget/color-icc-selector.cpp
+++ b/src/ui/widget/color-icc-selector.cpp
@@ -663,6 +663,9 @@ struct _cmp {
}
};
+template <typename From, typename To>
+struct static_caster { To * operator () (From * value) const { return static_cast<To *>(value); } };
+
void ColorICCSelectorImpl::_profilesChanged(std::string const &name)
{
GtkComboBox *combo = GTK_COMBO_BOX(_profileSel);
@@ -680,10 +683,15 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name)
int index = 1;
std::vector<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile");
- std::set<SPObject *, _cmp> _current(current.begin(), current.end());
- for (std::set<SPObject *, _cmp>::const_iterator it = _current.begin(); it != _current.end(); ++it) {
- SPObject *obj = *it;
- Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj);
+
+ std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current;
+ std::transform(current.begin(),
+ current.end(),
+ std::inserter(_current, _current.begin()),
+ static_caster<SPObject, Inkscape::ColorProfile>());
+
+ for (auto &it: _current) {
+ Inkscape::ColorProfile *prof = it;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1);