[easytag] Refactor and rename ET_Check_If_File_Is_Saved()



commit a67b2fa023ce32686d9e57870de44c3986a601b7
Author: David King <amigadave amigadave com>
Date:   Mon May 23 17:35:43 2016 +0100

    Refactor and rename ET_Check_If_File_Is_Saved()
    
    Avoid comparing directly against TRUE or FALSE. Rename to
    et_file_check_saved().

 src/application_window.c |    2 +-
 src/browser.c            |    6 +++---
 src/file.c               |   29 +++++++++++++++++++----------
 src/file.h               |    2 +-
 src/file_list.c          |    2 +-
 5 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index c05e2e2..045113d 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -2667,7 +2667,7 @@ et_application_window_update_actions (EtApplicationWindow *self)
                                                                               l->data);
                 has_undo    |= ET_File_Data_Has_Undo_Data(etfile);
                 has_redo    |= ET_File_Data_Has_Redo_Data(etfile);
-                //has_to_save |= ET_Check_If_File_Is_Saved(etfile);
+                /* has_to_save |= et_file_check_saved (etfile); */
                 if ((has_undo && has_redo /*&& has_to_save*/) || !l->next) // Useless to check the other 
files
                     break;
             }
diff --git a/src/browser.c b/src/browser.c
index 4d51eae..5c6f3e0 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1706,7 +1706,7 @@ Browser_List_Set_Row_Appearance (EtBrowser *self, GtkTreeIter *iter)
         background = NULL;
 
     // Set text to bold/red if 'filename' or 'tag' changed
-    if ( ET_Check_If_File_Is_Saved(rowETFile) == FALSE )
+    if (!et_file_check_saved (rowETFile))
     {
         if (g_settings_get_boolean (MainSettings, "file-changed-bold"))
         {
@@ -2462,7 +2462,7 @@ Browser_Artist_List_Set_Row_Appearance (EtBrowser *self, GtkTreeIter *iter)
     {
         for (m = (GList *)l->data; m != NULL; m = g_list_next (m))
         {
-            if (ET_Check_If_File_Is_Saved ((ET_File *)m->data) == FALSE)
+            if (!et_file_check_saved ((ET_File *)m->data))
             {
                 if (g_settings_get_boolean (MainSettings, "file-changed-bold"))
                 {
@@ -2701,7 +2701,7 @@ Browser_Album_List_Set_Row_Appearance (EtBrowser *self, GtkTreeIter *iter)
                              ALBUM_ETFILE_LIST_POINTER, &l, -1);
          l != NULL; l = g_list_next (l))
     {
-        if (ET_Check_If_File_Is_Saved ((ET_File *)l->data) == FALSE)
+        if (!et_file_check_saved ((ET_File *)l->data))
         {
             if (g_settings_get_boolean (MainSettings, "file-changed-bold"))
             {
diff --git a/src/file.c b/src/file.c
index 353f02e..041d613 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1657,32 +1657,41 @@ ET_File_Data_Has_Redo_Data (const ET_File *ETFile)
 }
 
 /*
- * Ckecks if the current files had been changed but not saved.
+ * Checks if the current files had been changed but not saved.
  * Returns TRUE if the file has been saved.
  * Returns FALSE if some changes haven't been saved.
  */
 gboolean
-ET_Check_If_File_Is_Saved (const ET_File *ETFile)
+et_file_check_saved (const ET_File *ETFile)
 {
-    File_Tag  *FileTag     = NULL;
-    File_Name *FileNameNew = NULL;
+    const File_Tag *FileTag = NULL;
+    const File_Name *FileNameNew = NULL;
 
     g_return_val_if_fail (ETFile != NULL, TRUE);
 
     if (ETFile->FileTag)
-        FileTag     = ETFile->FileTag->data;
+    {
+        FileTag = ETFile->FileTag->data;
+    }
+
     if (ETFile->FileNameNew)
+    {
         FileNameNew = ETFile->FileNameNew->data;
+    }
 
-    // Check if the tag has been changed
-    if ( FileTag && FileTag->saved != TRUE )
+    /* Check if the tag has been changed. */
+    if (FileTag && !FileTag->saved)
+    {
         return FALSE;
+    }
 
-    // Check if name of file has been changed
-    if ( FileNameNew && FileNameNew->saved != TRUE )
+    /* Check if name of file has been changed. */
+    if (FileNameNew && !FileNameNew->saved)
+    {
         return FALSE;
+    }
 
-    // No changes
+    /* No changes. */
     return TRUE;
 }
 
diff --git a/src/file.h b/src/file.h
index ed43947..7f23df8 100644
--- a/src/file.h
+++ b/src/file.h
@@ -62,7 +62,7 @@ typedef struct
     ET_File *ETFile;           /* Pointer to item of ETFileList changed */
 } ET_History_File;
 
-gboolean ET_Check_If_File_Is_Saved (const ET_File *ETFile);
+gboolean et_file_check_saved (const ET_File *ETFile);
 
 ET_File * ET_File_Item_New (void);
 void ET_Free_File_List_Item (ET_File *ETFile);
diff --git a/src/file_list.c b/src/file_list.c
index e2b124b..a756b34 100644
--- a/src/file_list.c
+++ b/src/file_list.c
@@ -1390,7 +1390,7 @@ et_file_list_check_all_saved (GList *etfilelist)
 
         for (l = g_list_first (etfilelist); l != NULL; l = g_list_next (l))
         {
-            if (!ET_Check_If_File_Is_Saved ((ET_File *)l->data))
+            if (!et_file_check_saved ((ET_File *)l->data))
             {
                 return FALSE;
             }


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