[easytag] Move undo key generation to misc.c



commit af47e0762d646d72b77c77d5f1de234bbaa22095
Author: David King <amigadave amigadave com>
Date:   Sat Feb 21 16:20:20 2015 +0000

    Move undo key generation to misc.c
    
    This should make it easier to write tests.

 src/file.c      |    9 ---------
 src/file.h      |    2 --
 src/file_list.c |    3 ++-
 src/file_name.c |    3 +--
 src/file_tag.c  |    6 +++---
 src/misc.c      |    8 ++++++++
 src/misc.h      |    2 ++
 7 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/file.c b/src/file.c
index 7c57599..f57ad6b 100644
--- a/src/file.c
+++ b/src/file.c
@@ -81,15 +81,6 @@ ET_File_Item_New (void)
     return ETFile;
 }
 
-
-/* Key for Undo */
-guint
-ET_Undo_Key_New (void)
-{
-    static guint ETUndoKey = 0;
-    return ++ETUndoKey;
-}
-
 /*
  * Comparison function for sorting by ascending filename.
  */
diff --git a/src/file.h b/src/file.h
index 7fddf60..ed43947 100644
--- a/src/file.h
+++ b/src/file.h
@@ -72,8 +72,6 @@ gboolean ET_Save_File_Name_Internal (const ET_File *ETFile, File_Name *FileName)
 gboolean ET_Save_File_Tag_To_HD (ET_File *ETFile, GError **error);
 gboolean ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag);
 
-guint ET_Undo_Key_New (void);
-
 gboolean ET_Undo_File_Data (ET_File *ETFile);
 gboolean ET_Redo_File_Data (ET_File *ETFile);
 gboolean ET_File_Data_Has_Undo_Data (const ET_File *ETFile);
diff --git a/src/file_list.c b/src/file_list.c
index 58d1212..887bb9a 100644
--- a/src/file_list.c
+++ b/src/file_list.c
@@ -32,6 +32,7 @@
 #include "charset.h"
 #include "easytag.h"
 #include "log.h"
+#include "misc.h"
 #include "mpeg_header.h"
 #include "monkeyaudio_header.h"
 #include "musepack_header.h"
@@ -442,7 +443,7 @@ et_file_list_add (GList *file_list,
      * Process the filename and tag to generate undo if needed...
      * The undo key must be the same for FileName and FileTag => changed in the same time
      */
-    undo_key = ET_Undo_Key_New();
+    undo_key = et_undo_key_new ();
 
     FileName = et_file_name_new ();
     FileName->key = undo_key;
diff --git a/src/file_name.c b/src/file_name.c
index 35dcf33..8b335d3 100644
--- a/src/file_name.c
+++ b/src/file_name.c
@@ -19,7 +19,6 @@
 #include "file_name.h"
 
 #include "charset.h"
-#include "file.h"
 #include "misc.h"
 
 #include <string.h>
@@ -33,7 +32,7 @@ et_file_name_new (void)
     File_Name *file_name;
 
     file_name = g_slice_new (File_Name);
-    file_name->key = ET_Undo_Key_New ();
+    file_name->key = et_undo_key_new ();
     file_name->saved = FALSE;
     file_name->value = NULL;
     file_name->value_utf8 = NULL;
diff --git a/src/file_tag.c b/src/file_tag.c
index 507b39f..9c66ec4 100644
--- a/src/file_tag.c
+++ b/src/file_tag.c
@@ -18,7 +18,7 @@
 
 #include "file_tag.h"
 
-#include "file.h"
+#include "misc.h"
 
 /*
  * Create a new File_Tag structure.
@@ -29,7 +29,7 @@ et_file_tag_new (void)
     File_Tag *file_tag;
 
     file_tag = g_slice_new0 (File_Tag);
-    file_tag->key = ET_Undo_Key_New ();
+    file_tag->key = et_undo_key_new ();
 
     return file_tag;
 }
@@ -105,7 +105,7 @@ et_file_tag_copy_into (File_Tag *destination,
     g_return_if_fail (destination != NULL);
 
     /* Key for the item, may be overwritten. */
-    destination->key = ET_Undo_Key_New ();
+    destination->key = et_undo_key_new ();
 
     et_file_tag_set_title (destination, source->title);
     et_file_tag_set_artist (destination, source->artist);
diff --git a/src/misc.c b/src/misc.c
index b19b45f..578fa4a 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -427,3 +427,11 @@ et_filename_prepare (gchar *filename_utf8,
             *character = '-';
     }
 }
+
+/* Key for Undo */
+guint
+et_undo_key_new (void)
+{
+    static guint ETUndoKey = 0;
+    return ++ETUndoKey;
+}
diff --git a/src/misc.h b/src/misc.h
index 63b2ed8..41183d6 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -39,6 +39,8 @@ gchar * et_track_number_to_string (const guint track_number);
 
 void et_filename_prepare (gchar *filename_utf8, gboolean replace_illegal);
 
+guint et_undo_key_new (void);
+
 G_END_DECLS
 
 #endif /* ET_MISC_H_ */


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