[easytag] Use gtk_[list|tree]_store_insert_with_values()



commit 66011431dd4da6463c9e2e4ef664e3af13150c6f
Author: David King <amigadave amigadave com>
Date:   Sat Jun 1 19:15:57 2013 +0100

    Use gtk_[list|tree]_store_insert_with_values()
    
    Rather than inserting or appending a row and then setting values on it,
    simply insert a new row and set values in a single call.

 src/browser.c |  162 ++++++++++++++++++++++++++++++--------------------------
 src/cddb.c    |   42 +++++++++------
 src/log.c     |   31 +++++------
 src/misc.c    |   79 +++++++++++++---------------
 src/picture.c |   42 ++++++++-------
 src/scan.c    |   13 ++---
 src/setting.c |   10 ++--
 7 files changed, 195 insertions(+), 184 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 8677679..d5c7486 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1018,30 +1018,35 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
             g_free(dir2_utf8);
         }
 
-        // File list displays the current filename (name on HardDisk) and tag fields
-        gtk_list_store_append(fileListModel, &rowIter);
+        /* File list displays the current filename (name on disc) and tag
+         * fields. */
         track = g_strconcat(FileTag->track ? FileTag->track : "",FileTag->track_total ? "/" : 
NULL,FileTag->track_total,NULL);
-               
-        gtk_list_store_set(fileListModel, &rowIter,
-                           LIST_FILE_NAME,          basename_utf8,
-                           LIST_FILE_POINTER, l->data,
-                           LIST_FILE_KEY,           fileKey,
-                           LIST_FILE_OTHERDIR,      activate_bg_color,
-                           LIST_FILE_TITLE,         FileTag->title,
-                           LIST_FILE_ARTIST,        FileTag->artist,
-                           LIST_FILE_ALBUM_ARTIST,  FileTag->album_artist,
-                                                  LIST_FILE_ALBUM,         FileTag->album,
-                           LIST_FILE_YEAR,          FileTag->year,
-                           LIST_FILE_DISCNO,        FileTag->disc_number,
-                           LIST_FILE_TRACK,         track,
-                           LIST_FILE_GENRE,         FileTag->genre,
-                           LIST_FILE_COMMENT,       FileTag->comment,
-                           LIST_FILE_COMPOSER,      FileTag->composer,
-                           LIST_FILE_ORIG_ARTIST,   FileTag->orig_artist,
-                           LIST_FILE_COPYRIGHT,     FileTag->copyright,
-                           LIST_FILE_URL,           FileTag->url,
-                           LIST_FILE_ENCODED_BY,    FileTag->encoded_by,
-                           -1);
+        gtk_list_store_insert_with_values (fileListModel, &rowIter, G_MAXINT,
+                                           LIST_FILE_NAME, basename_utf8,
+                                           LIST_FILE_POINTER, l->data,
+                                           LIST_FILE_KEY, fileKey,
+                                           LIST_FILE_OTHERDIR,
+                                           activate_bg_color,
+                                           LIST_FILE_TITLE, FileTag->title,
+                                           LIST_FILE_ARTIST, FileTag->artist,
+                                           LIST_FILE_ALBUM_ARTIST,
+                                           FileTag->album_artist,
+                                           LIST_FILE_ALBUM, FileTag->album,
+                                           LIST_FILE_YEAR, FileTag->year,
+                                           LIST_FILE_DISCNO,
+                                           FileTag->disc_number,
+                                           LIST_FILE_TRACK, track,
+                                           LIST_FILE_GENRE, FileTag->genre,
+                                           LIST_FILE_COMMENT, FileTag->comment,
+                                           LIST_FILE_COMPOSER,
+                                           FileTag->composer,
+                                           LIST_FILE_ORIG_ARTIST,
+                                           FileTag->orig_artist,
+                                           LIST_FILE_COPYRIGHT,
+                                           FileTag->copyright,
+                                           LIST_FILE_URL, FileTag->url,
+                                           LIST_FILE_ENCODED_BY,
+                                           FileTag->encoded_by, -1);
         g_free(basename_utf8);
         g_free(track);
 
