diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c index ff42f0a1d..d0c0beb78 100644 --- a/backends/gstreamer/rb-player-gst-xfade.c +++ b/backends/gstreamer/rb-player-gst-xfade.c @@ -680,7 +680,7 @@ rb_player_gst_xfade_class_init (RBPlayerGstXFadeClass *klass) 0, rb_signal_accumulator_value_array, NULL, rb_marshal_BOXED__STRING, - G_TYPE_VALUE_ARRAY, + G_TYPE_ARRAY, 1, G_TYPE_STRING); @@ -2082,7 +2082,7 @@ create_stream (RBPlayerGstXFade *player, const char *uri, gpointer stream_data, { RBXFadeStream *stream; GstCaps *caps; - GValueArray *stream_filters = NULL; + GArray *stream_filters = NULL; GstElement *tail; GstController *controller; int i; @@ -2247,8 +2247,8 @@ create_stream (RBPlayerGstXFade *player, const char *uri, gpointer stream_data, g_signal_emit (player, signals[GET_STREAM_FILTERS], 0, uri, &stream_filters); if (stream_filters != NULL) { int i; - for (i = 0; i < stream_filters->n_values; i++) { - GValue *v = g_value_array_get_nth (stream_filters, i); + for (i = 0; i < stream_filters->len; i++) { + GValue *v = &g_array_index (stream_filters, GValue, i); GstElement *filter; GstElement *audioconvert; @@ -2260,7 +2260,7 @@ create_stream (RBPlayerGstXFade *player, const char *uri, gpointer stream_data, tail = filter; } - g_value_array_free (stream_filters); + g_array_unref (stream_filters); } gst_element_link (tail, stream->audioconvert); diff --git a/lib/rb-util.c b/lib/rb-util.c index d08c81981..f934139a4 100644 --- a/lib/rb-util.c +++ b/lib/rb-util.c @@ -1089,7 +1089,7 @@ rb_signal_accumulator_value_handled (GSignalInvocationHint *hint, * @dummy: user data (unused) * * A #GSignalAccumulator used to combine all returned values into - * a #GValueArray. + * a #GArray of #GValue instances. * * Return value: %FALSE to abort signal emission, %TRUE to continue */ @@ -1099,35 +1099,31 @@ rb_signal_accumulator_value_array (GSignalInvocationHint *hint, const GValue *handler_return, gpointer dummy) { - GValueArray *a; - GValueArray *b; + GArray *a; + GArray *b; int i; if (handler_return == NULL) return TRUE; - a = NULL; + a = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 1); + g_array_set_clear_func (a, (GDestroyNotify) g_value_unset); if (G_VALUE_HOLDS_BOXED (return_accu)) { - a = g_value_get_boxed (return_accu); - if (a != NULL) { - a = g_value_array_copy (a); + b = g_value_get_boxed (return_accu); + if (b != NULL) { + g_array_append_vals (a, b->data, b->len); } } - if (a == NULL) { - a = g_value_array_new (1); - } - if (G_VALUE_HOLDS_BOXED (handler_return)) { b = g_value_get_boxed (handler_return); - for (i=0; i < b->n_values; i++) { - GValue *z = g_value_array_get_nth (b, i); - a = g_value_array_append (a, z); + for (i=0; i < b->len; i++) { + a = g_array_append_val (a, g_array_index (b, GValue, i)); } } g_value_unset (return_accu); - g_value_init (return_accu, G_TYPE_VALUE_ARRAY); + g_value_init (return_accu, G_TYPE_ARRAY); g_value_set_boxed (return_accu, a); return TRUE; } @@ -1164,14 +1160,14 @@ rb_signal_accumulator_boolean_or (GSignalInvocationHint *hint, /** * rb_value_array_append_data: (skip): - * @array: #GValueArray to append to + * @array: #GArray to append to * @type: #GType of the value being appended * @Varargs: value to append * * Appends a single value to @array, collecting it from @Varargs. */ void -rb_value_array_append_data (GValueArray *array, GType type, ...) +rb_value_array_append_data (GArray *array, GType type, ...) { GValue val = {0,}; va_list va; @@ -1181,7 +1177,7 @@ rb_value_array_append_data (GValueArray *array, GType type, ...) g_value_init (&val, type); G_VALUE_COLLECT (&val, va, 0, &err); - g_value_array_append (array, &val); + g_array_append_val (array, val); g_value_unset (&val); if (err) diff --git a/lib/rb-util.h b/lib/rb-util.h index 4b9024db5..2225e6424 100644 --- a/lib/rb-util.h +++ b/lib/rb-util.h @@ -97,7 +97,7 @@ gboolean rb_signal_accumulator_value_array (GSignalInvocationHint *hint, GValue *return_accu, const GValue *handler_return, gpointer dummy); -void rb_value_array_append_data (GValueArray *array, GType type, ...); +void rb_value_array_append_data (GArray *array, GType type, ...); void rb_value_free (GValue *val); /* g_value_unset, g_slice_free */ void rb_assert_locked (GMutex *mutex); diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c index 73baca9ea..40bc7acc1 100644 --- a/plugins/ipod/rb-ipod-source.c +++ b/plugins/ipod/rb-ipod-source.c @@ -1050,7 +1050,7 @@ send_offline_plays_notification (RBiPodSource *source) static void rb_ipod_source_entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, - GValueArray *changes, + GArray *changes, RBiPodSource *source) { int i; @@ -1075,8 +1075,8 @@ rb_ipod_source_entry_changed_cb (RhythmDB *db, * that's the worst that can happen and that's pretty theoretical, * I don't think avoiding it is worth the effort. */ - for (i = 0; i < changes->n_values; i++) { - GValue *v = g_value_array_get_nth (changes, i); + for (i = 0; i < changes->len; i++) { + GValue *v = &g_array_index (changes, GValue, i); RhythmDBEntryChange *change = g_value_get_boxed (v); switch (change->prop) { case RHYTHMDB_PROP_RATING: { diff --git a/plugins/mpris/rb-mpris-plugin.c b/plugins/mpris/rb-mpris-plugin.c index 996186f4e..3cd0afd23 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, GValueArray *changes, RBMprisPlugin *plugin) +entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, RBMprisPlugin *plugin) { RhythmDBEntry *playing_entry = rb_shell_player_get_playing_entry (plugin->player); if (playing_entry == NULL) { @@ -1251,8 +1251,8 @@ entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GValueArray *changes, RBMp gboolean emit = FALSE; /* make sure there's an interesting property change in there */ - for (i = 0; i < changes->n_values; i++) { - RhythmDBEntryChange *change = g_value_get_boxed (g_value_array_get_nth (changes, i)); + for (i = 0; i < changes->len; i++) { + RhythmDBEntryChange *change = g_value_get_boxed (&g_array_index (changes, GValue, 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 99f2ef311..1753fba47 100644 --- a/plugins/visualizer/rb-visualizer-fullscreen.c +++ b/plugins/visualizer/rb-visualizer-fullscreen.c @@ -263,13 +263,13 @@ playing_song_changed_cb (RBShellPlayer *player, RhythmDBEntry *entry, ClutterAct } static void -entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GValueArray *changes, ClutterActor *label) +entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, ClutterActor *label) { int i; /* somehow check entry == playing entry */ - for (i = 0; i < changes->n_values; i++) { - GValue *v = g_value_array_get_nth (changes, i); + for (i = 0; i < changes->len; i++) { + GValue *v = &g_array_index (changes, GValue, i); RhythmDBEntryChange *change = g_value_get_boxed (v); switch (change->prop) { case RHYTHMDB_PROP_TITLE: diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c index 179660ced..6ddabaec7 100644 --- a/podcast/rb-podcast-source.c +++ b/podcast/rb-podcast-source.c @@ -897,7 +897,7 @@ episode_activated_cb (RBEntryView *view, static void podcast_entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, - GValueArray *changes, + GArray *changes, RBPodcastSource *source) { RhythmDBEntryType *entry_type; @@ -909,8 +909,8 @@ podcast_entry_changed_cb (RhythmDB *db, return; feed_changed = FALSE; - for (i = 0; i < changes->n_values; i++) { - GValue *v = g_value_array_get_nth (changes, i); + for (i = 0; i < changes->len; i++) { + GValue *v = &g_array_index (changes, GValue, i); RhythmDBEntryChange *change = g_value_get_boxed (v); if (change->prop == RHYTHMDB_PROP_PLAYBACK_ERROR) { diff --git a/rhythmdb/rhythmdb-query-model.c b/rhythmdb/rhythmdb-query-model.c index ba77ed050..4786c3fde 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, - GValueArray *changes, RhythmDBQueryModel *model); + GArray *changes, RhythmDBQueryModel *model); static void rhythmdb_query_model_entry_deleted_cb (RhythmDB *db, RhythmDBEntry *entry, RhythmDBQueryModel *model); @@ -224,7 +224,7 @@ struct _RhythmDBQueryModelPrivate guint stamp; RhythmDBQueryModelLimitType limit_type; - GValueArray *limit_value; + GArray *limit_value; glong total_duration; guint64 total_size; @@ -374,7 +374,7 @@ rhythmdb_query_model_class_init (RhythmDBQueryModelClass *klass) g_param_spec_boxed ("limit-value", "limit-value", "value of limit", - G_TYPE_VALUE_ARRAY, + G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_SHOW_HIDDEN, @@ -605,8 +605,8 @@ rhythmdb_query_model_set_property (GObject *object, break; case PROP_LIMIT_VALUE: if (model->priv->limit_value) - g_value_array_free (model->priv->limit_value); - model->priv->limit_value = (GValueArray*)g_value_dup_boxed (value); + g_array_unref (model->priv->limit_value); + model->priv->limit_value = (GArray*)g_value_dup_boxed (value); break; case PROP_SHOW_HIDDEN: model->priv->show_hidden = g_value_get_boolean (value); @@ -794,7 +794,7 @@ rhythmdb_query_model_finalize (GObject *object) model->priv->sort_data_destroy (model->priv->sort_data); if (model->priv->limit_value) - g_value_array_free (model->priv->limit_value); + g_array_unref (model->priv->limit_value); G_OBJECT_CLASS (rhythmdb_query_model_parent_class)->finalize (object); } @@ -1017,7 +1017,7 @@ rhythmdb_query_model_entry_added_cb (RhythmDB *db, static void rhythmdb_query_model_entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, - GValueArray *changes, + GArray *changes, RhythmDBQueryModel *model) { gboolean hidden = FALSE; @@ -1089,8 +1089,8 @@ rhythmdb_query_model_entry_changed_cb (RhythmDB *db, * unless this is a chained query model, in which * case we propagate the parent model's signals instead. */ - for (i = 0; i < changes->n_values; i++) { - GValue *v = g_value_array_get_nth (changes, i); + for (i = 0; i < changes->len; i++) { + GValue *v = &g_array_index (changes, GValue, i); RhythmDBEntryChange *change = g_value_get_boxed (v); if (model->priv->base_model == NULL) { @@ -3275,7 +3275,7 @@ rhythmdb_query_model_within_limit (RhythmDBQueryModel *model, gulong limit_count; gulong current_count; - limit_count = g_value_get_ulong (g_value_array_get_nth (model->priv->limit_value, 0)); + limit_count = g_value_get_ulong (&g_array_index (model->priv->limit_value, GValue, 0)); current_count = g_hash_table_size (model->priv->reverse_map); if (entry) @@ -3290,7 +3290,7 @@ rhythmdb_query_model_within_limit (RhythmDBQueryModel *model, guint64 limit_size; guint64 current_size; - limit_size = g_value_get_uint64 (g_value_array_get_nth (model->priv->limit_value, 0)); + limit_size = g_value_get_uint64 (&g_array_index (model->priv->limit_value, GValue, 0)); current_size = model->priv->total_size; if (entry) @@ -3306,7 +3306,7 @@ rhythmdb_query_model_within_limit (RhythmDBQueryModel *model, gulong limit_time; gulong current_time; - limit_time = g_value_get_ulong (g_value_array_get_nth (model->priv->limit_value, 0)); + limit_time = g_value_get_ulong (&g_array_index (model->priv->limit_value, GValue, 0)); current_time = model->priv->total_duration; if (entry) diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c index 99253cb80..d83671f0d 100644 --- a/rhythmdb/rhythmdb.c +++ b/rhythmdb/rhythmdb.c @@ -399,7 +399,7 @@ rhythmdb_class_init (RhythmDBClass *klass) * RhythmDB::entry-changed: * @db: the #RhythmDB * @entry: the changed #RhythmDBEntry - * @changes: a #GValueArray of #RhythmDBEntryChange structures describing the changes + * @changes: a #GArray 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. @@ -412,7 +412,7 @@ rhythmdb_class_init (RhythmDBClass *klass) NULL, NULL, rb_marshal_VOID__BOXED_BOXED, G_TYPE_NONE, 2, - RHYTHMDB_TYPE_ENTRY, G_TYPE_VALUE_ARRAY); + RHYTHMDB_TYPE_ENTRY, G_TYPE_ARRAY); /** * RhythmDB::entry-keyword-added: @@ -1336,19 +1336,19 @@ 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)) { - GValueArray *emit_changes; + GArray *emit_changes; GSList *c; - emit_changes = g_value_array_new (g_slist_length (entry_changes)); + 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); 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_value_array_append (emit_changes, &v); - g_value_unset (&v); + g_array_append_val (emit_changes, v); } g_signal_emit (G_OBJECT (db), rhythmdb_signals[ENTRY_CHANGED], 0, entry, emit_changes); - g_value_array_free (emit_changes); + g_array_unref (emit_changes); g_hash_table_iter_remove (&iter); } } diff --git a/rhythmdb/rhythmdb.h b/rhythmdb/rhythmdb.h index 8efc8e9db..c92060e91 100644 --- a/rhythmdb/rhythmdb.h +++ b/rhythmdb/rhythmdb.h @@ -241,7 +241,7 @@ struct _RhythmDBClass /* signals */ void (*entry_added) (RhythmDB *db, RhythmDBEntry *entry); - void (*entry_changed) (RhythmDB *db, RhythmDBEntry *entry, GValueArray *changes); /* array of RhythmDBEntryChanges */ + void (*entry_changed) (RhythmDB *db, RhythmDBEntry *entry, GArray *changes); /* array of RhythmDBEntryChanges */ void (*entry_deleted) (RhythmDB *db, RhythmDBEntry *entry); void (*entry_keyword_added) (RhythmDB *db, RhythmDBEntry *entry, RBRefString *keyword); void (*entry_keyword_removed)(RhythmDB *db, RhythmDBEntry *entry, RBRefString *keyword); diff --git a/shell/rb-playlist-manager.c b/shell/rb-playlist-manager.c index 73ce944bc..5b3cad790 100644 --- a/shell/rb-playlist-manager.c +++ b/shell/rb-playlist-manager.c @@ -845,7 +845,7 @@ rb_playlist_manager_set_automatic_playlist (RBPlaylistManager *mgr, RBQueryCreator *creator) { RhythmDBQueryModelLimitType limit_type; - GValueArray *limit_value = NULL; + GArray *limit_value = NULL; const char *sort_key; gint sort_direction; GPtrArray *query; @@ -863,6 +863,9 @@ rb_playlist_manager_set_automatic_playlist (RBPlaylistManager *mgr, sort_key, sort_direction); rhythmdb_query_free (query); + if (limit_value != NULL) { + g_array_unref (limit_value); + } } static void @@ -948,7 +951,7 @@ rb_playlist_manager_cmd_edit_automatic_playlist (GtkAction *action, creator = g_object_get_data (G_OBJECT (playlist), "rhythmbox-playlist-editor"); if (creator == NULL) { RhythmDBQueryModelLimitType limit_type; - GValueArray *limit_value = NULL; + GArray *limit_value = NULL; GPtrArray *query; char *sort_key; gint sort_direction; @@ -969,7 +972,7 @@ rb_playlist_manager_cmd_edit_automatic_playlist (GtkAction *action, sort_key, sort_direction)); if (limit_value != NULL) { - g_value_array_free (limit_value); + g_array_unref (limit_value); } rhythmdb_query_free (query); g_free (sort_key); diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c index dc1d7c4b5..e1dfe66b3 100644 --- a/shell/rb-shell-player.c +++ b/shell/rb-shell-player.c @@ -134,7 +134,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, - GValueArray *changes, + GArray *changes, RBShellPlayer *player); static void rb_shell_player_entry_activated_cb (RBEntryView *view, @@ -2825,7 +2825,7 @@ rb_shell_player_property_row_activated_cb (RBPropertyView *view, static void rb_shell_player_entry_changed_cb (RhythmDB *db, RhythmDBEntry *entry, - GValueArray *changes, + GArray *changes, RBShellPlayer *player) { gboolean synced = FALSE; @@ -2844,8 +2844,8 @@ rb_shell_player_entry_changed_cb (RhythmDB *db, } location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); - for (i = 0; i < changes->n_values; i++) { - GValue *v = g_value_array_get_nth (changes, i); + for (i = 0; i < changes->len; i++) { + GValue *v = &g_array_index (changes, GValue, i); RhythmDBEntryChange *change = g_value_get_boxed (v); /* update UI if the artist, title or album has changed */ diff --git a/sources/rb-auto-playlist-source.c b/sources/rb-auto-playlist-source.c index c9adc50ae..691b80fab 100644 --- a/sources/rb-auto-playlist-source.c +++ b/sources/rb-auto-playlist-source.c @@ -123,7 +123,7 @@ struct _RBAutoPlaylistSourcePrivate GPtrArray *query; gboolean query_resetting; RhythmDBQueryModelLimitType limit_type; - GValueArray *limit_value; + GArray *limit_value; gboolean query_active; gboolean search_on_completion; @@ -228,7 +228,7 @@ rb_auto_playlist_source_finalize (GObject *object) } if (priv->limit_value) { - g_value_array_free (priv->limit_value); + g_array_unref (priv->limit_value); } G_OBJECT_CLASS (rb_auto_playlist_source_parent_class)->finalize (object); @@ -408,7 +408,7 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) xmlChar *tmp; GPtrArray *query; RhythmDBQueryModelLimitType limit_type = RHYTHMDB_QUERY_MODEL_LIMIT_NONE; - GValueArray *limit_value = NULL; + GArray *limit_value = NULL; gchar *sort_key = NULL; gint sort_direction = 0; GValue val = {0,}; @@ -420,7 +420,8 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) query = rhythmdb_query_deserialize (rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source)), child); - limit_value = g_value_array_new (0); + limit_value = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (limit_value, (GDestroyNotify) g_value_unset); tmp = xmlGetProp (node, RB_PLAYLIST_LIMIT_COUNT); if (!tmp) /* Backwards compatibility */ tmp = xmlGetProp (node, RB_PLAYLIST_LIMIT); @@ -431,7 +432,7 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) g_value_init (&val, G_TYPE_ULONG); g_value_set_ulong (&val, l); - g_value_array_append (limit_value, &val); + g_array_append_val (limit_value, val); g_free (tmp); g_value_unset (&val); } @@ -446,7 +447,7 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) g_value_init (&val, G_TYPE_UINT64); g_value_set_uint64 (&val, l); - g_value_array_append (limit_value, &val); + g_array_append_val (limit_value, val); g_free (tmp); g_value_unset (&val); } @@ -462,7 +463,7 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) g_value_init (&val, G_TYPE_ULONG); g_value_set_ulong (&val, l); - g_value_array_append (limit_value, &val); + g_array_append_val (limit_value, val); g_free (tmp); g_value_unset (&val); } @@ -488,7 +489,7 @@ rb_auto_playlist_source_new_from_xml (RBShell *shell, xmlNodePtr node) sort_key, sort_direction); g_free (sort_key); - g_value_array_free (limit_value); + g_array_unref (limit_value); rhythmdb_query_free (query); return RB_SOURCE (source); @@ -658,24 +659,24 @@ impl_receive_drag (RBDisplayPage *page, GtkSelectionData *data) } static void -_save_write_ulong (xmlNodePtr node, GValueArray *limit_value, const xmlChar *key) +_save_write_ulong (xmlNodePtr node, GArray *limit_value, const xmlChar *key) { gulong l; gchar *str; - l = g_value_get_ulong (g_value_array_get_nth (limit_value, 0)); + l = g_value_get_ulong (&g_array_index (limit_value, GValue, 0)); str = g_strdup_printf ("%u", (guint)l); xmlSetProp (node, key, BAD_CAST str); g_free (str); } static void -_save_write_uint64 (xmlNodePtr node, GValueArray *limit_value, const xmlChar *key) +_save_write_uint64 (xmlNodePtr node, GArray *limit_value, const xmlChar *key) { guint64 l; gchar *str; - l = g_value_get_uint64 (g_value_array_get_nth (limit_value, 0)); + l = g_value_get_uint64 (&g_array_index (limit_value, GValue, 0)); str = g_strdup_printf ("%" G_GUINT64_FORMAT, l); xmlSetProp (node, key, BAD_CAST str); g_free (str); @@ -687,7 +688,7 @@ impl_save_contents_to_xml (RBPlaylistSource *psource, { GPtrArray *query; RhythmDBQueryModelLimitType limit_type; - GValueArray *limit_value = NULL; + GArray *limit_value = NULL; char *sort_key; gint sort_direction; RBAutoPlaylistSource *source = RB_AUTO_PLAYLIST_SOURCE (psource); @@ -736,7 +737,7 @@ impl_save_contents_to_xml (RBPlaylistSource *psource, rhythmdb_query_free (query); if (limit_value != NULL) { - g_value_array_free (limit_value); + g_array_unref (limit_value); } g_free (sort_key); } @@ -830,7 +831,7 @@ void rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source, GPtrArray *query, RhythmDBQueryModelLimitType limit_type, - GValueArray *limit_value, + GArray *limit_value, const char *sort_key, gint sort_order) { @@ -848,7 +849,7 @@ rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source, } if (priv->limit_value) { - g_value_array_free (priv->limit_value); + g_array_unref (priv->limit_value); } /* playlists that aren't limited, with a particular sort order, are user-orderable */ @@ -857,7 +858,7 @@ rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source, priv->query = rhythmdb_query_copy (query); priv->limit_type = limit_type; - priv->limit_value = limit_value ? g_value_array_copy (limit_value) : NULL; + priv->limit_value = limit_value ? g_array_ref (limit_value) : NULL; priv->cached_all_query = g_object_new (RHYTHMDB_TYPE_QUERY_MODEL, "db", db, @@ -877,7 +878,7 @@ rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source, * @source: the #RBAutoPlaylistSource * @query: (out caller-allocates) (transfer full): returns the database query for the playlist * @limit_type: (out callee-allocates): returns the playlist limit type - * @limit_value: (out callee-allocates): returns the playlist limit value + * @limit_value: (out) (transfer full): returns the playlist limit value * @sort_key: (out callee-allocates) (transfer full): returns the playlist sorting key * @sort_order: (out callee-allocates): returns the playlist sorting direction (as a #GtkSortType) * @@ -887,7 +888,7 @@ void rb_auto_playlist_source_get_query (RBAutoPlaylistSource *source, GPtrArray **query, RhythmDBQueryModelLimitType *limit_type, - GValueArray **limit_value, + GArray **limit_value, char **sort_key, gint *sort_order) { @@ -901,7 +902,7 @@ rb_auto_playlist_source_get_query (RBAutoPlaylistSource *source, *query = rhythmdb_query_copy (priv->query); *limit_type = priv->limit_type; - *limit_value = (priv->limit_value) ? g_value_array_copy (priv->limit_value) : NULL; + *limit_value = (priv->limit_value) ? g_array_ref (priv->limit_value) : NULL; rb_entry_view_get_sorting_order (songs, sort_key, sort_order); } diff --git a/sources/rb-auto-playlist-source.h b/sources/rb-auto-playlist-source.h index 9188749ff..68954c62d 100644 --- a/sources/rb-auto-playlist-source.h +++ b/sources/rb-auto-playlist-source.h @@ -73,14 +73,14 @@ RBSource * rb_auto_playlist_source_new_from_xml (RBShell *shell, void rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source, GPtrArray *query, RhythmDBQueryModelLimitType limit_type, - GValueArray *limit_value, + GArray *limit_value, const char *sort_key, gint sort_order); void rb_auto_playlist_source_get_query (RBAutoPlaylistSource *source, GPtrArray **query, RhythmDBQueryModelLimitType *limit_type, - GValueArray **limit_value, + GArray **limit_value, char **sort_key, gint *sort_order); diff --git a/tests/test-rhythmdb.c b/tests/test-rhythmdb.c index 197662f9f..ef0a57cca 100644 --- a/tests/test-rhythmdb.c +++ b/tests/test-rhythmdb.c @@ -473,10 +473,10 @@ START_TEST (test_rhythmdb_modify_after_delete) END_TEST static void -commit_change_merge_cb (RhythmDB *db, RhythmDBEntry *entry, GValueArray *changes, gpointer ok) +commit_change_merge_cb (RhythmDB *db, RhythmDBEntry *entry, GArray *changes, gpointer ok) { int expected = GPOINTER_TO_INT (ok); - fail_unless (changes->n_values == expected, "commit change lists merged"); + fail_unless (changes->len == expected, "commit change lists merged"); } START_TEST (test_rhythmdb_commit_change_merging) diff --git a/tests/test-widgets.c b/tests/test-widgets.c index 40affb0b1..2000a7892 100644 --- a/tests/test-widgets.c +++ b/tests/test-widgets.c @@ -18,7 +18,7 @@ #endif static gboolean -rb_value_array_equal (GValueArray *a1, GValueArray *a2) +rb_value_array_equal (GArray *a1, GArray *a2) { int i; @@ -27,14 +27,14 @@ rb_value_array_equal (GValueArray *a1, GValueArray *a2) else if (a1 == NULL || a2 == NULL) return FALSE; - if (a1->n_values != a2->n_values) + if (a1->len != a2->len) return FALSE; - for (i = 0; i < a1->n_values; i++) { + for (i = 0; i < a1->len; i++) { GValue *v1, *v2; - v1 = g_value_array_get_nth (a1, i); - v2 = g_value_array_get_nth (a2, i); + v1 = &g_array_index (a1, GValue, i); + v2 = &g_array_index (a2, GValue, i); if (rb_gvalue_compare (v1, v2) != 0) return FALSE; } @@ -43,7 +43,7 @@ rb_value_array_equal (GValueArray *a1, GValueArray *a2) } static char * -rb_gvalue_array_to_string (GValueArray *a) +rb_gvalue_array_to_string (GArray *a) { int i; GString *s; @@ -53,13 +53,13 @@ rb_gvalue_array_to_string (GValueArray *a) s = g_string_new ("("); - for (i = 0; i < a->n_values; i++) { + for (i = 0; i < a->len; i++) { GValue *val; if (i != 0) g_string_append (s, ", "); - val = g_value_array_get_nth (a, i); + val = &g_array_index (a, GValue, i); switch (G_VALUE_TYPE (val)) { case G_TYPE_STRING: g_string_append_printf (s, "\"%s\"", g_value_get_string (val)); @@ -146,14 +146,14 @@ static void query_creator_test_load_query (RhythmDB *db, RhythmDBQuery *query, RhythmDBQueryModelLimitType limit_type, - GValueArray *limit_value, + GArray *limit_value, const char *sort_column, gint sort_direction) { GtkWidget *creator; RhythmDBQuery *squery; RhythmDBQuery *query2 = NULL; - GValueArray *limit_value2 = NULL; + GArray *limit_value2 = NULL; const char *sort_column2 = NULL; RhythmDBQueryModelLimitType limit_type2; gint sort_direction2; @@ -194,7 +194,7 @@ query_creator_test_load_query (RhythmDB *db, g_free (str2); g_free (str1); if (limit_value2) - g_value_array_free (limit_value2); + g_array_unref (limit_value2); /* check sorting */ rb_query_creator_get_sort_order (RB_QUERY_CREATOR (creator), @@ -274,108 +274,114 @@ END_TEST START_TEST (test_query_creator_load_limit_count) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_ULONG, 47); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_COUNT, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST START_TEST (test_query_creator_load_limit_minutes) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_ULONG, 37 * 60); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_TIME, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST START_TEST (test_query_creator_load_limit_hours) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_ULONG, 41 * 60 * 60); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_TIME, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST START_TEST (test_query_creator_load_limit_days) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_ULONG, 13 * 60 * 60 * 24); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_TIME, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST START_TEST (test_query_creator_load_limit_mb) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_UINT64, (guint64)13); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_SIZE, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST START_TEST (test_query_creator_load_limit_gb) { RhythmDBQuery *query; - GValueArray *array; + GArray *array; query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_END); - array = g_value_array_new (0); + array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (array, (GDestroyNotify) g_value_unset); rb_value_array_append_data (array, G_TYPE_UINT64, (guint64)(14 * 1000)); query_creator_test_load_query (db, query, RHYTHMDB_QUERY_MODEL_LIMIT_SIZE, array, "Title", GTK_SORT_ASCENDING); rhythmdb_query_free (query); - g_value_array_free (array); + g_array_unref (array); } END_TEST diff --git a/widgets/rb-query-creator.c b/widgets/rb-query-creator.c index 33591b69a..41d4be359 100644 --- a/widgets/rb-query-creator.c +++ b/widgets/rb-query-creator.c @@ -351,7 +351,7 @@ static gboolean rb_query_creator_load_query (RBQueryCreator *creator, GPtrArray *query, RhythmDBQueryModelLimitType limit_type, - GValueArray *limit_value) + GArray *limit_value) { RBQueryCreatorPrivate *priv = QUERY_CREATOR_GET_PRIVATE (creator); int i; @@ -418,17 +418,17 @@ rb_query_creator_load_query (RBQueryCreator *creator, case RHYTHMDB_QUERY_MODEL_LIMIT_COUNT: gtk_combo_box_set_active (GTK_COMBO_BOX (priv->limit_option), 0); - limit = g_value_get_ulong (g_value_array_get_nth (limit_value, 0)); + limit = g_value_get_ulong (&g_array_index (limit_value, GValue, 0)); break; case RHYTHMDB_QUERY_MODEL_LIMIT_TIME: gtk_combo_box_set_active (GTK_COMBO_BOX (priv->limit_option), 3); /* convert to minutes */ - limit = g_value_get_ulong (g_value_array_get_nth (limit_value, 0)) / 60; + limit = g_value_get_ulong (&g_array_index (limit_value, GValue, 0)) / 60; break; case RHYTHMDB_QUERY_MODEL_LIMIT_SIZE: - limit = g_value_get_uint64 (g_value_array_get_nth (limit_value, 0)); + limit = g_value_get_uint64 (&g_array_index (limit_value, GValue, 0)); if (limit % 1000 == 0) { gtk_combo_box_set_active (GTK_COMBO_BOX (priv->limit_option), 2); @@ -495,7 +495,7 @@ GtkWidget * rb_query_creator_new_from_query (RhythmDB *db, GPtrArray *query, RhythmDBQueryModelLimitType limit_type, - GValueArray *limit_value, + GArray *limit_value, const char *sort_column, gint sort_direction) { @@ -633,12 +633,12 @@ rb_query_creator_get_query (RBQueryCreator *creator) * * Retrieves the limit type and value from the query creator. * The limit value is returned as the first element in a - * #GValueArray. + * #GArray. */ void rb_query_creator_get_limit (RBQueryCreator *creator, RhythmDBQueryModelLimitType *type, - GValueArray **limit) + GArray **limit) { RBQueryCreatorPrivate *priv; @@ -650,7 +650,8 @@ rb_query_creator_get_limit (RBQueryCreator *creator, guint64 l; l = gtk_spin_button_get_value(GTK_SPIN_BUTTON (priv->limit_entry)); - *limit = g_value_array_new (0); + *limit = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0); + g_array_set_clear_func (*limit, (GDestroyNotify) g_value_unset); switch (gtk_combo_box_get_active (GTK_COMBO_BOX (priv->limit_option))) { case 0: diff --git a/widgets/rb-query-creator.h b/widgets/rb-query-creator.h index 96073f542..ccdd5f47d 100644 --- a/widgets/rb-query-creator.h +++ b/widgets/rb-query-creator.h @@ -60,14 +60,14 @@ GType rb_query_creator_get_type (void); GtkWidget * rb_query_creator_new (RhythmDB *db); GtkWidget * rb_query_creator_new_from_query (RhythmDB *db, GPtrArray *query, - RhythmDBQueryModelLimitType limit_type, GValueArray *limit_value, + RhythmDBQueryModelLimitType limit_type, GArray *limit_value, const char *sort_column, gint sort_direction); GPtrArray * rb_query_creator_get_query (RBQueryCreator *creator); void rb_query_creator_get_limit (RBQueryCreator *creator, RhythmDBQueryModelLimitType *type, - GValueArray **limit); + GArray **limit); void rb_query_creator_get_sort_order (RBQueryCreator *creator, const char **sort_key, gint *sort_direction); diff --git a/widgets/rb-song-info.c b/widgets/rb-song-info.c index 5792b7e8d..9a2ada769 100644 --- a/widgets/rb-song-info.c +++ b/widgets/rb-song-info.c @@ -267,15 +267,11 @@ rb_song_info_class_init (RBSongInfoClass *klass) */ g_object_class_install_property (object_class, PROP_SELECTED_ENTRIES, - g_param_spec_value_array ("selected-entries", - "Selected entries", - "List of selected entries, if this is a multiple-entry dialog", - g_param_spec_boxed ("selected-entry", - "Selected entry", - "RhythmDBEntry for a selected entry", - RHYTHMDB_TYPE_ENTRY, - G_PARAM_READABLE), - G_PARAM_READABLE)); + g_param_spec_boxed ("selected-entries", + "selected entries", + "List of selected entries, if this is a multiple-entry dialog", + G_TYPE_ARRAY, + G_PARAM_READABLE)); object_class->dispose = rb_song_info_dispose; object_class->finalize = rb_song_info_finalize; @@ -749,15 +745,16 @@ rb_song_info_get_property (GObject *object, break; case PROP_SELECTED_ENTRIES: if (song_info->priv->selected_entries) { - GValueArray *value_array; + GArray *value_array; GValue entry_value = { 0, }; GList *entry_list; - value_array = g_value_array_new (1); + value_array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 1); + g_array_set_clear_func (value_array, (GDestroyNotify) g_value_unset); g_value_init (&entry_value, RHYTHMDB_TYPE_ENTRY); for (entry_list = song_info->priv->selected_entries; entry_list; entry_list = entry_list->next) { g_value_set_boxed (&entry_value, entry_list->data); - g_value_array_append (value_array, &entry_value); + g_array_append_val (value_array, entry_value); } g_value_unset (&entry_value); g_value_take_boxed (value, value_array);