~matttbe/ubuntu/raring/rhythmbox/lp1010619_RB_2.98

« back to all changes in this revision

Viewing changes to sources/rb-auto-playlist-source.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-11-06 20:52:57 UTC
  • mfrom: (1.1.67) (214.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20121106205257-0btjh8jqley153el
Tags: 2.98-0ubuntu1
* New upstream release (LP: #1060601)
* debian/control.in:
  - Bump minimum glib, gtk, totem-plparser, clutter, and clutter-gst
  - Drop no longer needed musicbrainz dependency
* Refreshed 09_keywords.patch
* Updated 11_fix_cd_pausing.patch with fix from git
* Dropped patches applied in new version:
  - 00git_musicbrainz5.patch
  - 08_CVE-2012-3355.patch
  - dont_free_consumed_floating_gvariant.patch
  - git_scale_click.patch
  - git_crash_during_monitor.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        GPtrArray *query;
124
124
        gboolean query_resetting;
125
125
        RhythmDBQueryModelLimitType limit_type;
126
 
        GValueArray *limit_value;
 
126
        GArray *limit_value;
127
127
 
128
128
        gboolean query_active;
129
129
        gboolean search_on_completion;
173
173
}
174
174
 
175
175
static void
176
 
rb_auto_playlist_source_init (RBAutoPlaylistSource *source)
 
176
set_playlist_pixbuf (RBAutoPlaylistSource *source)
177
177
{
178
178
        if (playlist_pixbuf == NULL) {
179
179
                gint size;
193
193
        } else {
194
194
                g_object_set (source, "pixbuf", playlist_pixbuf, NULL);
195
195
        }
 
196
}
196
197
 
 
198
static void
 
199
rb_auto_playlist_source_init (RBAutoPlaylistSource *source)
 
200
{
197
201
}
198
202
 
199
203
static void
228
232
        }
229
233
 
230
234
        if (priv->limit_value) {
231
 
                g_value_array_free (priv->limit_value);
 
235
                g_array_unref (priv->limit_value);
232
236
        }
233
237
 
234
238
        G_OBJECT_CLASS (rb_auto_playlist_source_parent_class)->finalize (object);
280
284
 
281
285
        priv->paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
282
286
 
 
287
        set_playlist_pixbuf (source);
 
288
 
283
289
        g_object_get (RB_PLAYLIST_SOURCE (source), "entry-type", &entry_type, NULL);
284
290
        priv->browser = rb_library_browser_new (rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source)),
285
291
                                                entry_type);
299
305
        /* set up toolbar */
300
306
        g_object_get (source, "shell", &shell, NULL);
301
307
        g_object_get (shell, "ui-manager", &ui_manager, NULL);
302
 
        priv->toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager);
 
308
        priv->toolbar = rb_source_toolbar_new (RB_DISPLAY_PAGE (source), ui_manager);
303
309
        rb_source_toolbar_add_search_entry (priv->toolbar, "/AutoPlaylistSourceSearchMenu", NULL);
304
310
 
305
311
        g_object_unref (ui_manager);
408
414
        xmlChar *tmp;
409
415
        GPtrArray *query;
410
416
        RhythmDBQueryModelLimitType limit_type = RHYTHMDB_QUERY_MODEL_LIMIT_NONE;
411
 
        GValueArray *limit_value = NULL;
 
417
        GArray *limit_value = NULL;
412
418
        gchar *sort_key = NULL;
413
419
        gint sort_direction = 0;
414
420
        GValue val = {0,};
420
426
        query = rhythmdb_query_deserialize (rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source)),
421
427
                                            child);
422
428
 
423
 
        limit_value = g_value_array_new (0);
 
429
        limit_value = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 0);
 
430
        g_array_set_clear_func (limit_value, (GDestroyNotify) g_value_unset);
424
431
        tmp = xmlGetProp (node, RB_PLAYLIST_LIMIT_COUNT);
425
432
        if (!tmp) /* Backwards compatibility */
426
433
                tmp = xmlGetProp (node, RB_PLAYLIST_LIMIT);
431
438
 
432
439
                        g_value_init (&val, G_TYPE_ULONG);
433
440
                        g_value_set_ulong (&val, l);
434
 
                        g_value_array_append (limit_value, &val);
 
441
                        g_array_append_val (limit_value, val);
435
442
                        g_free (tmp);
436
443
                        g_value_unset (&val);
437
444
                }
446
453
 
447
454
                                g_value_init (&val, G_TYPE_UINT64);
448
455
                                g_value_set_uint64 (&val, l);
449
 
                                g_value_array_append (limit_value, &val);
 
456
                                g_array_append_val (limit_value, val);
450
457
                                g_free (tmp);
451
458
                                g_value_unset (&val);
452
459
                        }
462
469
 
463
470
                                g_value_init (&val, G_TYPE_ULONG);
464
471
                                g_value_set_ulong (&val, l);
465
 
                                g_value_array_append (limit_value, &val);
 
472
                                g_array_append_val (limit_value, val);
466
473
                                g_free (tmp);
467
474
                                g_value_unset (&val);
