[rhythmbox] shuffle: improve handling of query model changes
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] shuffle: improve handling of query model changes
- Date: Sat, 14 Mar 2015 12:43:00 +0000 (UTC)
commit 6a2f69052e3602bb8a5c10deab1ac24ad42fbc81
Author: Jonathan Matthew <jonathan d14n org>
Date: Sat Mar 14 22:38:56 2015 +1000
shuffle: improve handling of query model changes
Ensure all entries are removed from the ordering, then all the
entries in the new query model are added randomly, rather than leaving
the ones common to both query models in place. This distributes the
common entries better throughout the resulting play order.
Based on a patch from charboma38 gmail com
https://bugzilla.gnome.org/show_bug.cgi?id=330686
shell/rb-play-order-shuffle.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/shell/rb-play-order-shuffle.c b/shell/rb-play-order-shuffle.c
index 3635797..42de0e8 100644
--- a/shell/rb-play-order-shuffle.c
+++ b/shell/rb-play-order-shuffle.c
@@ -308,6 +308,7 @@ static void
handle_query_model_changed (RBShufflePlayOrder *sorder)
{
GPtrArray *history;
+ RhythmDBEntry *entry;
RhythmDBQueryModel *model;
GtkTreeIter iter;
int i;
@@ -321,17 +322,18 @@ handle_query_model_changed (RBShufflePlayOrder *sorder)
/* This simulates removing every entry in the old query model
* and then adding every entry in the new one. */
history = rb_history_dump (sorder->priv->history);
- for (i=0; i < history->len; ++i)
- rb_shuffle_entry_removed (RB_PLAY_ORDER (sorder), g_ptr_array_index (history, i));
+ for (i=0; i < history->len; ++i) {
+ entry = g_ptr_array_index (history, i);
+ g_hash_table_insert (sorder->priv->entries_removed, rhythmdb_entry_ref (entry), entry);
+ }
g_ptr_array_free (history, TRUE);
model = rb_play_order_get_query_model (RB_PLAY_ORDER (sorder));
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
do {
- RhythmDBEntry *entry;
entry = rhythmdb_query_model_iter_to_entry (model, &iter);
- rb_shuffle_entry_added (RB_PLAY_ORDER (sorder), entry);
- rhythmdb_entry_unref (entry);
+ /* hash table takes the reference we got from the query model */
+ g_hash_table_insert (sorder->priv->entries_added, entry, entry);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]