[easytag] Refactor loading of default masks



commit 2397a12a309b7e3c729cc344ba856a2028195ace
Author: David King <amigadave amigadave com>
Date:   Sun May 5 21:23:34 2013 +0100

    Refactor loading of default masks
    
    Make mask arrays static and const.

 src/scan.c    |    4 ++--
 src/setting.c |   20 ++++++++++++--------
 src/setting.h |    6 ++++--
 3 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/scan.c b/src/scan.c
index f26ad54..8cc3954 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -109,7 +109,7 @@ static GtkWidget *MaskEditorDownButton;
 static GtkWidget *MaskEditorSaveButton;
 
 /* Some predefined masks -- IMPORTANT: Null-terminate me! */
-gchar *Scan_Masks [] =
+static const gchar *Scan_Masks [] =
 {
     "%a - %b"G_DIR_SEPARATOR_S"%n - %t",
     "%a_-_%b"G_DIR_SEPARATOR_S"%n_-_%t",
@@ -136,7 +136,7 @@ gchar *Scan_Masks [] =
     NULL
 };
 
-gchar *Rename_File_Masks [] =
+static const gchar *Rename_File_Masks [] =
 {
     "%n - %a - %t",
     "%n_-_%a_-_%t",
diff --git a/src/setting.c b/src/setting.c
index 3111ebb..9537a1e 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -1241,9 +1241,11 @@ Populate_List_Store_From_File (const gchar *filename, GtkListStore *liststore, g
 /*
  * Functions for writing and reading list of 'Fill Tag' masks
  */
-void Load_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum, gchar **fallback)
+void
+Load_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum,
+                          const gchar * const *fallback)
 {
-    gint i = 0;
+    gsize i = 0;
     GtkTreeIter iter;
 
     if (!Populate_List_Store_From_File(SCAN_TAG_MASKS_FILE, liststore, colnum))
@@ -1253,8 +1255,8 @@ void Load_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum, gchar **fal
 
         while(fallback[i])
         {
-            gtk_list_store_append(liststore, &iter);
-            gtk_list_store_set(liststore, &iter, colnum, fallback[i], -1);
+            gtk_list_store_insert_with_values (liststore, &iter, G_MAXINT,
+                                               colnum, fallback[i], -1);
             i++;
         }
     }
@@ -1269,9 +1271,11 @@ void Save_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum)
 /*
  * Functions for writing and reading list of 'Rename File' masks
  */
-void Load_Rename_File_Masks_List (GtkListStore *liststore, gint colnum, gchar **fallback)
+void
+Load_Rename_File_Masks_List (GtkListStore *liststore, gint colnum,
+                             const gchar * const *fallback)
 {
-    gint i = 0;
+    gsize i = 0;
     GtkTreeIter iter;
 
     if (!Populate_List_Store_From_File(RENAME_FILE_MASKS_FILE, liststore, colnum))
@@ -1281,8 +1285,8 @@ void Load_Rename_File_Masks_List (GtkListStore *liststore, gint colnum, gchar **
 
         while(fallback[i])
         {
-            gtk_list_store_append(liststore, &iter);
-            gtk_list_store_set(liststore, &iter, colnum, fallback[i], -1);
+            gtk_list_store_insert_with_values (liststore, &iter, G_MAXINT,
+                                               colnum, fallback[i], -1);
             i++;
         }
     }
diff --git a/src/setting.h b/src/setting.h
index 947553e..53f92cd 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -309,11 +309,13 @@ gboolean Setting_Create_Files     (void);
 
 
 /* MasksList */
-void Load_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum, gchar **fallback);
+void Load_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum,
+                               const gchar * const *fallback);
 void Save_Scan_Tag_Masks_List (GtkListStore *liststore, gint colnum);
 
 /* RenameFileMasksList */
-void Load_Rename_File_Masks_List (GtkListStore *liststore, gint colnum, gchar **fallback);
+void Load_Rename_File_Masks_List (GtkListStore *liststore, gint colnum,
+                                  const gchar * const *fallback);
 void Save_Rename_File_Masks_List (GtkListStore *liststore, gint colnum);
 
 /* RenameDirectoryMasksList 'RenameDirectoryMaskCombo' combobox */


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