ocarina: Freeze and thaw the liststore while filling
This causes fewer refreshes of the liststore and speeds up filling it in.
This commit is contained in:
parent
284176fb5c
commit
ce2f9f02f8
|
@ -85,6 +85,18 @@ GtkWidget *SongList::get_label()
|
|||
return label;
|
||||
}
|
||||
|
||||
void SongList::freeze()
|
||||
{
|
||||
gtk_widget_freeze_child_notify(treeview);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), NULL);
|
||||
}
|
||||
|
||||
void SongList::thaw()
|
||||
{
|
||||
gtk_widget_thaw_child_notify(treeview);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));
|
||||
}
|
||||
|
||||
void SongList::clear()
|
||||
{
|
||||
gtk_list_store_clear(liststore);
|
||||
|
@ -96,6 +108,7 @@ void SongList::insert(list<Track> &track_list)
|
|||
Track *track;
|
||||
list<Track>::iterator it;
|
||||
|
||||
freeze();
|
||||
for (it = track_list.begin(); it != track_list.end(); it++) {
|
||||
track = &(*it);
|
||||
gtk_list_store_insert_with_values(liststore, NULL, ins_next,
|
||||
|
@ -109,4 +122,5 @@ void SongList::insert(list<Track> &track_list)
|
|||
-1);
|
||||
ins_next++;
|
||||
}
|
||||
thaw();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ class SongList
|
|||
GtkCellRenderer *text_cell;
|
||||
|
||||
void add_column(unsigned int);
|
||||
void freeze();
|
||||
void thaw();
|
||||
|
||||
public:
|
||||
SongList();
|
||||
|
|
Loading…
Reference in New Issue