[rhythmbox] rhythmdb: emit entry-changes with a GPtrArray rather than a GArray
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] rhythmdb: emit entry-changes with a GPtrArray rather than a GArray
- Date: Thu, 4 Jul 2013 22:26:35 +0000 (UTC)
commit dd1420790dfcb91af3dfc8211aabf11ae06f4727
Author: Jonathan Matthew <jonathan d14n org>
Date: Fri Jul 5 08:22:36 2013 +1000
rhythmdb: emit entry-changes with a GPtrArray rather than a GArray
This is slightly more efficient (no copies) and it's also easier
for pygobject to chew on.
https://bugzilla.gnome.org/show_bug.cgi?id=701307
plugins/ipod/rb-ipod-source.c | 5 ++---
plugins/mpris/rb-mpris-plugin.c | 4 ++--
plugins/visualizer/rb-visualizer-fullscreen.c | 5 ++---
podcast/rb-podcast-source.c | 5 ++---
rhythmdb/rhythmdb-query-model.c | 7 +++----
rhythmdb/rhythmdb.c | 18 +++++++-----------
shell/rb-shell-player.c | 7 +++----
7 files changed, 21 insertions(+), 30 deletions(-)
---
diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index 974f05c..bce4439 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -1140,7 +1140,7 @@ send_offline_plays_notification (RBiPodSource *source)
static void
rb_ipod_source_entry_changed_cb (RhythmDB *db,
RhythmDBEntry *entry,
- GArray *changes,
+ GPtrArray *changes,
RBiPodSource *source)
{
int i;
@@ -1166,8 +1166,7 @@ rb_ipod_source_entry_changed_cb (RhythmDB *db,
* I don't think avoiding it is worth the effort.
*/
for (i = 0; i < changes->len; i++) {
- GValue *v = &g_array_index (changes, GValue, i);
- RhythmDBEntryChange *change = g_value_get_boxed (v);
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
switch (change->prop) {
case RHYTHMDB_PROP_RATING: {
Itdb_Track *track;
diff --git a/plugins/mpris/rb-mpris-plugin.c b/plugins/mpris/rb-mpris-plugin.c
index 840f1f7..0d7fb53 100644
--- a/plugins/mpris/rb-mpris-plugin.c
+++ b/plugins/mpris/rb-mpris-plugin.c
@@ -1240,7 +1240,7 @@ art_added_cb (RBExtDB *store, RBExtDBKey *key, const char *filename, GValue *dat
}
static void
-entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, RBMprisPlugin *plugin)
+entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GPtrArray *changes, RBMprisPlugin *plugin)
{
RhythmDBEntry *playing_entry = rb_shell_player_get_playing_entry (plugin->player);
if (playing_entry == NULL) {
@@ -1252,7 +1252,7 @@ entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, RBMprisPl
/* make sure there's an interesting property change in there */
for (i = 0; i < changes->len; i++) {
- RhythmDBEntryChange *change = g_value_get_boxed (&g_array_index (changes, GValue, i));
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
switch (change->prop) {
/* probably not complete */
case RHYTHMDB_PROP_MOUNTPOINT:
diff --git a/plugins/visualizer/rb-visualizer-fullscreen.c b/plugins/visualizer/rb-visualizer-fullscreen.c
index 1753fba..1443961 100644
--- a/plugins/visualizer/rb-visualizer-fullscreen.c
+++ b/plugins/visualizer/rb-visualizer-fullscreen.c
@@ -263,14 +263,13 @@ playing_song_changed_cb (RBShellPlayer *player, RhythmDBEntry *entry, ClutterAct
}
static void
-entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, ClutterActor *label)
+entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GPtrArray *changes, ClutterActor *label)
{
int i;
/* somehow check entry == playing entry */
for (i = 0; i < changes->len; i++) {
- GValue *v = &g_array_index (changes, GValue, i);
- RhythmDBEntryChange *change = g_value_get_boxed (v);
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
switch (change->prop) {
case RHYTHMDB_PROP_TITLE:
case RHYTHMDB_PROP_ARTIST:
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index 52c2513..a21a4a9 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -907,7 +907,7 @@ episode_activated_cb (RBEntryView *view,
static void
podcast_entry_changed_cb (RhythmDB *db,
RhythmDBEntry *entry,
- GArray *changes,
+ GPtrArray *changes,
RBPodcastSource *source)
{
RhythmDBEntryType *entry_type;
@@ -920,8 +920,7 @@ podcast_entry_changed_cb (RhythmDB *db,
feed_changed = FALSE;
for (i = 0; i < changes->len; i++) {
- GValue *v = &g_array_index (changes, GValue, i);
- RhythmDBEntryChange *change = g_value_get_boxed (v);
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
switch (change->prop) {
case RHYTHMDB_PROP_PLAYBACK_ERROR:
diff --git a/rhythmdb/rhythmdb-query-model.c b/rhythmdb/rhythmdb-query-model.c
index 19f5f27..1e5f56e 100644
--- a/rhythmdb/rhythmdb-query-model.c
+++ b/rhythmdb/rhythmdb-query-model.c
@@ -82,7 +82,7 @@ static void rhythmdb_query_model_do_insert (RhythmDBQueryModel *model,
static void rhythmdb_query_model_entry_added_cb (RhythmDB *db, RhythmDBEntry *entry,
RhythmDBQueryModel *model);
static void rhythmdb_query_model_entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry,
- GArray *changes, RhythmDBQueryModel *model);
+ GPtrArray *changes, RhythmDBQueryModel *model);
static void rhythmdb_query_model_entry_deleted_cb (RhythmDB *db, RhythmDBEntry *entry,
RhythmDBQueryModel *model);
@@ -1018,7 +1018,7 @@ rhythmdb_query_model_entry_added_cb (RhythmDB *db,
static void
rhythmdb_query_model_entry_changed_cb (RhythmDB *db,
RhythmDBEntry *entry,
- GArray *changes,
+ GPtrArray *changes,
RhythmDBQueryModel *model)
{
gboolean hidden = FALSE;
@@ -1091,8 +1091,7 @@ rhythmdb_query_model_entry_changed_cb (RhythmDB *db,
* case we propagate the parent model's signals instead.
*/
for (i = 0; i < changes->len; i++) {
- GValue *v = &g_array_index (changes, GValue, i);
- RhythmDBEntryChange *change = g_value_get_boxed (v);
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
if (model->priv->base_model == NULL) {
g_signal_emit (G_OBJECT (model),
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index 10cc3a0..b67ddc1 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -406,20 +406,20 @@ rhythmdb_class_init (RhythmDBClass *klass)
* RhythmDB::entry-changed:
* @db: the #RhythmDB
* @entry: the changed #RhythmDBEntry
- * @changes: (element-type RB.RhythmDBEntryChange): a #GArray of #RhythmDBEntryChange structures
describing the changes
+ * @changes: (element-type RB.RhythmDBEntryChange): a #GPtrArray of #RhythmDBEntryChange structures
describing the changes
*
* Emitted when a database entry is modified. The @changes list
* contains a structure for each entry property that has been modified.
*/
rhythmdb_signals[ENTRY_CHANGED] =
- g_signal_new ("entry_changed",
+ g_signal_new ("entry-changed",
RHYTHMDB_TYPE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (RhythmDBClass, entry_changed),
NULL, NULL,
rb_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE, 2,
- RHYTHMDB_TYPE_ENTRY, G_TYPE_ARRAY);
+ RHYTHMDB_TYPE_ENTRY, G_TYPE_PTR_ARRAY);
/**
* RhythmDB::entry-keyword-added:
@@ -1331,19 +1331,15 @@ rhythmdb_emit_entry_signals_idle (RhythmDB *db)
if (changed_entries != NULL) {
g_hash_table_iter_init (&iter, changed_entries);
while (g_hash_table_iter_next (&iter, (gpointer *)&entry, (gpointer *)&entry_changes)) {
- GArray *emit_changes;
+ GPtrArray *emit_changes;
GSList *c;
- emit_changes = g_array_sized_new (FALSE, TRUE, sizeof (GValue), g_slist_length
(entry_changes));
- g_array_set_clear_func (emit_changes, (GDestroyNotify) g_value_unset);
+ emit_changes = g_ptr_array_new_full (g_slist_length (entry_changes), NULL);
for (c = entry_changes; c != NULL; c = c->next) {
- GValue v = {0,};
- g_value_init (&v, RHYTHMDB_TYPE_ENTRY_CHANGE);
- g_value_take_boxed (&v, c->data);
- g_array_append_val (emit_changes, v);
+ g_ptr_array_add (emit_changes, c->data);
}
g_signal_emit (G_OBJECT (db), rhythmdb_signals[ENTRY_CHANGED], 0, entry,
emit_changes);
- g_array_unref (emit_changes);
+ g_ptr_array_unref (emit_changes);
g_hash_table_iter_remove (&iter);
}
}
diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c
index 5bd9b0f..459dde2 100644
--- a/shell/rb-shell-player.c
+++ b/shell/rb-shell-player.c
@@ -119,7 +119,7 @@ static void rb_shell_player_sync_with_source (RBShellPlayer *player);
static void rb_shell_player_sync_with_selected_source (RBShellPlayer *player);
static void rb_shell_player_entry_changed_cb (RhythmDB *db,
RhythmDBEntry *entry,
- GArray *changes,
+ GPtrArray *changes,
RBShellPlayer *player);
static void rb_shell_player_entry_activated_cb (RBEntryView *view,
@@ -1810,7 +1810,7 @@ rb_shell_player_property_row_activated_cb (RBPropertyView *view,
static void
rb_shell_player_entry_changed_cb (RhythmDB *db,
RhythmDBEntry *entry,
- GArray *changes,
+ GPtrArray *changes,
RBShellPlayer *player)
{
gboolean synced = FALSE;
@@ -1830,8 +1830,7 @@ rb_shell_player_entry_changed_cb (RhythmDB *db,
location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
for (i = 0; i < changes->len; i++) {
- GValue *v = &g_array_index (changes, GValue, i);
- RhythmDBEntryChange *change = g_value_get_boxed (v);
+ RhythmDBEntryChange *change = g_ptr_array_index (changes, i);
/* update UI if the artist, title or album has changed */
switch (change->prop) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]