@@ -1946,15 +1951,15 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
             nbr_files += g_list_length (g_list_first ((GList *)m->data));
         }
 
-        // Add the new row
-        gtk_list_store_append(artistListModel, &iter);
-        gtk_list_store_set(artistListModel, &iter,
-                           ARTIST_PIXBUF,             "easytag-artist",
-                           ARTIST_NAME,               artistname,
-                           ARTIST_NUM_ALBUMS,         g_list_length(g_list_first(AlbumList)),
-                           ARTIST_NUM_FILES,          nbr_files,
-                           ARTIST_ALBUM_LIST_POINTER, AlbumList,
-                           -1);
+        /* Add the new row. */
+        gtk_list_store_insert_with_values (artistListModel, &iter, G_MAXINT,
+                                           ARTIST_PIXBUF, "easytag-artist",
+                                           ARTIST_NAME, artistname,
+                                           ARTIST_NUM_ALBUMS,
+                                           g_list_length (g_list_first (AlbumList)),
+                                           ARTIST_NUM_FILES, nbr_files,
+                                           ARTIST_ALBUM_LIST_POINTER,
+                                           AlbumList, -1);
 
         // Todo: Use something better than string comparison
         if ( (!artistname && !artist_to_select)
@@ -2094,12 +2099,12 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
         etfilelist = g_list_concat(etfilelist, etfilelist_tmp);
     }
 
-    gtk_list_store_append(albumListModel, &iter);
-    gtk_list_store_set(albumListModel, &iter,
-                       ALBUM_NAME,                _("<All albums>"),
-                       ALBUM_NUM_FILES,           g_list_length(g_list_first(etfilelist)),
-                       ALBUM_ETFILE_LIST_POINTER, etfilelist,
-                       -1);
+    gtk_list_store_insert_with_values (albumListModel, &iter, G_MAXINT,
+                                       ALBUM_NAME, _("<All albums>"),
+                                       ALBUM_NUM_FILES,
+                                       g_list_length (g_list_first (etfilelist)),
+                                       ALBUM_ETFILE_LIST_POINTER, etfilelist,
+                                       -1);
 
     // Create a line for each album of the artist
     for (l = albumlist; l != NULL; l = g_list_next (l))
@@ -2110,13 +2115,13 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
         albumname  = ((File_Tag *)etfile->FileTag->data)->album;
 
         // Add the new row
-        gtk_list_store_append(albumListModel, &iter);
-        gtk_list_store_set(albumListModel, &iter,
-                           ALBUM_PIXBUF,              "easytag-album",
-                           ALBUM_NAME,                albumname,
-                           ALBUM_NUM_FILES,           g_list_length(g_list_first(etfilelist)),
-                           ALBUM_ETFILE_LIST_POINTER, etfilelist,
-                           -1);
+        gtk_list_store_insert_with_values (albumListModel, &iter, G_MAXINT,
+                                           ALBUM_PIXBUF, "easytag-album",
+                                           ALBUM_NAME, albumname,
+                                           ALBUM_NUM_FILES,
+                                           g_list_length (g_list_first (etfilelist)),
+                                           ALBUM_ETFILE_LIST_POINTER,
+                                           etfilelist, -1);
 
         if ( (!albumname && !album_to_select)
         ||   (albumname &&  album_to_select && strcmp(albumname,album_to_select) == 0) )
@@ -2411,16 +2416,19 @@ Browser_Tree_Initialize (void)
             /* Drive letter first so alphabetical drive list order works */
             drive_dir_name = g_strconcat("(", drive_slashless, ") ", drive_label, NULL);
 
-            gtk_tree_store_append(directoryTreeModel, &parent_iter, NULL);
-            gtk_tree_store_set(directoryTreeModel,      &parent_iter,
-                               TREE_COLUMN_DIR_NAME,    drive_dir_name,
-                               TREE_COLUMN_FULL_PATH,   drive_backslashed,
-                               TREE_COLUMN_HAS_SUBDIR,  TRUE,
-                               TREE_COLUMN_SCANNED,     FALSE,
-                               TREE_COLUMN_ICON, drive_icon,
-                               -1);
-            // Insert dummy node
-            gtk_tree_store_append(directoryTreeModel, &dummy_iter, &parent_iter);
+            gtk_tree_store_insert_with_values (directoryTreeModel,
+                                               &parent_iter, NULL, G_MAXINT,
+                                               TREE_COLUMN_DIR_NAME,
+                                               drive_dir_name,
+                                               TREE_COLUMN_FULL_PATH,
+                                               drive_backslashed,
+                                               TREE_COLUMN_HAS_SUBDIR, TRUE,
+                                               TREE_COLUMN_SCANNED, FALSE,
+                                               TREE_COLUMN_ICON, drive_icon,
+                                               -1);
+            /* Insert dummy node. */
+            gtk_tree_store_append (directoryTreeModel, &dummy_iter,
+                                   &parent_iter);
 
             g_free(drive_dir_name);
         }
@@ -2432,16 +2440,16 @@ Browser_Tree_Initialize (void)
 
 #else /* !G_OS_WIN32 */
     drive_icon = get_gicon_for_path (G_DIR_SEPARATOR_S, ET_PATH_STATE_CLOSED);
-    gtk_tree_store_append(directoryTreeModel, &parent_iter, NULL);
-    gtk_tree_store_set(directoryTreeModel, &parent_iter,
-                       TREE_COLUMN_DIR_NAME,    G_DIR_SEPARATOR_S,
-                       TREE_COLUMN_FULL_PATH,   G_DIR_SEPARATOR_S,
-                       TREE_COLUMN_HAS_SUBDIR,  TRUE,
-                       TREE_COLUMN_SCANNED,     FALSE,
-                       TREE_COLUMN_ICON, drive_icon,
-                       -1);
-    // insert dummy node
-    gtk_tree_store_append(directoryTreeModel, &dummy_iter, &parent_iter);
+    gtk_tree_store_insert_with_values (directoryTreeModel, &parent_iter, NULL,
+                                       G_MAXINT, TREE_COLUMN_DIR_NAME,
+                                       G_DIR_SEPARATOR_S,
+                                       TREE_COLUMN_FULL_PATH,
+                                       G_DIR_SEPARATOR_S,
+                                       TREE_COLUMN_HAS_SUBDIR, TRUE,
+                                       TREE_COLUMN_SCANNED, FALSE,
+                                       TREE_COLUMN_ICON, drive_icon, -1);
+    /* Insert dummy node. */
+    gtk_tree_store_append (directoryTreeModel, &dummy_iter, &parent_iter);
 #endif /* !G_OS_WIN32 */
 
     g_object_unref (drive_icon);
@@ -2890,17 +2898,21 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
                 icon = get_gicon_for_path (fullpath_file,
                                            ET_PATH_STATE_CLOSED);
 
-                gtk_tree_store_append(directoryTreeModel, &currentIter, iter);
-                gtk_tree_store_set(directoryTreeModel, &currentIter,
-                                   TREE_COLUMN_DIR_NAME,   dirname_utf8,
-                                   TREE_COLUMN_FULL_PATH,  fullpath_file,
-                                   TREE_COLUMN_HAS_SUBDIR, !has_subdir,
-                                   TREE_COLUMN_SCANNED,    FALSE,
-                                   TREE_COLUMN_ICON, icon, -1);
+                gtk_tree_store_insert_with_values (directoryTreeModel,
+                                                   &currentIter, iter,
+                                                   G_MAXINT,
+                                                   TREE_COLUMN_DIR_NAME,
+                                                   dirname_utf8,
+                                                   TREE_COLUMN_FULL_PATH,
+                                                   fullpath_file,
+                                                   TREE_COLUMN_HAS_SUBDIR,
+                                                   !has_subdir,
+                                                   TREE_COLUMN_SCANNED, FALSE,
+                                                   TREE_COLUMN_ICON, icon, -1);
 
                 if (has_subdir)
                 {
-                    // Insert a dummy node
+                    /* Insert a dummy node. */
                     gtk_tree_store_append(directoryTreeModel, &subNodeIter, &currentIter);
                 }
 
@@ -3003,8 +3015,8 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
                        TREE_COLUMN_ICON, icon, -1);
 #endif /* !G_OS_WIN32 */
 
-    // insert dummy node
-    gtk_tree_store_append(directoryTreeModel, &subNodeIter, iter);
+    /* Insert dummy node. */
+    gtk_tree_store_append (directoryTreeModel, &subNodeIter, iter);
 
     g_object_unref (icon);
 }
diff --git a/src/cddb.c b/src/cddb.c
index 191a17d..4ae54fd 100644
--- a/src/cddb.c
+++ b/src/cddb.c
@@ -1921,13 +1921,17 @@ Cddb_Load_Album_List (gboolean only_red_lines)
 
             if ( (only_red_lines && cddbalbum->track_list) || !only_red_lines)
             {
-                // Load the row in the list
-                gtk_list_store_append(CddbAlbumListModel, &iter);
-                gtk_list_store_set(CddbAlbumListModel, &iter,
-                                   CDDB_ALBUM_LIST_PIXBUF,   cddbalbum->bitmap,
-                                   CDDB_ALBUM_LIST_ALBUM,    cddbalbum->artist_album,
-                                   CDDB_ALBUM_LIST_CATEGORY, cddbalbum->category,
-                                   CDDB_ALBUM_LIST_DATA,     cddbalbum, -1);
+                /* Load the row in the list. */
+                gtk_list_store_insert_with_values (CddbAlbumListModel, &iter,
+                                                   G_MAXINT,
+                                                   CDDB_ALBUM_LIST_PIXBUF,
+                                                   cddbalbum->bitmap,
+                                                   CDDB_ALBUM_LIST_ALBUM,
+                                                   cddbalbum->artist_album,
+                                                   CDDB_ALBUM_LIST_CATEGORY,
+                                                   cddbalbum->category,
+                                                   CDDB_ALBUM_LIST_DATA,
+                                                   cddbalbum, -1);
 
                 Cddb_Album_List_Set_Row_Appearance(&iter);
 
@@ -1946,8 +1950,6 @@ Cddb_Load_Album_List (gboolean only_red_lines)
 static void
 Cddb_Load_Track_Album_List (GList *track_list)
 {
-    GtkTreeIter iter;
-
     if (CddbWindow && track_list && CddbTrackListView)
     {
         GList *l;
@@ -1964,15 +1966,19 @@ Cddb_Load_Track_Album_List (GList *track_list)
 
             row_text[0] = Convert_Duration((gulong)cddbtrackalbum->duration);
 
-            // Load the row in the list
-            gtk_list_store_append(CddbTrackListModel, &iter);
-            gtk_list_store_set(CddbTrackListModel, &iter,
-                               CDDB_TRACK_LIST_NUMBER, cddbtrackalbum->track_number,
-                               CDDB_TRACK_LIST_NAME,   cddbtrackalbum->track_name,
-                               CDDB_TRACK_LIST_TIME,   row_text[0],
-                               CDDB_TRACK_LIST_DATA,   cddbtrackalbum,
-                               CDDB_TRACK_LIST_ETFILE, etfile,
-                               -1);
+            /* Load the row in the list. */
+            gtk_list_store_insert_with_values (CddbTrackListModel, NULL,
+                                               G_MAXINT,
+                                               CDDB_TRACK_LIST_NUMBER,
+                                               cddbtrackalbum->track_number,
+                                               CDDB_TRACK_LIST_NAME,
+                                               cddbtrackalbum->track_name,
+                                               CDDB_TRACK_LIST_TIME,
+                                               row_text[0],
+                                               CDDB_TRACK_LIST_DATA,
+                                               cddbtrackalbum,
+                                               CDDB_TRACK_LIST_ETFILE, etfile,
+                                               -1);
 
             g_free(row_text[0]);
         }
diff --git a/src/log.c b/src/log.c
index 76c94a8..5fede0c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -274,14 +274,12 @@ void Log_Print (Log_Error_Type error_type, gchar const *format, ...)
         }
 
         LogListNbrRows++;
-        gtk_list_store_append(logListModel, &iter);
-        gtk_list_store_set(logListModel, &iter,
-                           LOG_PIXBUF,         Log_Get_Stock_Id_From_Error_Type(error_type),
-                           LOG_TIME_TEXT,      time,
-                           LOG_TEXT,           string,
-                           LOG_ROW_BACKGROUND, NULL,
-                           LOG_ROW_FOREGROUND, NULL,
-                           -1);
+        gtk_list_store_insert_with_values (logListModel, &iter, G_MAXINT,
+                                           LOG_PIXBUF,
+                                           Log_Get_Stock_Id_From_Error_Type (error_type),
+                                           LOG_TIME_TEXT, time, LOG_TEXT,
+                                           string, LOG_ROW_BACKGROUND, NULL,
+                                           LOG_ROW_FOREGROUND, NULL, -1);
         Log_List_Set_Row_Visible(GTK_TREE_MODEL(logListModel), &iter);
         g_free(time);
     }else
@@ -395,14 +393,15 @@ Log_Print_Tmp_List (void)
         if (LogList && logListModel)
         {
             LogListNbrRows++;
-            gtk_list_store_append(logListModel, &iter);
-            gtk_list_store_set(logListModel, &iter,
-                               LOG_PIXBUF, Log_Get_Stock_Id_From_Error_Type (((Log_Data 
*)l->data)->error_type),
-                               LOG_TIME_TEXT, ((Log_Data *)l->data)->time,
-                               LOG_TEXT, ((Log_Data *)l->data)->string,
-                               LOG_ROW_BACKGROUND, NULL,
-                               LOG_ROW_FOREGROUND, NULL,
-                               -1);
+            gtk_list_store_insert_with_values (logListModel, &iter, G_MAXINT,
+                                               LOG_PIXBUF,
+                                               Log_Get_Stock_Id_From_Error_Type (((Log_Data 
*)l->data)->error_type),
+                                               LOG_TIME_TEXT,
+                                               ((Log_Data *)l->data)->time,
+                                               LOG_TEXT,
+                                               ((Log_Data *)l->data)->string,
+                                               LOG_ROW_BACKGROUND, NULL,
+                                               LOG_ROW_FOREGROUND, NULL, -1);
             Log_List_Set_Row_Visible(GTK_TREE_MODEL(logListModel), &iter);
         }
     }
diff --git a/src/misc.c b/src/misc.c
index 4a1860f..2e6829c 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -325,9 +325,9 @@ gboolean Add_String_To_Combo_List (GtkListStore *liststore, const gchar *str)
         } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore), &iter));
     }
 
-    // We add the string to the beginning of the list store
-    gtk_list_store_prepend(liststore, &iter);
-    gtk_list_store_set(liststore, &iter, MISC_COMBO_TEXT, string, -1);
+    /* We add the string to the beginning of the list store. */
+    gtk_list_store_insert_with_values (liststore, &iter, -1, MISC_COMBO_TEXT,
+                                       string, -1);
 
     // Limit list size to HISTORY_MAX_LENGTH
     while (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore),NULL) > HISTORY_MAX_LENGTH)
@@ -468,21 +468,21 @@ gboolean Parse_Date (void)
  */
 void Load_Genres_List_To_UI (void)
 {
-    guint i;
-    GtkTreeIter iter;
+    gsize i;
 
     g_return_if_fail (GenreComboModel != NULL);
 
-    gtk_list_store_append(GTK_LIST_STORE(GenreComboModel), &iter);
-    gtk_list_store_set(GTK_LIST_STORE(GenreComboModel), &iter, MISC_COMBO_TEXT, "", -1);
+    gtk_list_store_insert_with_values (GTK_LIST_STORE (GenreComboModel), NULL,
+                                       G_MAXINT, MISC_COMBO_TEXT, "", -1);
+    gtk_list_store_insert_with_values (GTK_LIST_STORE (GenreComboModel), NULL,
+                                       G_MAXINT, MISC_COMBO_TEXT, "Unknown",
+                                       -1);
 
-    gtk_list_store_append(GTK_LIST_STORE(GenreComboModel), &iter);
-    gtk_list_store_set(GTK_LIST_STORE(GenreComboModel), &iter, MISC_COMBO_TEXT, "Unknown", -1);
-
-    for (i=0; i<=GENRE_MAX; i++)
+    for (i = 0; i <= GENRE_MAX; i++)
     {
-        gtk_list_store_append(GTK_LIST_STORE(GenreComboModel), &iter);
-        gtk_list_store_set(GTK_LIST_STORE(GenreComboModel), &iter, MISC_COMBO_TEXT, id3_genres[i], -1);
+        gtk_list_store_insert_with_values (GTK_LIST_STORE (GenreComboModel),
+                                           NULL, G_MAXINT, MISC_COMBO_TEXT,
+                                           id3_genres[i], -1);
     }
 }
 
@@ -492,33 +492,32 @@ void Load_Genres_List_To_UI (void)
  */
 void Load_Track_List_To_UI (void)
 {
-    guint len;
-    guint i;
-    GtkTreeIter iter;
+    /* Number mini of items
+     *if ((len=ETCore->ETFileDisplayedList_Length) < 30)
+     * Length limited to 30 (instead to the number of files)! */
+    const gsize len = 30;
+    gsize i;
     gchar *text;
 
     g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
                       TrackEntryComboModel != NULL);
 
-    // Number mini of items
-    //if ((len=ETCore->ETFileDisplayedList_Length) < 30)
-    // Length limited to 30 (instead to the number of files)!
-    len = 30;
-
-    // Create list of tracks
-    for (i=1; i<=len; i++)
+    /* Create list of tracks. */
+    for (i = 1; i <= len; i++)
     {
 
         if (NUMBER_TRACK_FORMATED)
         {
-            text = g_strdup_printf("%.*d",NUMBER_TRACK_FORMATED_SPIN_BUTTON,i);
+            text = g_strdup_printf ("%.*" G_GSIZE_FORMAT,
+                                    NUMBER_TRACK_FORMATED_SPIN_BUTTON, i);
         } else
         {
-            text = g_strdup_printf("%.2d",i);
+            text = g_strdup_printf ("%.2" G_GSIZE_FORMAT, i);
         }
 
-        gtk_list_store_append(GTK_LIST_STORE(TrackEntryComboModel), &iter);
-        gtk_list_store_set(GTK_LIST_STORE(TrackEntryComboModel), &iter, MISC_COMBO_TEXT, text, -1);
+        gtk_list_store_insert_with_values (GTK_LIST_STORE (TrackEntryComboModel),
+                                           NULL, G_MAXINT, MISC_COMBO_TEXT,
+                                           text, -1);
         g_free(text);
     }
 
@@ -2446,7 +2445,6 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
     gchar *track, *track_total;
     gboolean case_sensitive;
     gint column;
-    GtkTreeIter iter;
 
     if (!ETFile || !string_to_search)
         return;
@@ -2540,8 +2538,7 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
     }
 
     // Load the row in the list
-    gtk_list_store_append(SearchResultListModel, &iter);
-    gtk_list_store_set(SearchResultListModel, &iter,
+    gtk_list_store_insert_with_values (SearchResultListModel, NULL, G_MAXINT,
                        SEARCH_RESULT_FILENAME,    SearchResultList_Text[SEARCH_RESULT_FILENAME],
                        SEARCH_RESULT_TITLE,       SearchResultList_Text[SEARCH_RESULT_TITLE],
                        SEARCH_RESULT_ARTIST,      SearchResultList_Text[SEARCH_RESULT_ARTIST],
@@ -3087,10 +3084,8 @@ Load_File_Content (GtkWidget *entry)
     gchar buffer[MAX_STRING_LEN];
     gchar *text;
     gchar *valid;
-    GtkTreeIter iter;
 
-    if (!entry)
-        return;
+    g_return_if_fail (entry != NULL);
 
     // The file to read
     filename_utf8 = gtk_entry_get_text(GTK_ENTRY(entry)); // Don't free me!
@@ -3130,10 +3125,9 @@ Load_File_Content (GtkWidget *entry)
         }*/
         valid = Try_To_Validate_Utf8_String(text);
 
-        gtk_list_store_append(LoadFileContentListModel, &iter);
-        gtk_list_store_set(LoadFileContentListModel, &iter,
-                           LOAD_FILE_CONTENT_TEXT, valid,
-                           -1);
+        gtk_list_store_insert_with_values (LoadFileContentListModel, NULL,
+                                           G_MAXINT, LOAD_FILE_CONTENT_TEXT,
+                                           valid, -1);
         g_free(valid);
     }
 
@@ -3157,7 +3151,6 @@ Load_File_List (void)
     ET_File *etfile;
     gchar *filename_utf8;
     gchar *pos;
-    GtkTreeIter iter;
 
     gtk_list_store_clear(LoadFileNameListModel);
 
@@ -3168,11 +3161,11 @@ Load_File_List (void)
         // Remove the extension ('filename' must be allocated to don't affect the initial value)
         if ((pos=strrchr(filename_utf8,'.'))!=NULL)
             *pos = 0;
-        gtk_list_store_append(LoadFileNameListModel, &iter);
-        gtk_list_store_set(LoadFileNameListModel, &iter,
-                           LOAD_FILE_NAME_TEXT, filename_utf8,
-                           LOAD_FILE_NAME_POINTER, l->data,
-                           -1);
+        gtk_list_store_insert_with_values (LoadFileNameListModel, NULL,
+                                           G_MAXINT, LOAD_FILE_NAME_TEXT,
+                                           filename_utf8,
+                                           LOAD_FILE_NAME_POINTER, l->data,
+                                           -1);
         g_free(filename_utf8);
     }
 }
diff --git a/src/picture.c b/src/picture.c
index 103f012..91cfee7 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -500,15 +500,16 @@ void Picture_Properties_Button_Clicked (GObject *object)
         {
             case MP4_TAG:
             {
-                // Load picture type (only Front Cover!)
+                /* Load picture type (only Front Cover!). */
                 GtkTreeIter itertype;
 
-                gtk_list_store_append(store, &itertype);
-                gtk_list_store_set(store, &itertype,
-                                   PICTURE_TYPE_COLUMN_TEXT, 
_(Picture_Type_String(ET_PICTURE_TYPE_FRONT_COVER)),
-                                   PICTURE_TYPE_COLUMN_TYPE_CODE, ET_PICTURE_TYPE_FRONT_COVER,
-                                   -1);
-                // Line to select by default
+                gtk_list_store_insert_with_values (store, &itertype, G_MAXINT,
+                                                   PICTURE_TYPE_COLUMN_TEXT,
+                                                   _(Picture_Type_String (ET_PICTURE_TYPE_FRONT_COVER)),
+                                                   PICTURE_TYPE_COLUMN_TYPE_CODE,
+                                                   ET_PICTURE_TYPE_FRONT_COVER,
+                                                   -1);
+                /* Line to select by default. */
                 type_iter_to_select = itertype;
                 break;
             }
@@ -521,12 +522,13 @@ void Picture_Properties_Button_Clicked (GObject *object)
                 {
                     GtkTreeIter itertype;
 
-                    gtk_list_store_append(store, &itertype);
-                    gtk_list_store_set(store, &itertype,
-                                       PICTURE_TYPE_COLUMN_TEXT,      _(Picture_Type_String(pic_type)),
-                                       PICTURE_TYPE_COLUMN_TYPE_CODE, pic_type,
-                                       -1);
-                    // Line to select by default
+                    gtk_list_store_insert_with_values (store, &itertype,
+                                                       G_MAXINT,
+                                                       PICTURE_TYPE_COLUMN_TEXT,
+                                                       _(Picture_Type_String (pic_type)),
+                                                       PICTURE_TYPE_COLUMN_TYPE_CODE,
+                                                       pic_type, -1);
+                    /* Line to select by default. */
                     if (pic->type == pic_type)
                         type_iter_to_select = itertype;
                 }
@@ -998,13 +1000,15 @@ void PictureEntry_Update (Picture *pic, gboolean select_it)
                 g_object_unref(pixbuf);
 
                 picture_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(PictureEntryView)));
-                gtk_list_store_append(picture_store, &iter1);
                 pic_info = Picture_Info(pic);
-                gtk_list_store_set(picture_store, &iter1,
-                                   PICTURE_COLUMN_PIC,  scaled_pixbuf,
-                                   PICTURE_COLUMN_TEXT, pic_info,
-                                   PICTURE_COLUMN_DATA, Picture_Copy_One(pic),
-                                   -1);
+                gtk_list_store_insert_with_values (picture_store, &iter1,
+                                                   G_MAXINT,
+                                                   PICTURE_COLUMN_PIC,
+                                                   scaled_pixbuf,
+                                                   PICTURE_COLUMN_TEXT,
+                                                   pic_info,
+                                                   PICTURE_COLUMN_DATA,
+                                                   Picture_Copy_One (pic), -1);
                 g_free(pic_info);
 
                 if (select_it)
diff --git a/src/scan.c b/src/scan.c
index 9de61f7..29a59ea 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -3641,7 +3641,6 @@ static void
 Mask_Editor_List_Add (void)
 {
     gint i = 0;
-    GtkTreeIter iter;
     GtkTreeModel *treemodel;
     gchar *temp;
 
@@ -3657,9 +3656,9 @@ Mask_Editor_List_Add (void)
                 temp = g_strdup(Scan_Masks[i]);*/
             temp = Try_To_Validate_Utf8_String(Scan_Masks[i]);
 
-            gtk_list_store_append(GTK_LIST_STORE(treemodel), &iter);
-            gtk_list_store_set(GTK_LIST_STORE(treemodel), &iter,
-                               MASK_EDITOR_TEXT, temp, -1);
+            gtk_list_store_insert_with_values (GTK_LIST_STORE (treemodel),
+                                               NULL, G_MAXINT,
+                                               MASK_EDITOR_TEXT, temp, -1);
             g_free(temp);
             i++;
         }
@@ -3673,9 +3672,9 @@ Mask_Editor_List_Add (void)
                 temp = g_strdup(Rename_File_Masks[i]);*/
             temp = Try_To_Validate_Utf8_String(Rename_File_Masks[i]);
 
-            gtk_list_store_append(GTK_LIST_STORE(treemodel), &iter);
-            gtk_list_store_set(GTK_LIST_STORE(treemodel), &iter,
-                               MASK_EDITOR_TEXT, temp, -1);
+            gtk_list_store_insert_with_values (GTK_LIST_STORE (treemodel),
+                                               NULL, G_MAXINT,
+                                               MASK_EDITOR_TEXT, temp, -1);
             g_free(temp);
             i++;
         }
diff --git a/src/setting.c b/src/setting.c
index dac046d..503bcdd 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -1227,7 +1227,6 @@ Populate_List_Store_From_File (const gchar *filename, GtkListStore *liststore, g
     gchar *file_path = NULL;
     FILE *file;
     gchar buffer[MAX_STRING_LEN];
-    GtkTreeIter iter;
     gboolean entries_set = FALSE;
 
     /* The file to write */
@@ -1257,8 +1256,8 @@ Populate_List_Store_From_File (const gchar *filename, GtkListStore *liststore, g
 
             if (data && g_utf8_strlen(data, -1) > 0)
             {
-                gtk_list_store_append(liststore, &iter);
-                gtk_list_store_set(liststore, &iter, text_column, data, -1);
+                gtk_list_store_insert_with_values (liststore, NULL, G_MAXINT,
+                                                   text_column, data, -1);
                 entries_set = TRUE;
             }
             g_free(data);
@@ -1335,7 +1334,6 @@ void Save_Rename_File_Masks_List (GtkListStore *liststore, gint colnum)
 void Load_Rename_Directory_Masks_List (GtkListStore *liststore, gint colnum, gchar **fallback)
 {
     gint i = 0;
-    GtkTreeIter iter;
 
     if (!Populate_List_Store_From_File(RENAME_DIRECTORY_MASKS_FILE, liststore, colnum))
     {
@@ -1344,8 +1342,8 @@ void Load_Rename_Directory_Masks_List (GtkListStore *liststore, gint colnum, gch
 
         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, NULL, G_MAXINT,
+                                               colnum, fallback[i], -1);
             i++;
         }
     }


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