[rygel] media-export: Don't show empty virtual folders
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Don't show empty virtual folders
- Date: Mon, 21 Feb 2011 20:46:53 +0000 (UTC)
commit 3305afc1cecc7ef26d5b7fdd588a3825cfe4b369
Author: Jens Georg <mail jensge org>
Date: Sat Feb 12 23:59:38 2011 +0100
media-export: Don't show empty virtual folders
.../rygel-media-export-object-factory.vala | 8 +++++
.../rygel-media-export-root-container.vala | 30 ++++++++++++++++---
2 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-object-factory.vala b/src/plugins/media-export/rygel-media-export-object-factory.vala
index e7fce2a..d1dabc4 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -40,6 +40,14 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
// Must not fail - plugin is disabled if this fails
assert_not_reached ();
}
+ } else if (id == RootContainer.FILESYSTEM_FOLDER_ID) {
+ try {
+ var root_container = RootContainer.get_instance ()
+ as RootContainer;
+
+ return root_container.get_filesystem_container ()
+ as DBContainer;
+ } catch (Error error) { assert_not_reached (); }
}
if (id.has_prefix (QueryContainer.PREFIX)) {
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 5e5e053..0d47bc9 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -70,6 +70,10 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
return RootContainer.instance;
}
+ public MediaContainer get_filesystem_container () {
+ return this.filesystem_container;
+ }
+
public void shutdown () {
this.cancellable.cancel ();
}
@@ -335,10 +339,11 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
} catch (Error error) { } // do nothing
try {
- this.filesystem_container = new NullContainer ();
+ this.filesystem_container = new DBContainer
+ (media_db,
+ FILESYSTEM_FOLDER_ID,
+ FILESYSTEM_FOLDER_NAME);
this.filesystem_container.parent = this;
- this.filesystem_container.title = FILESYSTEM_FOLDER_NAME;
- this.filesystem_container.id = FILESYSTEM_FOLDER_ID;
this.media_db.save_container (this.filesystem_container);
} catch (Error error) { }
@@ -368,6 +373,11 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
}
}
+ this.filesystem_container.container_updated.connect( () => {
+ this.add_default_virtual_folders ();
+ this.updated ();
+ });
+
this.add_default_virtual_folders ();
this.updated ();
@@ -400,8 +410,12 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
var query_container = new QueryContainer (this.media_db,
id,
definition.title);
- query_container.parent = container;
- this.media_db.save_container (query_container);
+ if (query_container.child_count > 0) {
+ query_container.parent = container;
+ this.media_db.save_container (query_container);
+ } else {
+ this.media_db.remove_by_id (id);
+ }
}
private void add_virtual_containers_for_class
@@ -424,5 +438,11 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
this.add_folder_definition (container, item_class, definition);
}
}
+
+ if (this.media_db.get_child_count (container.id) == 0) {
+ this.media_db.remove_by_id (container.id);
+ } else {
+ container.updated ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]