[grilo] core: Add a default root media in notify_change()



commit d41e8dfc5060e4611dda5598085e75072e072b91
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Tue Feb 1 17:55:14 2011 +0100

    core: Add a default root media in notify_change()
    
    If plugin use a NULL-media in notify_change(), replace it by the GrlBox that
    represents the root.
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 src/grl-media-source.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index 07e3c90..088fb1e 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -2585,7 +2585,7 @@ grl_media_source_notify_change_stop (GrlMediaSource *source,
 /**
  * grl_media_source_notify_change:
  * @source: a media source
- * @media: (allow-none): the media which has changed
+ * @media: (allow-none): the media which has changed, or @NULL to use the root box.
  * @change_type: the type of change
  * @location_unknown: if change has happpened in @media or any descendant
  *
@@ -2605,13 +2605,25 @@ void grl_media_source_notify_change (GrlMediaSource *source,
                                      GrlMediaSourceChangeType change_type,
                                      gboolean location_unknown)
 {
+  gboolean free_media = FALSE;
+
   g_return_if_fail (GRL_IS_MEDIA_SOURCE (source));
   g_return_if_fail (!media || GRL_IS_MEDIA (media));
 
+  if (!media) {
+    media = grl_media_box_new();
+    free_media = TRUE;
+  }
+
+  grl_media_set_source (media,
+                        grl_metadata_source_get_id (GRL_METADATA_SOURCE (source)));
   g_signal_emit (source,
                  registry_signals[SIG_CONTENT_CHANGED],
                  0,
                  media,
                  change_type,
                  location_unknown);
+  if (free_media) {
+    g_object_unref (media);
+  }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]