[gthumb] always use a GthMetadata object for attributes



commit deea1194e32709e59c35ba5883a36a9320bca968
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Apr 28 21:20:39 2012 +0200

    always use a GthMetadata object for attributes
    
    some objects (keyword attributes) were  GthStringList, now it's always
    used the GthMetadata object, that can contain a GthStringList value as well,
    in order to make the code more consistent.

 extensions/catalogs/gth-organize-task.c            |   13 +-
 extensions/comments/gth-comment.c                  |    9 +-
 .../comments/gth-metadata-provider-comment.c       |   14 ++-
 extensions/edit_metadata/gth-edit-general-page.c   |   18 ++-
 extensions/edit_metadata/gth-edit-tags-dialog.c    |   11 ++-
 extensions/edit_metadata/gth-tag-task.c            |    8 +-
 extensions/edit_metadata/utils.c                   |    4 +-
 extensions/exiv2_tools/exiv2-utils.cpp             |  124 ++++++++++---------
 extensions/flicker_utils/flickr-service.c          |    4 +-
 extensions/importer/gth-import-task.c              |    5 +-
 extensions/picasaweb/picasa-web-service.c          |    4 +-
 gthumb/gth-file-data.c                             |   23 +++-
 gthumb/gth-metadata.c                              |    9 ++
 gthumb/gth-metadata.h                              |   29 +++---
 gthumb/gth-string-list.c                           |   13 ++
 gthumb/gth-string-list.h                           |    2 +
 gthumb/gth-test-category.c                         |   13 ++-
 17 files changed, 191 insertions(+), 112 deletions(-)
---
diff --git a/extensions/catalogs/gth-organize-task.c b/extensions/catalogs/gth-organize-task.c
index c93cb97..74304f5 100644
--- a/extensions/catalogs/gth-organize-task.c
+++ b/extensions/catalogs/gth-organize-task.c
@@ -454,7 +454,6 @@ for_each_file_func (GFile     *file,
 	GthFileData     *file_data;
 	char            *catalog_key;
 	GObject         *metadata;
-	GthStringList   *categories;
 	GTimeVal         timeval;
 	GthCatalog      *catalog;
 
@@ -492,13 +491,15 @@ for_each_file_func (GFile     *file,
 	case GTH_GROUP_POLICY_TAG:
 	case GTH_GROUP_POLICY_TAG_EMBEDDED:
 		if (self->priv->group_policy == GTH_GROUP_POLICY_TAG)
-			categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "comment::categories");
+			metadata = g_file_info_get_attribute_object (file_data->info, "comment::categories");
 		else
-			categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags");
-		if (categories != NULL) {
-			GList *list;
-			GList *scan;
+			metadata = g_file_info_get_attribute_object (file_data->info, "general::tags");
+		if ((metadata != NULL) && GTH_IS_METADATA (metadata)) {
+			GthStringList *categories;
+			GList         *list;
+			GList         *scan;
 
+			categories = gth_metadata_get_string_list (GTH_METADATA (metadata));
 			list = gth_string_list_get_list (categories);
 			for (scan = list; scan; scan = scan->next) {
 				char *tag = (char *) scan->data;
diff --git a/extensions/comments/gth-comment.c b/extensions/comments/gth-comment.c
index a2b1f2c..1e6ceef 100644
--- a/extensions/comments/gth-comment.c
+++ b/extensions/comments/gth-comment.c
@@ -628,7 +628,8 @@ gth_comment_synchronize_metadata (GList *file_list)
 		if (metadata != NULL)
 			gth_comment_set_time_from_exif_format (comment, gth_metadata_get_raw (metadata));
 
-		comment_categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "comment::categories");
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "comment::categories");
+		comment_categories = gth_metadata_get_string_list (metadata);
 		if (comment_categories != NULL)
 			for (scan = gth_string_list_get_list (comment_categories); scan; scan = scan->next)
 				gth_comment_add_category (comment, (char *) scan->data);
@@ -676,9 +677,11 @@ gth_comment_synchronize_metadata (GList *file_list)
 			}
 		}
 
