Skip to content

Commit

Permalink
replace deprecated GValueArray with equivalent GArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Matthew committed Jul 21, 2012
1 parent 88c358c commit a1172d1
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 138 deletions.
10 changes: 5 additions & 5 deletions backends/gstreamer/rb-player-gst-xfade.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);

Expand Down
32 changes: 14 additions & 18 deletions lib/rb-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/rb-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions plugins/ipod/rb-ipod-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: {
Expand Down
6 changes: 3 additions & 3 deletions plugins/mpris/rb-mpris-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions plugins/visualizer/rb-visualizer-fullscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions podcast/rb-podcast-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
24 changes: 12 additions & 12 deletions rhythmdb/rhythmdb-query-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -224,7 +224,7 @@ struct _RhythmDBQueryModelPrivate
guint stamp;

RhythmDBQueryModelLimitType limit_type;
GValueArray *limit_value;
GArray *limit_value;

glong total_duration;
guint64 total_size;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions rhythmdb/rhythmdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rhythmdb/rhythmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions shell/rb-playlist-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Loading

0 comments on commit a1172d1

Please sign in to comment.