[rygel] core, plugins: Add add_child & remove_child to SimpleContainer
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core, plugins: Add add_child & remove_child to SimpleContainer
- Date: Mon, 21 Sep 2009 14:53:28 +0000 (UTC)
commit 13cb13907a29cd7a4ad62b6720b6abcc5f97cab5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Sep 21 16:18:14 2009 +0300
core,plugins: Add add_child & remove_child to SimpleContainer
Add add_child and remove_child to SimpleContainer. They automatically
increment and decrement child_count respectively.
.../gstlaunch/rygel-gstlaunch-root-container.vala | 12 +++-----
.../mediathek/rygel-mediathek-root-container.vala | 3 +-
.../mediathek/rygel-mediathek-rss-container.vala | 5 ++-
src/plugins/test/rygel-test-root-container.vala | 15 ++++------
src/plugins/tracker/rygel-tracker-keywords.vala | 3 +-
.../tracker/rygel-tracker-metadata-values.vala | 3 +-
.../tracker/rygel-tracker-root-container.vala | 27 +++++++++-----------
src/rygel/rygel-simple-container.vala | 12 +++++++++
8 files changed, 41 insertions(+), 39 deletions(-)
---
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
index cd63c73..a18b6e6 100644
--- a/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
@@ -48,8 +48,6 @@ public class Rygel.GstLaunchRootContainer : SimpleContainer {
} catch (Error err) {
debug ("GstLaunch init failed: %s", err.message);
}
-
- this.child_count = this.children.size;
}
void add_launch_item (string name) {
@@ -61,11 +59,11 @@ public class Rygel.GstLaunchRootContainer : SimpleContainer {
var launch_line = config.get_string (CONFIG_GROUP,
"%s_launch".printf (name));
- this.children.add (new GstLaunchItem (name,
- this,
- title,
- mime_type,
- launch_line));
+ this.add_child (new GstLaunchItem (name,
+ this,
+ title,
+ mime_type,
+ launch_line));
} catch (GLib.Error err) {
debug ("GstLaunch failed item '%s': %s", name, err.message);
}
diff --git a/src/plugins/mediathek/rygel-mediathek-root-container.vala b/src/plugins/mediathek/rygel-mediathek-root-container.vala
index 7936aef..b55e9b3 100644
--- a/src/plugins/mediathek/rygel-mediathek-root-container.vala
+++ b/src/plugins/mediathek/rygel-mediathek-root-container.vala
@@ -62,10 +62,9 @@ public class Rygel.MediathekRootContainer : Rygel.SimpleContainer {
}
foreach (int id in feeds) {
- this.children.add (new MediathekRssContainer (this, id));
+ this.add_child (new MediathekRssContainer (this, id));
}
- this.child_count = this.children.size;
GLib.Timeout.add_seconds (1800, on_schedule_update);
}
}
diff --git a/src/plugins/mediathek/rygel-mediathek-rss-container.vala b/src/plugins/mediathek/rygel-mediathek-rss-container.vala
index 5e05183..b99c6db 100644
--- a/src/plugins/mediathek/rygel-mediathek-rss-container.vala
+++ b/src/plugins/mediathek/rygel-mediathek-rss-container.vala
@@ -54,6 +54,8 @@ public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
Xml.Doc* doc = Xml.Parser.parse_memory (data, (int) length);
if (doc != null) {
this.children.clear ();
+ this.child_count = 0;
+
var ctx = new XPathContext (doc);
var xpo = ctx.eval ("/rss/channel/title");
if (xpo->type == Xml.XPathObjectType.NODESET &&
@@ -70,7 +72,7 @@ public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
var item =
MediathekVideoItem.create_from_xml (this,
node);
- this.children.add (item);
+ this.add_child (item);
ret = true;
}
catch (MediathekVideoItemError error) {
@@ -84,7 +86,6 @@ public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
}
delete doc;
- this.child_count = children.size;
this.updated ();
}
else {
diff --git a/src/plugins/test/rygel-test-root-container.vala b/src/plugins/test/rygel-test-root-container.vala
index f126684..7b28d18 100644
--- a/src/plugins/test/rygel-test-root-container.vala
+++ b/src/plugins/test/rygel-test-root-container.vala
@@ -33,15 +33,12 @@ public class Rygel.TestRootContainer : Rygel.SimpleContainer {
public TestRootContainer (string title) {
base.root (title);
- this.children.add (new TestAudioItem ("sinewave",
- this,
- "Sine Wave"));
- this.children.add (new TestVideoItem ("smtpe",
- this,
- "SMTPE"));
-
- // Now we know how many top-level children we have
- this.child_count = this.children.size;
+ this.add_child (new TestAudioItem ("sinewave",
+ this,
+ "Sine Wave"));
+ this.add_child (new TestVideoItem ("smtpe",
+ this,
+ "SMTPE"));
}
}
diff --git a/src/plugins/tracker/rygel-tracker-keywords.vala b/src/plugins/tracker/rygel-tracker-keywords.vala
index 208cbd8..cd7b8ff 100644
--- a/src/plugins/tracker/rygel-tracker-keywords.vala
+++ b/src/plugins/tracker/rygel-tracker-keywords.vala
@@ -77,10 +77,9 @@ public class Rygel.TrackerKeywords : Rygel.SimpleContainer {
"",
keywords);
- this.children.add (container);
+ this.add_child (container);
}
- this.child_count = this.children.size;
this.updated ();
}
diff --git a/src/plugins/tracker/rygel-tracker-metadata-values.vala b/src/plugins/tracker/rygel-tracker-metadata-values.vala
index 45f8f37..b7f3c09 100644
--- a/src/plugins/tracker/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker/rygel-tracker-metadata-values.vala
@@ -103,10 +103,9 @@ public class Rygel.TrackerMetadataValues : Rygel.SimpleContainer {
SERVICE,
query_condition);
- this.children.add (container);
+ this.add_child (container);
}
- this.child_count = this.children.size;
this.updated ();
}
diff --git a/src/plugins/tracker/rygel-tracker-root-container.vala b/src/plugins/tracker/rygel-tracker-root-container.vala
index c520118..de7ac8e 100644
--- a/src/plugins/tracker/rygel-tracker-root-container.vala
+++ b/src/plugins/tracker/rygel-tracker-root-container.vala
@@ -33,33 +33,30 @@ public class Rygel.TrackerRootContainer : Rygel.SimpleContainer {
public TrackerRootContainer (string title) {
base.root (title);
- this.children.add (new TrackerSearchContainer (
+ this.add_child (new TrackerSearchContainer (
"16",
this,
"Pictures",
TrackerImageItem.SERVICE));
- this.children.add (new TrackerSearchContainer (
+ this.add_child (new TrackerSearchContainer (
"14",
this,
"Music",
TrackerMusicItem.SERVICE));
- this.children.add (new TrackerSearchContainer (
+ this.add_child (new TrackerSearchContainer (
"15",
this,
"Videos",
TrackerVideoItem.SERVICE));
- this.children.add (new TrackerMetadataValues ("Audio:Artist",
- "17",
- this,
- "Artists"));
- this.children.add (new TrackerMetadataValues ("Audio:Album",
- "18",
- this,
- "Albums"));
- this.children.add (new TrackerKeywords ("19", this));
-
- // Now we know how many top-level containers we have
- this.child_count = this.children.size;
+ this.add_child (new TrackerMetadataValues ("Audio:Artist",
+ "17",
+ this,
+ "Artists"));
+ this.add_child (new TrackerMetadataValues ("Audio:Album",
+ "18",
+ this,
+ "Albums"));
+ this.add_child (new TrackerKeywords ("19", this));
}
}
diff --git a/src/rygel/rygel-simple-container.vala b/src/rygel/rygel-simple-container.vala
index c91d948..a699457 100644
--- a/src/rygel/rygel-simple-container.vala
+++ b/src/rygel/rygel-simple-container.vala
@@ -47,6 +47,18 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer {
this ("0", null, title);
}
+ public void add_child (MediaObject child) {
+ this.children.add (child);
+
+ this.child_count++;
+ }
+
+ public void remove_child (MediaObject child) {
+ this.children.remove (child);
+
+ this.child_count--;
+ }
+
public override void get_children (uint offset,
uint max_count,
Cancellable? cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]