[easytag] Factor out EtPicture comparison to new function
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Factor out EtPicture comparison to new function
- Date: Tue, 30 Jun 2015 07:33:51 +0000 (UTC)
commit 7cafddad51ebe49ba893c69097ea53b8ebdc8c34
Author: David King <amigadave amigadave com>
Date: Mon Jun 29 20:37:17 2015 +0100
Factor out EtPicture comparison to new function
Move the code to check for differences between two EtPicture instances
into EtPicture from File_Tag.
src/file_tag.c | 15 +--------------
src/picture.c | 39 ++++++++++++++++++++++++++++++++++++++-
src/picture.h | 3 ++-
3 files changed, 41 insertions(+), 16 deletions(-)
---
diff --git a/src/file_tag.c b/src/file_tag.c
index 8239bef..b0cf164 100644
--- a/src/file_tag.c
+++ b/src/file_tag.c
@@ -456,20 +456,7 @@ et_file_tag_detect_difference (const File_Tag *FileTag1,
for (pic1 = FileTag1->picture, pic2 = FileTag2->picture; ;
pic1 = pic1->next, pic2 = pic2->next)
{
- if( (pic1 && !pic2) || (!pic1 && pic2) )
- return TRUE;
- if (!pic1 || !pic2)
- break; // => no changes
- //if (!pic1->data || !pic2->data)
- // break; // => no changes
-
- if (!g_bytes_equal (pic1->bytes, pic2->bytes))
- {
- return TRUE;
- }
- if (pic1->type != pic2->type)
- return TRUE;
- if (et_normalized_strcmp0 (pic1->description, pic2->description) != 0)
+ if (et_picture_detect_difference (pic1, pic2))
{
return TRUE;
}
diff --git a/src/picture.c b/src/picture.c
index 2fedee2..74f1a82 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -1,5 +1,5 @@
/* EasyTAG - Tag editor for audio files
- * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2014-2015 David King <amigadave amigadave com>
* Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
* This program is free software; you can redistribute it and/or modify
@@ -237,6 +237,43 @@ Picture_Type_String (EtPictureType type)
}
}
+gboolean
+et_picture_detect_difference (const EtPicture *a,
+ const EtPicture *b)
+{
+ if (!a && !b)
+ {
+ return FALSE;
+ }
+
+ if ((a && !b) || (!a && b))
+ {
+ return TRUE;
+ }
+
+ if (a->type != b->type)
+ {
+ return TRUE;
+ }
+
+ if ((a->width != b->width) || (a->height != b->height))
+ {
+ return TRUE;
+ }
+
+ if (et_normalized_strcmp0 (a->description, b->description) != 0)
+ {
+ return TRUE;
+ }
+
+ if (!g_bytes_equal (a->bytes, b->bytes))
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
gchar *
et_picture_format_info (const EtPicture *pic,
ET_Tag_Type tag_type)
diff --git a/src/picture.h b/src/picture.h
index 34a8ab5..5f62bc5 100644
--- a/src/picture.h
+++ b/src/picture.h
@@ -1,5 +1,5 @@
/* EasyTAG - tag editor for audio files
- * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2014-2015 David King <amigadave amigadave com>
* Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
* This program is free software; you can redistribute it and/or modify it
@@ -92,6 +92,7 @@ void et_picture_free (EtPicture *pic);
Picture_Format Picture_Format_From_Data (const EtPicture *pic);
const gchar *Picture_Mime_Type_String (Picture_Format format);
const gchar * Picture_Type_String (EtPictureType type);
+gboolean et_picture_detect_difference (const EtPicture *a, const EtPicture *b);
gchar * et_picture_format_info (const EtPicture *pic, ET_Tag_Type tag_type);
GBytes * et_picture_load_file_data (GFile *file, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]