[easytag] Make EtPicture a boxed type
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Make EtPicture a boxed type
- Date: Wed, 17 Dec 2014 19:14:09 +0000 (UTC)
commit 7a04dedf0a37a5da1fadb085b5693e67fc220107
Author: David King <amigadave amigadave com>
Date: Wed Dec 17 18:02:02 2014 +0000
Make EtPicture a boxed type
Rename Picture to EtPicture and define a boxed type with
G_DEFINE_BOXED_TYPE. Rename Picture functions to et_picture_*(). Fix a
memory leak when destroying the tag area tree view, by using an
EtPicture column in the list store. Update the EtPicture tests.
data/tag_area.ui | 2 +-
src/et_core.c | 41 ++++++++++++++++++-----------
src/et_core.h | 18 ++++++------
src/picture.c | 52 ++++++++++++++++++++++----------------
src/picture.h | 19 ++++++++------
src/tag_area.c | 67 +++++++++++++++++++-----------------------------
src/tags/flac_tag.c | 9 +++---
src/tags/id3_tag.c | 2 +-
src/tags/id3v24_tag.c | 8 +++---
src/tags/mp4_tag.cc | 2 +-
src/tags/ogg_tag.c | 13 +++++----
tests/test-picture.c | 28 ++++++++++----------
12 files changed, 135 insertions(+), 126 deletions(-)
---
diff --git a/data/tag_area.ui b/data/tag_area.ui
index daa05c0..f555fd6 100644
--- a/data/tag_area.ui
+++ b/data/tag_area.ui
@@ -9,7 +9,7 @@
<columns>
<column type="GdkPixbuf"/>
<column type="gchararray"/>
- <column type="gpointer"/>
+ <column type="EtPicture"/>
</columns>
</object>
<object class="GtkListStore" id="track_combo_model">
diff --git a/src/et_core.c b/src/et_core.c
index e7c1044..0eb5bbe 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -145,8 +145,6 @@ static void ET_Initialize_File_Tag_Item (File_Tag *FileTag);
static void ET_Initialize_File_Name_Item (File_Name *FileName);
static void ET_Initialize_File_Info_Item (ET_File_Info *ETFileInfo);
-//gboolean ET_Set_Field_File_Tag_Picture (gchar **FileTagField, Picture *pic);
-
static guint ET_File_Key_New (void);
static guint ET_Undo_Key_New (void);
@@ -2458,7 +2456,7 @@ gboolean ET_Free_File_Tag_Item (File_Tag *FileTag)
g_free(FileTag->copyright);
g_free(FileTag->url);
g_free(FileTag->encoded_by);
- Picture_Free(FileTag->picture);
+ et_picture_free (FileTag->picture);
// Free list of other fields
ET_Free_File_Tag_Item_Other_Field(FileTag);
@@ -2750,11 +2748,15 @@ ET_Copy_File_Tag_Item (const ET_File *ETFile, File_Tag *FileTag)
if (FileTagCur->picture)
{
if (FileTag->picture)
- Picture_Free(FileTag->picture);
- FileTag->picture = Picture_Copy(FileTagCur->picture);
- }else if (FileTag->picture)
+ {
+ et_picture_free (FileTag->picture);
+ }
+
+ FileTag->picture = et_picture_copy_all (FileTagCur->picture);
+ }
+ else if (FileTag->picture)
{
- Picture_Free(FileTag->picture);
+ et_picture_free (FileTag->picture);
FileTag->picture = NULL;
}
@@ -2836,18 +2838,21 @@ gboolean ET_Set_Field_File_Tag_Item (gchar **FileTagField, const gchar *value)
* Set the value of a field of a FileTag Picture item.
*/
gboolean
-ET_Set_Field_File_Tag_Picture (Picture **FileTagField, const Picture *pic)
+ET_Set_Field_File_Tag_Picture (EtPicture **FileTagField,
+ const EtPicture *pic)
{
g_return_val_if_fail (FileTagField != NULL, FALSE);
if (*FileTagField != NULL)
{
- Picture_Free((Picture *)*FileTagField);
+ et_picture_free ((EtPicture *)*FileTagField);
*FileTagField = NULL;
}
if (pic)
- *FileTagField = Picture_Copy(pic);
+ {
+ *FileTagField = et_picture_copy_all (pic);
+ }
return TRUE;
}
@@ -3495,11 +3500,15 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
if(FileTagCur->picture)
{
if (FileTag->picture)
- Picture_Free(FileTag->picture);
- FileTag->picture = Picture_Copy(FileTagCur->picture);
- }else if (FileTag->picture)
+ {
+ et_picture_free (FileTag->picture);
+ }
+
+ FileTag->picture = et_picture_copy_all (FileTagCur->picture);
+ }
+ else if (FileTag->picture)
{
- Picture_Free(FileTag->picture);
+ et_picture_free (FileTag->picture);
FileTag->picture = NULL;
}
@@ -3799,8 +3808,8 @@ gboolean
ET_Detect_Changes_Of_File_Tag (const File_Tag *FileTag1,
const File_Tag *FileTag2)
{
- const Picture *pic1;
- const Picture *pic2;
+ const EtPicture *pic1;
+ const EtPicture *pic2;
g_return_val_if_fail (FileTag1 != NULL && FileTag2 != NULL, FALSE);
diff --git a/src/et_core.h b/src/et_core.h
index 1c520df..757e37a 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -83,17 +83,17 @@ struct _File_Name
/*
- * Description of Picture item (see picture.h)
+ * Description of EtPicture item (see picture.h)
*/
-typedef struct _Picture Picture;
-struct _Picture
+typedef struct _EtPicture EtPicture;
+struct _EtPicture
{
gint type;
- gchar *description;
- gint width; /* Original width of the picture */
- gint height; /* Original height of the picture */
+ gchar *description;
+ gint width; /* Original width of the picture */
+ gint height; /* Original height of the picture */
GBytes *bytes;
- Picture *next;
+ EtPicture *next;
};
@@ -122,7 +122,7 @@ struct _File_Tag
gchar *copyright; /* Copyright */
gchar *url; /* URL */
gchar *encoded_by; /* Encoded by */
- Picture *picture; /* Picture */
+ EtPicture *picture; /* Picture */
GList *other; /* List of unsupported fields (used for ogg only) */
};
@@ -298,7 +298,7 @@ gboolean ET_Copy_File_Tag_Item (const ET_File *ETFile, File_Tag *FileTag);
gboolean ET_Set_Field_File_Name_Item (gchar **FileNameField, gchar *value);
gboolean ET_Set_Filename_File_Name_Item (File_Name *FileName, const gchar *filename_utf8, const gchar
*filename);
gboolean ET_Set_Field_File_Tag_Item (gchar **FileTagField, const gchar *value);
-gboolean ET_Set_Field_File_Tag_Picture (Picture **FileTagField, const Picture *pic);
+gboolean ET_Set_Field_File_Tag_Picture (EtPicture **FileTagField, const EtPicture *pic);
GList *ET_Displayed_File_List_First (void);
GList *ET_Displayed_File_List_Previous (void);
diff --git a/src/picture.c b/src/picture.c
index c2f4d0c..ef022f1 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -32,6 +32,8 @@
#include "win32/win32dep.h"
+G_DEFINE_BOXED_TYPE (EtPicture, et_picture, et_picture_copy_single, et_picture_free)
+
/*
* Note :
* -> MP4_TAG :
@@ -109,7 +111,7 @@ et_picture_type_from_filename (const gchar *filename_utf8)
/* FIXME: Possibly use gnome_vfs_get_mime_type_for_buffer. */
Picture_Format
-Picture_Format_From_Data (const Picture *pic)
+Picture_Format_From_Data (const EtPicture *pic)
{
gsize size;
gconstpointer data;
@@ -234,8 +236,8 @@ Picture_Type_String (EtPictureType type)
}
gchar *
-Picture_Info (const Picture *pic,
- ET_Tag_Type tag_type)
+et_picture_format_info (const EtPicture *pic,
+ ET_Tag_Type tag_type)
{
const gchar *format, *desc, *type;
gchar *r, *size_str;
@@ -277,21 +279,21 @@ Picture_Info (const Picture *pic,
return r;
}
-Picture *
-Picture_Allocate (void)
+EtPicture *
+et_picture_new (void)
{
- Picture *pic = g_slice_new0 (Picture);
+ EtPicture *pic = g_slice_new0 (EtPicture);
return pic;
}
-Picture *
-Picture_Copy_One (const Picture *pic)
+EtPicture *
+et_picture_copy_single (const EtPicture *pic)
{
- Picture *pic2;
+ EtPicture *pic2;
g_return_val_if_fail (pic != NULL, NULL);
- pic2 = Picture_Allocate ();
+ pic2 = et_picture_new ();
pic2->type = pic->type;
pic2->width = pic->width;
pic2->height = pic->height;
@@ -306,17 +308,21 @@ Picture_Copy_One (const Picture *pic)
return pic2;
}
-Picture *
-Picture_Copy (const Picture *pic)
+EtPicture *
+et_picture_copy_all (const EtPicture *pic)
{
- Picture *pic2 = Picture_Copy_One(pic);
+ EtPicture *pic2 = et_picture_copy_single (pic);
+
if (pic->next)
- pic2->next = Picture_Copy(pic->next);
+ {
+ pic2->next = et_picture_copy_all (pic->next);
+ }
+
return pic2;
}
void
-Picture_Free (Picture *pic)
+et_picture_free (EtPicture *pic)
{
if (pic == NULL)
{
@@ -325,14 +331,14 @@ Picture_Free (Picture *pic)
if (pic->next)
{
- Picture_Free (pic->next);
+ et_picture_free (pic->next);
}
g_free (pic->description);
g_bytes_unref (pic->bytes);
pic->bytes = NULL;
- g_slice_free (Picture, pic);
+ g_slice_free (EtPicture, pic);
}
@@ -345,7 +351,7 @@ Picture_Free (Picture *pic)
*
* Returns: an image on success, %NULL otherwise
*/
-Picture *
+EtPicture *
et_picture_load_file_data (GFile *file, GError **error)
{
gsize size;
@@ -398,7 +404,7 @@ et_picture_load_file_data (GFile *file, GError **error)
else
{
/* Image loaded. */
- Picture *pic;
+ EtPicture *pic;
gpointer data;
gsize data_size;
@@ -413,7 +419,7 @@ et_picture_load_file_data (GFile *file, GError **error)
g_assert (error == NULL || *error == NULL);
- pic = Picture_Allocate ();
+ pic = et_picture_new ();
data = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (ostream));
data_size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (ostream));
pic->bytes = g_bytes_new_take (data, data_size);
@@ -427,7 +433,7 @@ et_picture_load_file_data (GFile *file, GError **error)
/*
* et_picture_save_file_data:
- * @pic: the #Picture from which to take an image
+ * @pic: the #EtPicture from which to take an image
* @file: the #GFile for which to save an image
* @error: a #GError to provide information on errors, or %NULL to ignore
*
@@ -436,7 +442,9 @@ et_picture_load_file_data (GFile *file, GError **error)
* Returns: %TRUE on success, %FALSE otherwise
*/
gboolean
-et_picture_save_file_data (const Picture *pic, GFile *file, GError **error)
+et_picture_save_file_data (const EtPicture *pic,
+ GFile *file,
+ GError **error)
{
GFileOutputStream *file_ostream;
gconstpointer data;
diff --git a/src/picture.h b/src/picture.h
index bb8f2d1..4b0285b 100644
--- a/src/picture.h
+++ b/src/picture.h
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
+#define ET_TYPE_PICTURE (et_picture_get_type ())
+
/* Defined in et_core.h
typedef struct _Picture Picture;
struct _Picture
@@ -72,17 +74,18 @@ typedef enum
PICTURE_FORMAT_UNKNOWN
} Picture_Format;
-Picture *Picture_Allocate (void);
-Picture *Picture_Copy_One (const Picture *pic);
-Picture *Picture_Copy (const Picture *pic);
-void Picture_Free (Picture *pic);
-Picture_Format Picture_Format_From_Data (const Picture *pic);
+GType et_picture_get_type (void);
+EtPicture * et_picture_new (void);
+EtPicture * et_picture_copy_single (const EtPicture *pic);
+EtPicture * et_picture_copy_all (const EtPicture *pic);
+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);
-gchar * Picture_Info (const Picture *pic, ET_Tag_Type tag_type);
+gchar * et_picture_format_info (const EtPicture *pic, ET_Tag_Type tag_type);
-Picture *et_picture_load_file_data (GFile *file, GError **error);
-gboolean et_picture_save_file_data (const Picture *pic, GFile *file, GError **error);
+EtPicture * et_picture_load_file_data (GFile *file, GError **error);
+gboolean et_picture_save_file_data (const EtPicture *pic, GFile *file, GError **error);
EtPictureType et_picture_type_from_filename (const gchar *filename_utf8);
diff --git a/src/tag_area.c b/src/tag_area.c
index c6968c3..61dfa44 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -614,7 +614,7 @@ on_apply_to_selection (GObject *object,
}
else if (object == G_OBJECT (priv->apply_image_toolitem))
{
- Picture *res = NULL, *pic, *prev_pic = NULL;
+ EtPicture *res = NULL, *pic, *prev_pic = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -623,8 +623,9 @@ on_apply_to_selection (GObject *object,
{
do
{
- gtk_tree_model_get(model, &iter, PICTURE_COLUMN_DATA, &pic, -1);
- pic = Picture_Copy_One(pic);
+ gtk_tree_model_get (model, &iter, PICTURE_COLUMN_DATA, &pic,
+ -1);
+
if (!res)
res = pic;
else
@@ -638,7 +639,8 @@ on_apply_to_selection (GObject *object,
etfile = (ET_File *)l->data;
FileTag = ET_File_Tag_Item_New();
ET_Copy_File_Tag_Item(etfile,FileTag);
- ET_Set_Field_File_Tag_Picture((Picture **)&FileTag->picture, res);
+ ET_Set_Field_File_Tag_Picture ((EtPicture **)&FileTag->picture,
+ res);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
if (res)
@@ -650,7 +652,7 @@ on_apply_to_selection (GObject *object,
msg = g_strdup (_("Removed images from selected files"));
}
- Picture_Free (res);
+ et_picture_free (res);
}
g_list_free(etfilelist);
@@ -1215,31 +1217,15 @@ static void
PictureEntry_Clear (EtTagArea *self)
{
EtTagAreaPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- Picture *pic;
priv = et_tag_area_get_instance_private (self);
- model = GTK_TREE_MODEL (priv->images_model);
-
- /* FIXME: Make Picture a boxed type, so that it can be freed
- * automatically. */
- if (gtk_tree_model_get_iter_first (model, &iter))
- {
- do
- {
- gtk_tree_model_get (model, &iter, PICTURE_COLUMN_DATA, &pic, -1);
- Picture_Free (pic);
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
gtk_list_store_clear (priv->images_model);
}
static void
PictureEntry_Update (EtTagArea *self,
- Picture *pic,
+ EtPicture *pic,
gboolean select_it)
{
EtTagAreaPrivate *priv;
@@ -1305,8 +1291,8 @@ PictureEntry_Update (EtTagArea *self,
GDK_INTERP_BILINEAR);
g_object_unref(pixbuf);
- pic_info = Picture_Info (pic,
- ETCore->ETFileDisplayed->ETFileDescription->TagType);
+ pic_info = et_picture_format_info (pic,
+ ETCore->ETFileDisplayed->ETFileDescription->TagType);
gtk_list_store_insert_with_values (priv->images_model, &iter1,
G_MAXINT,
PICTURE_COLUMN_PIC,
@@ -1314,7 +1300,7 @@ PictureEntry_Update (EtTagArea *self,
PICTURE_COLUMN_TEXT,
pic_info,
PICTURE_COLUMN_DATA,
- Picture_Copy_One (pic), -1);
+ pic, -1);
g_free(pic_info);
if (select_it)
@@ -1372,7 +1358,7 @@ static void
load_picture_from_file (GFile *file,
EtTagArea *self)
{
- Picture *pic;
+ EtPicture *pic;
const gchar *filename_utf8;
GFileInfo *info;
GError *error = NULL;
@@ -1453,7 +1439,7 @@ load_picture_from_file (GFile *file,
PictureEntry_Update (self, pic, TRUE);
- Picture_Free (pic);
+ et_picture_free (pic);
}
g_object_unref (info);
@@ -1614,7 +1600,7 @@ on_picture_properties_button_clicked (GObject *object,
{
GtkWidget *PictureTypesWindow;
GtkTreePath *path = l->data;
- Picture *pic = NULL;
+ EtPicture *pic = NULL;
GtkTreeSelection *selectiontype;
gchar *title;
GtkTreePath *rowPath;
@@ -1778,8 +1764,8 @@ on_picture_properties_button_clicked (GObject *object,
pic->description = buffer;
/* Update value in the PictureEntryView. */
- pic_info = Picture_Info (pic,
- ETCore->ETFileDisplayed->ETFileDescription->TagType);
+ pic_info = et_picture_format_info (pic,
+ ETCore->ETFileDisplayed->ETFileDescription->TagType);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
PICTURE_COLUMN_TEXT, pic_info, -1);
g_free (pic_info);
@@ -1828,7 +1814,7 @@ on_picture_save_button_clicked (GObject *object,
{
GtkTreePath *path = l->data;
GtkTreeIter iter;
- Picture *pic;
+ EtPicture *pic;
gchar *title;
gboolean valid;
gint response;
@@ -2057,13 +2043,9 @@ on_picture_clear_button_clicked (GObject *object,
for (l = refs; l != NULL; l = g_list_next (l))
{
GtkTreePath *path = gtk_tree_row_reference_get_path (l->data);
- Picture *pic;
if (gtk_tree_model_get_iter (model, &iter, path))
{
- gtk_tree_model_get(model, &iter, PICTURE_COLUMN_DATA, &pic,-1);
- Picture_Free(pic);
-
gtk_list_store_remove (priv->images_model, &iter);
}
@@ -2130,6 +2112,10 @@ create_tag_area (EtTagArea *self)
priv = et_tag_area_get_instance_private (self);
+ /* Ensure that the boxed type is registered before using it in
+ * GtkBuilder. */
+ et_picture_get_type ();
+
/* Main Frame */
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder,
@@ -2939,13 +2925,13 @@ et_tag_area_create_file_tag (EtTagArea *self)
/* Picture */
{
- Picture *pic, *prev_pic = NULL;
+ EtPicture *pic, *prev_pic = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
if (FileTag->picture)
{
- Picture_Free (FileTag->picture);
+ et_picture_free (FileTag->picture);
FileTag->picture = NULL;
}
@@ -2955,8 +2941,9 @@ et_tag_area_create_file_tag (EtTagArea *self)
{
do
{
- gtk_tree_model_get (model, &iter, PICTURE_COLUMN_DATA, &pic,-1);
- pic = Picture_Copy_One (pic);
+ gtk_tree_model_get (model, &iter, PICTURE_COLUMN_DATA, &pic,
+ -1);
+
if (!FileTag->picture)
{
FileTag->picture = pic;
@@ -3249,7 +3236,7 @@ et_tag_area_display_et_file (EtTagArea *self,
if (FileTag && FileTag->picture)
{
- Picture *pic;
+ EtPicture *pic;
guint nbr_pic = 0;
GtkWidget *page;
gchar *string;
diff --git a/src/tags/flac_tag.c b/src/tags/flac_tag.c
index 7156fcb..4545927 100644
--- a/src/tags/flac_tag.c
+++ b/src/tags/flac_tag.c
@@ -91,7 +91,7 @@ flac_tag_read_file_tag (GFile *file,
gchar *string = NULL;
guint i;
- Picture *prev_pic = NULL;
+ EtPicture *prev_pic = NULL;
//gint j = 1;
g_return_val_if_fail (file != NULL && FileTag != NULL, FALSE);
@@ -666,12 +666,12 @@ flac_tag_read_file_tag (GFile *file,
* Picture *
***********/
FLAC__StreamMetadata_Picture *p;
- Picture *pic;
+ EtPicture *pic;
// Get picture data from block
p = &block->data.picture;
- pic = Picture_Allocate();
+ pic = et_picture_new ();
if (!prev_pic)
FileTag->picture = pic;
else
@@ -1073,7 +1073,8 @@ flac_tag_write_file_tag (const ET_File *ETFile,
* Picture *
***********/
{
- Picture *pic = FileTag->picture;
+ EtPicture *pic = FileTag->picture;
+
while (pic)
{
/* TODO: Can this ever be NULL? */
diff --git a/src/tags/id3_tag.c b/src/tags/id3_tag.c
index e755c7a..05cdc33 100644
--- a/src/tags/id3_tag.c
+++ b/src/tags/id3_tag.c
@@ -167,7 +167,7 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
ID3Field *id3_field;
//gchar *string;
gchar *string1;
- Picture *pic;
+ EtPicture *pic;
g_return_val_if_fail (ETFile != NULL && ETFile->FileTag != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
diff --git a/src/tags/id3v24_tag.c b/src/tags/id3v24_tag.c
index 8c5159a..279ff6b 100644
--- a/src/tags/id3v24_tag.c
+++ b/src/tags/id3v24_tag.c
@@ -99,7 +99,7 @@ id3tag_read_file_tag (GFile *gfile,
struct id3_frame *frame;
union id3_field *field;
gchar *string1, *string2;
- Picture *prev_pic = NULL;
+ EtPicture *prev_pic = NULL;
int i, j;
unsigned tmpupdate, update = 0;
long tagsize;
@@ -447,9 +447,9 @@ id3tag_read_file_tag (GFile *gfile,
******************/
for (i = 0; (frame = id3_tag_findframe(tag, "APIC", i)); i++)
{
- Picture *pic;
+ EtPicture *pic;
- pic = Picture_Allocate();
+ pic = et_picture_new ();
if (!prev_pic)
FileTag->picture = pic;
else
@@ -914,7 +914,7 @@ id3tag_write_file_v24tag (const ET_File *ETFile,
struct id3_frame *frame;
union id3_field *field;
gchar *string1;
- Picture *pic;
+ EtPicture *pic;
gboolean strip_tags = TRUE;
guchar genre_value = ID3_INVALID_GENRE;
gboolean success;
diff --git a/src/tags/mp4_tag.cc b/src/tags/mp4_tag.cc
index 7be5b9e..1a2ed64 100644
--- a/src/tags/mp4_tag.cc
+++ b/src/tags/mp4_tag.cc
@@ -209,7 +209,7 @@ mp4tag_read_file_tag (GFile *file,
const TagLib::MP4::CoverArtList covers = cover.toCoverArtList ();
const TagLib::MP4::CoverArt &art = covers.front ();
- FileTag->picture = Picture_Allocate ();
+ FileTag->picture = et_picture_new ();
/* TODO: Use g_bytes_new_with_free_func()? */
FileTag->picture->bytes = g_bytes_new (art.data ().data (),
diff --git a/src/tags/ogg_tag.c b/src/tags/ogg_tag.c
index fe2aba2..99a103a 100644
--- a/src/tags/ogg_tag.c
+++ b/src/tags/ogg_tag.c
@@ -172,7 +172,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
gchar *string1 = NULL;
gchar *string2 = NULL;
guint field_num, i;
- Picture *prev_pic = NULL;
+ EtPicture *prev_pic = NULL;
/*********
* Title *
@@ -481,7 +481,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
field_num = 0;
while ( (string = vorbis_comment_query(vc,"COVERART",field_num++)) != NULL )
{
- Picture *pic;
+ EtPicture *pic;
guchar *data;
gsize data_size;
@@ -489,7 +489,8 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
* field in converted in a METADATA_PICTURE_BLOCK field. */
FileTag->saved = FALSE;
- pic = Picture_Allocate();
+ pic = et_picture_new ();
+
if (!prev_pic)
FileTag->picture = pic;
else
@@ -522,14 +523,14 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
while ((string = vorbis_comment_query (vc, "METADATA_BLOCK_PICTURE",
field_num++)) != NULL)
{
- Picture *pic;
+ EtPicture *pic;
gsize bytes_pos, mimelen, desclen;
guchar *decoded_ustr;
GBytes *bytes;
gsize decoded_size;
gsize data_size;
- pic = Picture_Allocate();
+ pic = et_picture_new ();
if (!prev_pic)
{
@@ -790,7 +791,7 @@ ogg_tag_write_file_tag (const ET_File *ETFile,
vorbis_comment *vc;
gchar *string;
GList *l;
- Picture *pic;
+ EtPicture *pic;
g_return_val_if_fail (ETFile != NULL && ETFile->FileTag != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
diff --git a/tests/test-picture.c b/tests/test-picture.c
index adcb7d6..ea25733 100644
--- a/tests/test-picture.c
+++ b/tests/test-picture.c
@@ -21,14 +21,14 @@
static void
picture_copy (void)
{
- Picture *pic1;
- Picture *pic2;
- Picture *pic3;
- Picture *pic1_copy;
- Picture *pic2_copy;
- const Picture *pic3_copy;
+ EtPicture *pic1;
+ EtPicture *pic2;
+ EtPicture *pic3;
+ EtPicture *pic1_copy;
+ EtPicture *pic2_copy;
+ const EtPicture *pic3_copy;
- pic1 = Picture_Allocate ();
+ pic1 = et_picture_new ();
pic1->type = ET_PICTURE_TYPE_LEAFLET_PAGE;
pic1->width = 640;
@@ -36,7 +36,7 @@ picture_copy (void)
pic1->description = g_strdup ("foobar.png");
pic1->bytes = g_bytes_new_static ("foobar", 6);
- pic2 = Picture_Copy (pic1);
+ pic2 = et_picture_copy_all (pic1);
g_assert_cmpint (pic2->type, ==, ET_PICTURE_TYPE_LEAFLET_PAGE);
g_assert_cmpint (pic2->width, ==, 640);
@@ -47,7 +47,7 @@ picture_copy (void)
g_assert (pic2->bytes == pic1->bytes);
g_assert (pic2->next == NULL);
- pic3 = Picture_Allocate ();
+ pic3 = et_picture_new ();
pic3->type = ET_PICTURE_TYPE_ILLUSTRATION;
pic3->width = 320;
@@ -58,7 +58,7 @@ picture_copy (void)
pic1->next = pic2;
pic2->next = pic3;
- pic2_copy = Picture_Copy_One (pic2);
+ pic2_copy = et_picture_copy_single (pic2);
g_assert_cmpint (pic2_copy->type, ==, ET_PICTURE_TYPE_LEAFLET_PAGE);
g_assert_cmpint (pic2_copy->width, ==, 640);
@@ -67,7 +67,7 @@ picture_copy (void)
g_assert_cmpint (g_bytes_get_size (pic2_copy->bytes), ==, 6);
g_assert (pic2_copy->next == NULL);
- pic1_copy = Picture_Copy (pic1);
+ pic1_copy = et_picture_copy_all (pic1);
g_assert (pic1_copy->next != NULL);
g_assert (pic1_copy->next->next != NULL);
@@ -81,9 +81,9 @@ picture_copy (void)
g_assert_cmpstr (pic3_copy->description, ==, "bash.jpg");
g_assert_cmpint (g_bytes_get_size (pic3_copy->bytes), ==, 3);
- Picture_Free (pic1_copy);
- Picture_Free (pic2_copy);
- Picture_Free (pic1);
+ et_picture_free (pic1_copy);
+ et_picture_free (pic2_copy);
+ et_picture_free (pic1);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]