[easytag/wip/core-refactoring: 1/3] Refactor function to check if all files are saved
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/core-refactoring: 1/3] Refactor function to check if all files are saved
- Date: Mon, 5 Jan 2015 23:25:21 +0000 (UTC)
commit 01be3143fa8d9454d74f9e2ca5c037640d5ad090
Author: David King <amigadave amigadave com>
Date: Mon Jan 5 21:27:34 2015 +0000
Refactor function to check if all files are saved
Accept the file list as a parameter.
src/application_window.c | 2 +-
src/browser.c | 2 +-
src/file_list.c | 26 ++++++++++++++++----------
src/file_list.h | 2 +-
4 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index ffa7cff..9d9f056 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -2676,7 +2676,7 @@ et_application_window_quit (EtApplicationWindow *self)
/* Check if all files have been saved before exit */
if (g_settings_get_boolean (MainSettings, "confirm-when-unsaved-files")
- && ET_Check_If_All_Files_Are_Saved () != TRUE)
+ && et_file_list_check_all_saved (ETCore->ETFileList) != TRUE)
{
/* Some files haven't been saved */
msgbox = gtk_message_dialog_new (GTK_WINDOW (self),
diff --git a/src/browser.c b/src/browser.c
index e359395..f1c3439 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -846,7 +846,7 @@ Browser_Tree_Node_Selected (EtBrowser *self, GtkTreeSelection *selection)
/* Check if all files have been saved before changing the directory */
if (g_settings_get_boolean (MainSettings, "confirm-when-unsaved-files")
- && ET_Check_If_All_Files_Are_Saved () != TRUE)
+ && et_file_list_check_all_saved (ETCore->ETFileList) != TRUE)
{
GtkWidget *msgdialog;
gint response;
diff --git a/src/file_list.c b/src/file_list.c
index ab0fd57..5e345f5 100644
--- a/src/file_list.c
+++ b/src/file_list.c
@@ -1382,28 +1382,34 @@ ET_Add_File_To_History_List (ET_File *ETFile)
return TRUE;
}
+
/*
- * Ckecks if some files, in the list, had been changed but not saved.
- * Returns TRUE if all files have been saved.
- * Returns FALSE if some changes haven't been saved.
+ * et_file_list_check_all_saved:
+ * @etfilelist: (element-type ET_File) (allow-none): a list of files
+ *
+ * Checks if some files, in the list, have been changed but not saved.
+ *
+ * Returns: %TRUE if all files have been saved, %FALSE otherwise
*/
gboolean
-ET_Check_If_All_Files_Are_Saved (void)
+et_file_list_check_all_saved (GList *etfilelist)
{
- /* Check if some files haven't been saved, if didn't nochange=0 */
- if (!ETCore->ETFileList)
+ if (!etfilelist)
{
return TRUE;
- }else
+ }
+ else
{
GList *l;
- for (l = g_list_first (ETCore->ETFileList); l != NULL;
- l = g_list_next (l))
+ for (l = g_list_first (etfilelist); l != NULL; l = g_list_next (l))
{
- if (ET_Check_If_File_Is_Saved ((ET_File *)l->data) == FALSE)
+ if (!ET_Check_If_File_Is_Saved ((ET_File *)l->data))
+ {
return FALSE;
+ }
}
+
return TRUE;
}
}
diff --git a/src/file_list.h b/src/file_list.h
index be7ba20..b3ecfb6 100644
--- a/src/file_list.h
+++ b/src/file_list.h
@@ -35,7 +35,7 @@ gboolean ET_Create_Artist_Album_File_List (void);
gboolean ET_Free_Artist_Album_File_List (void);
gboolean ET_Remove_File_From_File_List (ET_File *ETFile);
-gboolean ET_Check_If_All_Files_Are_Saved (void);
+gboolean et_file_list_check_all_saved (GList *etfilelist);
GList * ET_Displayed_File_List_First (void);
GList * ET_Displayed_File_List_Previous (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]