From 39bd472029be9cf49944a7bc7e2ab3117ccf4e07 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Tue, 21 Dec 2010 22:47:27 +0200 Subject: [PATCH] core,tracker: CategoryContainer.add_child_container -> SimpleContainer Move add_child_container method of Tracker.CategoryContainer to parent SimpleContainer in core so that all plugins can make use of it. --- .../tracker/rygel-tracker-category-container.vala | 28 ---------------------- src/rygel/rygel-simple-container.vala | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/plugins/tracker/rygel-tracker-category-container.vala b/src/plugins/tracker/rygel-tracker-category-container.vala index 4e24d9f..0dc6b2a 100644 --- a/src/plugins/tracker/rygel-tracker-category-container.vala +++ b/src/plugins/tracker/rygel-tracker-category-container.vala @@ -29,8 +29,6 @@ using Gee; public abstract class Rygel.Tracker.CategoryContainer : Rygel.SimpleContainer { public ItemFactory item_factory; - private MediaObjects empty_children; - public CategoryContainer (string id, MediaContainer parent, string title, @@ -38,36 +36,10 @@ public abstract class Rygel.Tracker.CategoryContainer : Rygel.SimpleContainer { base (id, parent, title); this.item_factory = item_factory; - this.empty_children = new MediaObjects (); this.add_child_container (new CategoryAllContainer (this)); this.add_child_container (new Tags (this, item_factory)); this.add_child_container (new Titles (this, this.item_factory)); this.add_child_container (new New (this, this.item_factory)); } - - protected void add_child_container (MediaContainer child) { - if (child.child_count > 0) { - this.add_child (child); - } else { - this.empty_children.add (child); - child.container_updated.connect (this.on_container_updated); - } - } - - private void on_container_updated (MediaContainer source, - MediaContainer updated) { - if (!(updated in this.empty_children)) { - return; - } - - if (updated.child_count > 0) { - this.empty_children.remove (updated); - updated.container_updated.disconnect (this.on_container_updated); - - this.add_child (updated); - - this.updated (); - } - } } diff --git a/src/rygel/rygel-simple-container.vala b/src/rygel/rygel-simple-container.vala index 36fab0d..e05fd4e 100644 --- a/src/rygel/rygel-simple-container.vala +++ b/src/rygel/rygel-simple-container.vala @@ -33,12 +33,15 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer, Rygel.SearchableContainer { public MediaObjects children; + private MediaObjects empty_children; + public SimpleContainer (string id, MediaContainer? parent, string title) { base (id, parent, title, 0); this.children = new MediaObjects (); + this.empty_children = new MediaObjects (); } public SimpleContainer.root (string title) { @@ -51,6 +54,15 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer, this.child_count++; } + public void add_child_container (MediaContainer child) { + if (child.child_count > 0) { + this.add_child (child); + } else { + this.empty_children.add (child); + child.container_updated.connect (this.on_container_updated); + } + } + public void remove_child (MediaObject child) { this.children.remove (child); @@ -108,4 +120,20 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer, out total_matches, cancellable); } + + private void on_container_updated (MediaContainer source, + MediaContainer updated) { + if (!(updated in this.empty_children)) { + return; + } + + if (updated.child_count > 0) { + this.empty_children.remove (updated); + updated.container_updated.disconnect (this.on_container_updated); + + this.add_child (updated); + + this.updated (); + } + } } -- 2.7.4