Author: post
Date: 2010-01-19 21:01:31 +0100 (Tue, 19 Jan 2010)
New Revision: 3040
Modified:
branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.c
branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.h
branches/rawstudio-ng-color/librawstudio/rs-dcp-file.c
branches/rawstudio-ng-color/librawstudio/rs-dcp-file.h
branches/rawstudio-ng-color/src/rs-cache.c
branches/rawstudio-ng-color/src/rs-camera-db.c
Log:
Use an id for recognizing DCP profiles that consist of filename, camera id and
profile name.
Modified: branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.c
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.c 2010-01-19
19:14:35 UTC (rev 3039)
+++ branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.c 2010-01-19
20:01:31 UTC (rev 3040)
@@ -111,7 +111,7 @@
}
RSDcpFile *
-rs_dcp_factory_find_from_path(RSDcpFactory *factory, const gchar *path)
+rs_dcp_factory_find_from_id(RSDcpFactory *factory, const gchar *id)
{
RSDcpFile *ret = NULL;
GList *node;
@@ -120,8 +120,16 @@
{
RSDcpFile *dcp = RS_DCP_FILE(node->data);
- if (g_str_equal(path,
rs_tiff_get_filename_nopath(RS_TIFF(dcp))))
+ gchar* dcp_id = rs_dcp_get_id(dcp);
+
+ if (g_str_equal(id, dcp_id))
+ {
+ if (ret)
+ g_warning("WARNING: Duplicate profiles detected
in file: %s, for %s, named:%s.\nUnsing last found profile.",
rs_tiff_get_filename_nopath(RS_TIFF(dcp)), rs_dcp_file_get_model(dcp),
rs_dcp_file_get_name(dcp));
ret = dcp;
+ }
+
+ g_free(dcp_id);
}
return ret;
Modified: branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.h
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.h 2010-01-19
19:14:35 UTC (rev 3039)
+++ branches/rawstudio-ng-color/librawstudio/rs-dcp-factory.h 2010-01-19
20:01:31 UTC (rev 3040)
@@ -33,7 +33,7 @@
GList *rs_dcp_factory_get_compatible(RSDcpFactory *factory, const gchar *make,
const gchar *model);
-RSDcpFile *rs_dcp_factory_find_from_path(RSDcpFactory *factory, const gchar
*path);
+RSDcpFile *rs_dcp_factory_find_from_id(RSDcpFactory *factory, const gchar
*path);
G_END_DECLS
Modified: branches/rawstudio-ng-color/librawstudio/rs-dcp-file.c
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-dcp-file.c 2010-01-19
19:14:35 UTC (rev 3039)
+++ branches/rawstudio-ng-color/librawstudio/rs-dcp-file.c 2010-01-19
20:01:31 UTC (rev 3040)
@@ -304,3 +304,20 @@
{
return rs_huesat_map_new_from_dcp(RS_TIFF(dcp_file), 0, 0xc725, 0xc726);
}
+
+gchar*
+rs_dcp_get_id(RSDcpFile *dcp_file)
+{
+ const gchar* dcp_filename =
rs_tiff_get_filename_nopath(RS_TIFF(dcp_file));
+ const gchar* dcp_model = rs_dcp_file_get_model(dcp_file);
+ const gchar* dcp_name = rs_dcp_file_get_name(dcp_file);
+
+ /* Concat all three elements */
+ gchar *id = g_strconcat(dcp_filename, dcp_model, dcp_name, NULL);
+
+ /* Convert to lower case to eliminate case mismatches */
+ gchar *id_return = g_ascii_strdown(id, -1);
+ g_free(id);
+
+ return id_return;
+}
Modified: branches/rawstudio-ng-color/librawstudio/rs-dcp-file.h
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-dcp-file.h 2010-01-19
19:14:35 UTC (rev 3039)
+++ branches/rawstudio-ng-color/librawstudio/rs-dcp-file.h 2010-01-19
20:01:31 UTC (rev 3040)
@@ -72,6 +72,10 @@
RSHuesatMap *rs_dcp_file_get_looktable(RSDcpFile *dcp_file);
+/* Returns a generated (hopefully) unique id, that should make it possible to
find this profile again */
+/* returned result must be free using g_free() */
+gchar* rs_dcp_get_id(RSDcpFile *dcp_file);
+
G_END_DECLS
#endif /* RS_DCP_FILE_H */
Modified: branches/rawstudio-ng-color/src/rs-cache.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-cache.c 2010-01-19 19:14:35 UTC (rev
3039)
+++ branches/rawstudio-ng-color/src/rs-cache.c 2010-01-19 20:01:31 UTC (rev
3040)
@@ -77,8 +77,12 @@
RSDcpFile *dcp = rs_photo_get_dcp_profile(photo);
if (RS_IS_DCP_FILE(dcp))
+ {
+ gchar* dcp_id = rs_dcp_get_id(RS_DCP_FILE(dcp));
xmlTextWriterWriteFormatElement(writer, BAD_CAST "dcp-profile",
"%s",
- rs_tiff_get_filename_nopath(RS_TIFF(dcp)));
+ dcp_id);
+ g_free(dcp_id);
+ }
if (photo->crop)
{
@@ -376,7 +380,7 @@
{
val = xmlNodeListGetString(doc, cur->xmlChildrenNode,
1);
RSDcpFactory *factory = rs_dcp_factory_new_default();
- RSDcpFile *dcp = rs_dcp_factory_find_from_path(factory,
(gchar *) val);
+ RSDcpFile *dcp = rs_dcp_factory_find_from_id(factory,
(gchar *) val);
if (dcp)
rs_photo_set_dcp_profile(photo, dcp);
xmlFree(val);
Modified: branches/rawstudio-ng-color/src/rs-camera-db.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-camera-db.c 2010-01-19 19:14:35 UTC
(rev 3039)
+++ branches/rawstudio-ng-color/src/rs-camera-db.c 2010-01-19 20:01:31 UTC
(rev 3040)
@@ -304,7 +304,7 @@
else if ((!xmlStrcmp(entry->name,
BAD_CAST "model")))
gtk_list_store_set(camera_db->cameras, &iter, COLUMN_MODEL, val, -1);
else if ((!xmlStrcmp(entry->name,
BAD_CAST "dcp-profile")))
-
gtk_list_store_set(camera_db->cameras, &iter, COLUMN_PROFILE,
rs_dcp_factory_find_from_path(dcp_factory, (gchar *) val), -1);
+
gtk_list_store_set(camera_db->cameras, &iter, COLUMN_PROFILE,
rs_dcp_factory_find_from_id(dcp_factory, (gchar *) val), -1);
xmlFree(val);
if ((!xmlStrcmp(entry->name, BAD_CAST
"settings")))
@@ -370,7 +370,11 @@
if (profile)
{
if (RS_IS_DCP_FILE(profile))
- xmlTextWriterWriteFormatElement(writer,
BAD_CAST "dcp-profile", "%s", rs_tiff_get_filename_nopath(RS_TIFF(profile)));
+ {
+ gchar* dcp_id =
rs_dcp_get_id(RS_DCP_FILE(profile));
+ xmlTextWriterWriteFormatElement(writer,
BAD_CAST "dcp-profile", "%s", dcp_id);
+ g_free(dcp_id);
+ }
/* FIXME: Add support for ICC profiles */
}
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit