commit acb4ca013d66069b53e4bac86c52e2d5480417e7
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Wed May 9 22:29:04 2012 +0100

    Improve performance of playlist selection
    
    * For playlists / ipods with many tracks, playlist selection can be very
      slow. Turns out this is due to excessive track display signals being
      fired while tracks are added.
    
    * Use gtk_list_store_insert_with_values since this triggers fewer signals
      than the gtk_list_store_append/gtk_list_store_set couplet
    
    * Turn off sorting then turn back on afterwards since sorting makes adding
      very slow!

 plugins/track_display/display_tracks.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/plugins/track_display/display_tracks.c 
b/plugins/track_display/display_tracks.c
index da57139..f98f723 100644
--- a/plugins/track_display/display_tracks.c
+++ b/plugins/track_display/display_tracks.c
@@ -2376,15 +2376,28 @@ gboolean tm_add_filelist(gchar *data, GtkTreePath 
*path, GtkTreeViewDropPosition
 
 void track_display_set_tracks_cb(GtkPodApp *app, gpointer tks, gpointer data) {
     GList *tracks = tks;
+    GtkTreeModel *model = NULL;
+
 
     tm_remove_all_tracks();
 
+    // Unsort the track view to improve performance
+    model = gtk_tree_view_get_model(track_treeview);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (model), 
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
+
     while (tracks != NULL) { /* add all tracks to model */
         Track *track = tracks->data;
-        tm_add_track_to_track_model(track, NULL);
+        gtk_list_store_insert_with_values (get_model_as_store(model), NULL, 
-1, READOUT_COL, track, -1);
         tracks = tracks->next;
     }
 
+    if (model) {
+        int column = prefs_get_int("tm_sortcol");
+        int order = prefs_get_int("tm_sort");
+        if (order != SORT_NONE) {
+            gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (model), 
column, order);
+        }
+    }
 }
 
 void track_display_set_playlist_cb(GtkPodApp *app, gpointer pl, gpointer data) 
{

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to