468
475
                        }
488
495
                                           sort_key,
489
496
                                           sort_direction);
490
497
        g_free (sort_key);
491
 
        g_value_array_free (limit_value);
 
498
        g_array_unref (limit_value);
492
499
        rhythmdb_query_free (query);
493
500
 
494
501
        return RB_SOURCE (source);
658
665
}
659
666
 
660
667
static void
661
 
_save_write_ulong (xmlNodePtr node, GValueArray *limit_value, const xmlChar *key)
 
668
_save_write_ulong (xmlNodePtr node, GArray *limit_value, const xmlChar *key)
662
669
{
663
670
        gulong l;
664
671
        gchar *str;
665
672
 
666
 
        l = g_value_get_ulong (g_value_array_get_nth (limit_value, 0));
 
673
        l = g_value_get_ulong (&g_array_index (limit_value, GValue, 0));
667
674
        str = g_strdup_printf ("%u", (guint)l);
668
675
        xmlSetProp (node, key, BAD_CAST str);
669
676
        g_free (str);
670
677
}
671
678
 
672
679
static void
673
 
_save_write_uint64 (xmlNodePtr node, GValueArray *limit_value, const xmlChar *key)
 
680
_save_write_uint64 (xmlNodePtr node, GArray *limit_value, const xmlChar *key)
674
681
{
675
682
        guint64 l;
676
683
        gchar *str;
677
684
 
678
 
        l = g_value_get_uint64 (g_value_array_get_nth (limit_value, 0));
 
685
        l = g_value_get_uint64 (&g_array_index (limit_value, GValue, 0));
679
686
        str = g_strdup_printf ("%" G_GUINT64_FORMAT, l);
680
687
        xmlSetProp (node, key, BAD_CAST str);
681
688
        g_free (str);
687
694
{
688
695
        GPtrArray *query;
689
696
        RhythmDBQueryModelLimitType limit_type;
690
 
        GValueArray *limit_value = NULL;
 
697
        GArray *limit_value = NULL;
691
698
        char *sort_key;
692
699
        gint sort_direction;
693
700
        RBAutoPlaylistSource *source = RB_AUTO_PLAYLIST_SOURCE (psource);
736
743
        rhythmdb_query_free (query);
737
744
 
738
745
        if (limit_value != NULL) {
739
 
                g_value_array_free (limit_value);
 
746
                g_array_unref (limit_value);
740
747
        }
741
748
        g_free (sort_key);
742
749
}
830
837
rb_auto_playlist_source_set_query (RBAutoPlaylistSource *source,
831
838
                                   GPtrArray *query,
832
839
                                   RhythmDBQueryModelLimitType limit_type,
833
 
                                   GValueArray *limit_value,
 
840
                                   GArray *limit_value,
834
841
                                   const char *sort_key,
835
842
                                   gint sort_order)
836
843
{
848
855
        }
849
856
 
850
857
        if (priv->limit_value) {
851
 
                g_value_array_free (priv->limit_value);
 
858
                g_array_unref (priv->limit_value);
852
859
        }
853
860
 
854
861
        /* playlists that aren't limited, with a particular sort order, are user-orderable */
857
864
 
858
865
        priv->query = rhythmdb_query_copy (query);
859
866
        priv->limit_type = limit_type;
860
 
        priv->limit_value = limit_value ? g_value_array_copy (limit_value) : NULL;
 
867
        priv->limit_value = limit_value ? g_array_ref (limit_value) : NULL;
861
868
 
862
869
        priv->cached_all_query = g_object_new (RHYTHMDB_TYPE_QUERY_MODEL,
863
870
                                               "db", db,
877
884
 * @source: the #RBAutoPlaylistSource
878
885
 * @query: (out caller-allocates) (transfer full): returns the database query for the playlist
879
886
 * @limit_type: (out callee-allocates): returns the playlist limit type
880
 
 * @limit_value: (out callee-allocates): returns the playlist limit value
 
887
 * @limit_value: (out) (transfer full): returns the playlist limit value
881
888
 * @sort_key: (out callee-allocates) (transfer full): returns the playlist sorting key
882
889
 * @sort_order: (out callee-allocates): returns the playlist sorting direction (as a #GtkSortType)
883
890
 *
887
894
rb_auto_playlist_source_get_query (RBAutoPlaylistSource *source,
888
895
                                   GPtrArray **query,
889
896
                                   RhythmDBQueryModelLimitType *limit_type,
890
 
                                   GValueArray **limit_value,
 
897
                                   GArray **limit_value,
891
898
                                   char **sort_key,
892
899
                                   gint *sort_order)
893
900
{
901
908
 
902
909
        *query = rhythmdb_query_copy (priv->query);
903
910
        *limit_type = priv->limit_type;
904
 
        *limit_value = (priv->limit_value) ? g_value_array_copy (priv->limit_value) : NULL;
 
911
        *limit_value = (priv->limit_value) ? g_array_ref (priv->limit_value) : NULL;
905
912
 
906
913
        rb_entry_view_get_sorting_order (songs, sort_key, sort_order);
907
914
}