-		categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		categories = gth_metadata_get_string_list (metadata);
 		if (categories != NULL) {
-			comment_categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "comment::categories");
+			metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "comment::categories");
+			comment_categories = gth_metadata_get_string_list (metadata);
 			if (! gth_string_list_equal (categories, comment_categories)) {
 				GList *scan;
 
diff --git a/extensions/comments/gth-metadata-provider-comment.c b/extensions/comments/gth-metadata-provider-comment.c
index 3548ae1..bae882f 100644
--- a/extensions/comments/gth-metadata-provider-comment.c
+++ b/extensions/comments/gth-metadata-provider-comment.c
@@ -95,12 +95,15 @@ gth_metadata_provider_comment_read (GthMetadataProvider *self,
 
 	categories = gth_comment_get_categories (comment);
 	if (categories->len > 0) {
-		GObject *value;
+		GthStringList *list;
+		GthMetadata   *metadata;
 
-		value = (GObject *) gth_string_list_new_from_ptr_array (categories);
-		g_file_info_set_attribute_object (file_data->info, "comment::categories", value);
+		list =  gth_string_list_new_from_ptr_array (categories);
+		metadata = gth_metadata_new_for_string_list (list);
+		g_file_info_set_attribute_object (file_data->info, "comment::categories", G_OBJECT (metadata));
 
-		g_object_unref (value);
+		g_object_unref (metadata);
+		g_object_unref (list);
 	}
 	else
 		g_file_info_remove_attribute (file_data->info, "comment::categories");
@@ -180,7 +183,8 @@ gth_metadata_provider_comment_write (GthMetadataProvider   *self,
 
 	/* keywords */
 
-	categories = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+	metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+	categories = gth_metadata_get_string_list (metadata);
 	if (categories != NULL) {
 		GList *list;
 		GList *scan;
diff --git a/extensions/edit_metadata/gth-edit-general-page.c b/extensions/edit_metadata/gth-edit-general-page.c
index 0bdd225..058ee2d 100644
--- a/extensions/edit_metadata/gth-edit-general-page.c
+++ b/extensions/edit_metadata/gth-edit-general-page.c
@@ -392,7 +392,8 @@ gth_edit_general_page_real_update_info (GthEditCommentPage *base,
 
 		/* keep the inconsistent tags */
 
-		old_tags = _g_hash_table_from_string_list ((GthStringList *) g_file_info_get_attribute_object (info, "general::tags"));
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (info, "general::tags");
+		old_tags = _g_hash_table_from_string_list (gth_metadata_get_string_list (metadata));
 		for (scan_tags = inconsistent_tags; scan_tags; scan_tags = scan_tags->next) {
 			char *inconsistent_tag = scan_tags->data;
 
@@ -405,12 +406,15 @@ gth_edit_general_page_real_update_info (GthEditCommentPage *base,
 
 		if (new_tags != NULL) {
 			GthStringList *file_tags;
+			GthMetadata   *metadata;
 
 			new_tags = g_list_sort (new_tags, (GCompareFunc) g_strcmp0);
 			file_tags = gth_string_list_new (new_tags);
-			g_file_info_set_attribute_object (info, "general::tags", G_OBJECT (file_tags));
+			metadata = gth_metadata_new_for_string_list (file_tags);
+			g_file_info_set_attribute_object (info, "general::tags", G_OBJECT (metadata));
 
-			_g_object_unref (file_tags);
+			g_object_unref (metadata);
+			g_object_unref (file_tags);
 			_g_string_list_free (new_tags);
 		}
 		else
@@ -435,8 +439,12 @@ gth_edit_general_page_real_update_info (GthEditCommentPage *base,
 		else
 			string_list = NULL;
 
-		if (string_list != NULL)
-			g_file_info_set_attribute_object (info, "general::tags", G_OBJECT (string_list));
+		if (string_list != NULL) {
+			metadata = gth_metadata_new_for_string_list (string_list);
+			g_file_info_set_attribute_object (info, "general::tags", G_OBJECT (metadata));
+
+			g_object_unref (metadata);
+		}
 		else
 			g_file_info_remove_attribute (info, "general::tags");
 
diff --git a/extensions/edit_metadata/gth-edit-tags-dialog.c b/extensions/edit_metadata/gth-edit-tags-dialog.c
index 53b242e..07c61fa 100644
--- a/extensions/edit_metadata/gth-edit-tags-dialog.c
+++ b/extensions/edit_metadata/gth-edit-tags-dialog.c
@@ -118,6 +118,7 @@ gth_edit_tags_dialog_update_info (GthEditMetadataDialog *base,
 	for (scan = file_list; scan; scan = scan->next) {
 		GthFileData *file_data = scan->data;
 		GList       *new_tags;
+		GthMetadata *metadata;
 		GHashTable  *old_tags;
 		GList       *scan_tags;
 
@@ -125,7 +126,8 @@ gth_edit_tags_dialog_update_info (GthEditMetadataDialog *base,
 
 		/* keep the inconsistent tags */
 
-		old_tags = _g_hash_table_from_string_list ((GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags"));
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		old_tags = _g_hash_table_from_string_list (gth_metadata_get_string_list (metadata));
 		for (scan_tags = inconsistent_tags; scan_tags; scan_tags = scan_tags->next) {
 			char *inconsistent_tag = scan_tags->data;
 
@@ -138,12 +140,15 @@ gth_edit_tags_dialog_update_info (GthEditMetadataDialog *base,
 
 		if (new_tags != NULL) {
 			GthStringList *file_tags;
+			GthMetadata   *metadata;
 
 			new_tags = g_list_sort (new_tags, (GCompareFunc) g_strcmp0);
 			file_tags = gth_string_list_new (new_tags);
-			g_file_info_set_attribute_object (file_data->info, "general::tags", G_OBJECT (file_tags));
+			metadata = gth_metadata_new_for_string_list (file_tags);
+			g_file_info_set_attribute_object (file_data->info, "general::tags", G_OBJECT (metadata));
 
-			_g_object_unref (file_tags);
+			g_object_unref (metadata);
+			g_object_unref (file_tags);
 			_g_string_list_free (new_tags);
 		}
 		else
diff --git a/extensions/edit_metadata/gth-tag-task.c b/extensions/edit_metadata/gth-tag-task.c
index 62bf952..e3a6427 100644
--- a/extensions/edit_metadata/gth-tag-task.c
+++ b/extensions/edit_metadata/gth-tag-task.c
@@ -98,17 +98,21 @@ info_ready_cb (GList    *files,
 	self->priv->file_data_list = _g_object_list_ref (files);
 	for (scan = self->priv->file_data_list; scan; scan = scan->next) {
 		GthFileData   *file_data = scan->data;
+		GthMetadata   *metadata;
 		GthStringList *original_tags;
 		GthStringList *new_tags;
 
-		original_tags = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		original_tags = gth_metadata_get_string_list (metadata);
 
 		new_tags = gth_string_list_new (NULL);
 		gth_string_list_append (new_tags, original_tags);
 		gth_string_list_append (new_tags, self->priv->tags);
 
-		g_file_info_set_attribute_object (file_data->info, "general::tags", G_OBJECT (new_tags));
+		metadata = gth_metadata_new_for_string_list (new_tags);
+		g_file_info_set_attribute_object (file_data->info, "general::tags", G_OBJECT (metadata));
 
+		g_object_unref (metadata);
 		g_object_unref (new_tags);
 	}
 
diff --git a/extensions/edit_metadata/utils.c b/extensions/edit_metadata/utils.c
index eddb9d2..a466507 100644
--- a/extensions/edit_metadata/utils.c
+++ b/extensions/edit_metadata/utils.c
@@ -50,9 +50,11 @@ utils_get_common_tags (GList       *file_list, /* GthFileData list */
 	common_tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 	for (scan = file_list; scan; scan = scan->next) {
 		GthFileData   *file_data = scan->data;
+		GthMetadata   *metadata;
 		GthStringList *file_tags;
 
-		file_tags = (GthStringList *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::tags");
+		file_tags = gth_metadata_get_string_list (metadata);
 		if (file_tags != NULL) {
 			for (scan_tags = gth_string_list_get_list (file_tags);
 			     scan_tags != NULL;
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index 9cb4966..9535675 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -294,12 +294,13 @@ create_metadata (const char *key,
 
 
 static void
-add_string_list_to_metadata (GthMetadata        *metadata,
-			     const Exiv2::Value &value)
+add_string_list_to_metadata (GthMetadata            *metadata,
+			     const Exiv2::Metadatum &value)
 {
-	GList         *list = NULL;
+	GList         *list;
 	GthStringList *string_list;
 
+	list = NULL;
 	for (int i = 0; i < value.count(); i++)
 		list = g_list_prepend (list, g_strdup (value.toString(i).c_str()));
 	string_list = gth_string_list_new (g_list_reverse (list));
@@ -360,24 +361,41 @@ add_metadata_to_hash (GHashTable  *table,
 		GList         *list;
 
 		string_list = NULL;
-		if (GTH_IS_METADATA (object)) {
+		switch (gth_metadata_get_data_type (GTH_METADATA (object))) {
+		case GTH_METADATA_TYPE_STRING:
 			string_list = gth_string_list_new (NULL);
 			list = g_list_append (NULL, g_strdup (gth_metadata_get_formatted (GTH_METADATA (object))));
 			gth_string_list_set_list (string_list, list);
+			break;
+
+		case GTH_METADATA_TYPE_STRING_LIST:
+			string_list = (GthStringList *) g_object_ref (gth_metadata_get_string_list (GTH_METADATA (object)));
+			break;
 		}
-		else if (GTH_IS_STRING_LIST (object))
-			string_list = GTH_STRING_LIST (g_object_ref (object));
 
-		if (string_list == NULL)
+		if (string_list == NULL) {
+			g_hash_table_insert (table,
+					     g_strdup (key),
+					     g_object_ref (metadata));
 			return;
+		}
 
-		list = gth_string_list_get_list (string_list);
-		list = g_list_append (list, g_strdup (gth_metadata_get_formatted (metadata)));
-		gth_string_list_set_list (string_list, list);
+		switch (gth_metadata_get_data_type (metadata)) {
+		case GTH_METADATA_TYPE_STRING:
+			list = gth_string_list_get_list (string_list);
+			list = g_list_append (list, g_strdup (gth_metadata_get_formatted (metadata)));
+			gth_string_list_set_list (string_list, list);
+			break;
+
+		case GTH_METADATA_TYPE_STRING_LIST:
+			gth_string_list_concat (string_list, gth_metadata_get_string_list (metadata));
+			break;
+		}
 
+		g_object_set (metadata, "string-list", string_list, NULL);
 		g_hash_table_replace (table,
 				      g_strdup (key),
-				      g_object_ref (string_list));
+				      g_object_ref (metadata));
 
 		g_object_unref (string_list);
 	}
@@ -477,7 +495,7 @@ set_string_list_attribute_from_tagset (GFileInfo  *info,
 	if (metadata == NULL)
 		return;
 
-	if (GTH_IS_METADATA (metadata)) {
+	if (GTH_IS_METADATA (metadata) && (gth_metadata_get_data_type (GTH_METADATA (metadata)) != GTH_METADATA_TYPE_STRING_LIST)) {
 		char           *raw;
 		char          **keywords;
 		GthStringList  *string_list;
@@ -485,12 +503,15 @@ set_string_list_attribute_from_tagset (GFileInfo  *info,
 		g_object_get (metadata, "raw", &raw, NULL);
 		keywords = g_strsplit (raw, ",", -1);
 		string_list = gth_string_list_new_from_strv (keywords);
-		g_file_info_set_attribute_object (info, attribute, G_OBJECT (string_list));
+		metadata = (GObject *) gth_metadata_new_for_string_list (string_list);
+		g_file_info_set_attribute_object (info, attribute, metadata);
 
+		g_object_unref (metadata);
+		g_object_unref (string_list);
 		g_strfreev (keywords);
 		g_free (raw);
 	}
-	else if (GTH_IS_STRING_LIST (metadata))
+	else
 		g_file_info_set_attribute_object (info, attribute, metadata);
 }
 
@@ -638,6 +659,7 @@ exiv2_read_metadata (Exiv2::Image::AutoPtr  image,
 						    raw_value.str().c_str(),
 						    "Iptc",
 						    md->typeName());
+
 			add_metadata_to_hash (table, metadata);
 			_g_object_unref (metadata);
 		}
@@ -672,7 +694,7 @@ exiv2_read_metadata (Exiv2::Image::AutoPtr  image,
 			if ((g_strcmp0 (md->typeName(), "XmpBag") == 0)
 			    || (g_strcmp0 (md->typeName(), "XmpSeq") == 0))
 			{
-				add_string_list_to_metadata (metadata, md->value());
+				add_string_list_to_metadata (metadata, *md);
 			}
 
 			add_metadata_to_hash (table, metadata);
@@ -1066,26 +1088,26 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 				Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
 				Exiv2::IptcKey iptc_key(key);
 
-				if (GTH_IS_STRING_LIST (metadatum)) {
-					GthStringList *string_list;
-					GList         *scan;
-
-					string_list = GTH_STRING_LIST (metadatum);
-					for (scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
-						char *single_value = (char *) scan->data;
-
-						value->read (single_value);
-						id.add (iptc_key, value.get());
-					}
-				}
-				else if (GTH_IS_METADATA (metadatum)) {
-					const char *raw_value;
+				const char *raw_value;
 
+				switch (gth_metadata_get_data_type (GTH_METADATA (metadatum))) {
+				case GTH_METADATA_TYPE_STRING:
 					raw_value = gth_metadata_get_raw (GTH_METADATA (metadatum));
 					if ((raw_value != NULL) && (strcmp (raw_value, "") != 0)) {
 						value->read (raw_value);
 						id.add (iptc_key, value.get());
 					}
+					break;
+
+				case GTH_METADATA_TYPE_STRING_LIST:
+					GthStringList *string_list = gth_metadata_get_string_list (GTH_METADATA (metadatum));
+					for (GList *scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
+						char *single_value = (char *) scan->data;
+
+						value->read (single_value);
+						id.add (iptc_key, value.get());
+					}
+					break;
 				}
 			}
 		}
@@ -1122,42 +1144,26 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 				Exiv2::Value::AutoPtr value = Exiv2::Value::create (Exiv2::TypeInfo::typeId (value_type));
 				Exiv2::XmpKey xmp_key(key);
 
-				if (GTH_IS_STRING_LIST (metadatum)) {
-					GthStringList *string_list;
-					GList         *scan;
+				const char *raw_value;
 
-					string_list = GTH_STRING_LIST (metadatum);
-					for (scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
+				switch (gth_metadata_get_data_type (GTH_METADATA (metadatum))) {
+				case GTH_METADATA_TYPE_STRING:
+					raw_value = gth_metadata_get_raw (GTH_METADATA (metadatum));
+					if ((raw_value != NULL) && (strcmp (raw_value, "") != 0)) {
+						value->read (raw_value);
+						xd.add (xmp_key, value.get());
+					}
+					break;
+
+				case GTH_METADATA_TYPE_STRING_LIST:
+					GthStringList *string_list = gth_metadata_get_string_list (GTH_METADATA (metadatum));
+					for (GList *scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
 						char *single_value = (char *) scan->data;
 
 						value->read (single_value);
 						xd.add (xmp_key, value.get());
 					}
-				}
-				else if (GTH_IS_METADATA (metadatum)) {
-					const char    *raw_value;
-					GthStringList *string_list;
-					GList         *scan;
-
-					switch (gth_metadata_get_data_type (GTH_METADATA (metadatum))) {
-					case GTH_METADATA_TYPE_STRING:
-						raw_value = gth_metadata_get_raw (GTH_METADATA (metadatum));
-						if ((raw_value != NULL) && (strcmp (raw_value, "") != 0)) {
-							value->read (raw_value);
-							xd.add (xmp_key, value.get());
-						}
-						break;
-
-					case GTH_METADATA_TYPE_STRING_LIST:
-						string_list = gth_metadata_get_string_list (GTH_METADATA (metadatum));
-						for (scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
-							char *single_value = (char *) scan->data;
-
-							value->read (single_value);
-							xd.add (xmp_key, value.get());
-						}
-						break;
-					}
+					break;
 				}
 			}
 		}
diff --git a/extensions/flicker_utils/flickr-service.c b/extensions/flicker_utils/flickr-service.c
index 909e974..926caff 100644
--- a/extensions/flicker_utils/flickr-service.c
+++ b/extensions/flicker_utils/flickr-service.c
@@ -798,8 +798,8 @@ post_photo_file_buffer_ready_cb (void     **buffer,
 
 		tags = NULL;
 		metadata = g_file_info_get_attribute_object (file_data->info, "general::tags");
-		if ((metadata != NULL) && GTH_IS_STRING_LIST (metadata))
-			tags = gth_string_list_join (GTH_STRING_LIST (metadata), " ");
+		if (metadata != NULL)
+			tags = gth_string_list_join (GTH_STRING_LIST (gth_metadata_get_string_list (GTH_METADATA (metadata))), " ");
 		if (tags != NULL)
 			g_hash_table_insert (data_set, "tags", tags);
 
diff --git a/extensions/importer/gth-import-task.c b/extensions/importer/gth-import-task.c
index ba3e496..0586030 100644
--- a/extensions/importer/gth-import-task.c
+++ b/extensions/importer/gth-import-task.c
@@ -209,6 +209,7 @@ transformation_ready_cb (GError   *error,
 {
 	GthImportTask *self = user_data;
 	GthStringList *tag_list;
+	GthMetadata   *metadata;
 	GList         *file_list;
 
 	if ((error != NULL) && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@@ -222,7 +223,8 @@ transformation_ready_cb (GError   *error,
 	}
 
 	tag_list = gth_string_list_new_from_strv (self->priv->tags);
-	g_file_info_set_attribute_object (self->priv->destination_file->info, "comment::categories", G_OBJECT (tag_list));
+	metadata = gth_metadata_new_for_string_list (tag_list);
+	g_file_info_set_attribute_object (self->priv->destination_file->info, "comment::categories", G_OBJECT (metadata));
 	file_list = g_list_prepend (NULL, self->priv->destination_file);
 	_g_write_metadata_async (file_list,
 				 GTH_METADATA_WRITE_DEFAULT,
@@ -232,6 +234,7 @@ transformation_ready_cb (GError   *error,
 				 self);
 
 	g_list_free (file_list);
+	g_object_unref (metadata);
 	g_object_unref (tag_list);
 }
 
diff --git a/extensions/picasaweb/picasa-web-service.c b/extensions/picasaweb/picasa-web-service.c
index c6ee378..5656a6d 100644
--- a/extensions/picasaweb/picasa-web-service.c
+++ b/extensions/picasaweb/picasa-web-service.c
@@ -475,8 +475,8 @@ post_photo_file_buffer_ready_cb (void     **buffer,
 					  dom_document_create_element_with_text (doc, value, "gphoto:location", NULL));
 
 	metadata = g_file_info_get_attribute_object (file_data->info, "general::tags");
-	if ((metadata != NULL) && GTH_IS_STRING_LIST (metadata))
-		value = gth_string_list_join (GTH_STRING_LIST (metadata), ", ");
+	if (metadata != NULL)
+		value = gth_string_list_join (GTH_STRING_LIST (gth_metadata_get_string_list (GTH_METADATA (metadata))), ", ");
 	if (value != NULL) {
 		DomElement *group;
 
diff --git a/gthumb/gth-file-data.c b/gthumb/gth-file-data.c
index 9c424ff..3f41f2b 100644
--- a/gthumb/gth-file-data.c
+++ b/gthumb/gth-file-data.c
@@ -495,8 +495,16 @@ gth_file_data_get_attribute_as_string (GthFileData *file_data,
 	switch (g_file_info_get_attribute_type (file_data->info, id)) {
 	case G_FILE_ATTRIBUTE_TYPE_OBJECT:
 		obj = g_file_info_get_attribute_object (file_data->info, id);
-		if (GTH_IS_METADATA (obj))
-			value = g_strdup (gth_metadata_get_formatted (GTH_METADATA (obj)));
+		if (GTH_IS_METADATA (obj)) {
+			switch (gth_metadata_get_data_type (GTH_METADATA (obj))) {
+			case GTH_METADATA_TYPE_STRING:
+				value = g_strdup (gth_metadata_get_formatted (GTH_METADATA (obj)));
+				break;
+			case GTH_METADATA_TYPE_STRING_LIST:
+				value = gth_string_list_join (GTH_STRING_LIST (gth_metadata_get_string_list (GTH_METADATA (obj))), " ");
+				break;
+			}
+		}
 		else if (GTH_IS_STRING_LIST (obj))
 			value = gth_string_list_join (GTH_STRING_LIST (obj), " ");
 		else
@@ -617,8 +625,15 @@ gth_file_data_attribute_equal_string_list (GthFileData    *file_data,
 					   const char     *attribute,
 					   GthStringList  *value)
 {
-	GObject *obj;
+	GthStringList *list;
+	GObject       *obj;
 
+	list = NULL;
 	obj = g_file_info_get_attribute_object (file_data->info, attribute);
-	return gth_string_list_equal (GTH_STRING_LIST (obj), value);
+	if (GTH_IS_METADATA (obj))
+		list = gth_metadata_get_string_list (GTH_METADATA (obj));
+	else if (GTH_IS_STRING_LIST (obj))
+		list = (GthStringList *) obj;
+
+	return gth_string_list_equal (list, value);
 }
diff --git a/gthumb/gth-metadata.c b/gthumb/gth-metadata.c
index 22823b6..f3d37b1 100644
--- a/gthumb/gth-metadata.c
+++ b/gthumb/gth-metadata.c
@@ -214,6 +214,13 @@ gth_metadata_new (void)
 }
 
 
+GthMetadata *
+gth_metadata_new_for_string_list (GthStringList *list)
+{
+	return g_object_new (GTH_TYPE_METADATA, "string-list", list, NULL);
+}
+
+
 GthMetadataType
 gth_metadata_get_data_type (GthMetadata *metadata)
 {
@@ -238,6 +245,8 @@ gth_metadata_get_raw (GthMetadata *metadata)
 GthStringList *
 gth_metadata_get_string_list (GthMetadata *metadata)
 {
+	if (metadata == NULL)
+		return NULL;
 	if (metadata->priv->data_type == GTH_METADATA_TYPE_STRING_LIST)
 		return metadata->priv->list;
 	else
diff --git a/gthumb/gth-metadata.h b/gthumb/gth-metadata.h
index b349510..0eadb3a 100644
--- a/gthumb/gth-metadata.h
+++ b/gthumb/gth-metadata.h
@@ -78,20 +78,21 @@ struct _GthMetadataClass {
 	GObjectClass parent_class;
 };
 
-GType             gth_metadata_get_type        (void);
-GthMetadata *     gth_metadata_new             (void);
-GthMetadataType   gth_metadata_get_data_type   (GthMetadata     *metadata);
-const char *      gth_metadata_get_id          (GthMetadata     *metadata);
-const char *      gth_metadata_get_raw         (GthMetadata     *metadata);
-GthStringList *   gth_metadata_get_string_list (GthMetadata     *metadata);
-const char *      gth_metadata_get_formatted   (GthMetadata     *metadata);
-const char *      gth_metadata_get_value_type  (GthMetadata     *metadata);
-GthMetadata *     gth_metadata_dup             (GthMetadata     *metadata);
-GthMetadataInfo * gth_metadata_info_dup        (GthMetadataInfo *info);
-void              set_attribute_from_string    (GFileInfo       *info,
-						const char      *key,
-						const char      *raw,
-						const char      *formatted);
+GType             gth_metadata_get_type             (void);
+GthMetadata *     gth_metadata_new                  (void);
+GthMetadata *     gth_metadata_new_for_string_list  (GthStringList   *list);
+GthMetadataType   gth_metadata_get_data_type        (GthMetadata     *metadata);
+const char *      gth_metadata_get_id               (GthMetadata     *metadata);
+const char *      gth_metadata_get_raw              (GthMetadata     *metadata);
+GthStringList *   gth_metadata_get_string_list      (GthMetadata     *metadata);
+const char *      gth_metadata_get_formatted        (GthMetadata     *metadata);
+const char *      gth_metadata_get_value_type       (GthMetadata     *metadata);
+GthMetadata *     gth_metadata_dup                  (GthMetadata     *metadata);
+GthMetadataInfo * gth_metadata_info_dup             (GthMetadataInfo *info);
+void              set_attribute_from_string         (GFileInfo       *info,
+						     const char      *key,
+						     const char      *raw,
+						     const char      *formatted);
 
 G_END_DECLS
 
diff --git a/gthumb/gth-string-list.c b/gthumb/gth-string-list.c
index 6343264..f7b8287 100644
--- a/gthumb/gth-string-list.c
+++ b/gthumb/gth-string-list.c
@@ -189,6 +189,19 @@ gth_string_list_append (GthStringList *list1,
 }
 
 
+void
+gth_string_list_concat (GthStringList  *list1,
+			GthStringList  *list2)
+{
+	GList *scan;
+
+	if (list2 == NULL)
+		return;
+
+	list1->priv->list = g_list_concat (list1->priv->list, _g_string_list_dup (list2->priv->list));
+}
+
+
 GHashTable *
 _g_hash_table_from_string_list (GthStringList *list)
 {
diff --git a/gthumb/gth-string-list.h b/gthumb/gth-string-list.h
index 9706398..cfb63f4 100644
--- a/gthumb/gth-string-list.h
+++ b/gthumb/gth-string-list.h
@@ -60,6 +60,8 @@ gboolean          gth_string_list_equal               (GthStringList  *list1,
 						       GthStringList  *list2);
 void              gth_string_list_append              (GthStringList  *list1,
 		       	       	       	       	       GthStringList  *list2);
+void              gth_string_list_concat              (GthStringList  *list1,
+		       	       	       	       	       GthStringList  *list2);
 
 /* utilities */
 
diff --git a/gthumb/gth-test-category.c b/gthumb/gth-test-category.c
index 9c47a1a..6941d37 100644
--- a/gthumb/gth-test-category.c
+++ b/gthumb/gth-test-category.c
@@ -269,15 +269,18 @@ gth_test_category_real_match (GthTest     *test,
         test_category = GTH_TEST_CATEGORY (test);
 
 	if (test_category->priv->category != NULL) {
-		GthStringList *string_list;
+		GthMetadata   *metadata;
 		GList         *list, *scan;
 		char          *test_category_casefolded;
 
-		string_list = (GthStringList *) g_file_info_get_attribute_object (file->info, gth_test_get_attributes (GTH_TEST (test_category)));
-		if (string_list != NULL)
+		list = NULL;
+		metadata = (GthMetadata *) g_file_info_get_attribute_object (file->info, gth_test_get_attributes (GTH_TEST (test_category)));
+		if ((metadata != NULL) && GTH_IS_METADATA (metadata)) {
+			GthStringList *string_list;
+
+			string_list = gth_metadata_get_string_list (metadata);
 			list = gth_string_list_get_list (string_list);
-		else
-			list = NULL;
+		}
 
 		if (test_category->priv->op == GTH_TEST_OP_CONTAINS_ONLY) {
 			if ((list == NULL) || (list->next != NULL))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]