[rygel] tracker: Add "New" container
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] tracker: Add "New" container
- Date: Wed, 8 Dec 2010 18:42:06 +0000 (UTC)
commit 404c55d698c49634db9368ebac386352d30f4599
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Dec 8 20:32:20 2010 +0200
tracker: Add "New" container
Under each category container, add a child container that lists all items
of that category that were added (to tracker-store) less than 3 days ago.
src/plugins/tracker/Makefile.am | 1 +
src/plugins/tracker/rygel-tracker-music.vala | 1 +
src/plugins/tracker/rygel-tracker-new.vala | 57 +++++++++++++++++++++++
src/plugins/tracker/rygel-tracker-pictures.vala | 1 +
src/plugins/tracker/rygel-tracker-videos.vala | 1 +
5 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index 2c78a5c..b626df8 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -23,6 +23,7 @@ librygel_media_tracker_la_SOURCES = rygel-tracker-root-container.vala \
rygel-tracker-albums.vala \
rygel-tracker-artists.vala \
rygel-tracker-genre.vala \
+ rygel-tracker-new.vala \
rygel-tracker-search-container.vala \
rygel-tracker-category-all-container.vala \
rygel-tracker-query.vala \
diff --git a/src/plugins/tracker/rygel-tracker-music.vala b/src/plugins/tracker/rygel-tracker-music.vala
index 751b2a0..beda548 100644
--- a/src/plugins/tracker/rygel-tracker-music.vala
+++ b/src/plugins/tracker/rygel-tracker-music.vala
@@ -35,6 +35,7 @@ public class Rygel.Tracker.Music : CategoryContainer {
this.add_child (new Genre (this));
this.add_child (new Tags (this, item_factory));
this.add_child (new Titles (this, this.item_factory));
+ this.add_child (new New (this, this.item_factory));
}
}
diff --git a/src/plugins/tracker/rygel-tracker-new.vala b/src/plugins/tracker/rygel-tracker-new.vala
new file mode 100644
index 0000000..9b87fc8
--- /dev/null
+++ b/src/plugins/tracker/rygel-tracker-new.vala
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2008,2010 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using Gee;
+
+/**
+ * A container listing all newly (<3 days) added items.
+ */
+public class Rygel.Tracker.New : Rygel.Tracker.SearchContainer {
+ private const string ADDED_PREDICATE = "tracker:added";
+ private const string ADDED_VARIABLE = "?added";
+ private const long THREE_DAYS_AS_SEC = 259200;
+
+ public New (MediaContainer parent, ItemFactory item_factory) {
+ var triplets = new QueryTriplets ();
+
+ triplets.add_triplet (new QueryTriplet (SelectionQuery.ITEM_VARIABLE,
+ "a",
+ item_factory.category));
+ triplets.add_triplet (new QueryTriplet (SelectionQuery.ITEM_VARIABLE,
+ ADDED_PREDICATE,
+ ADDED_VARIABLE));
+
+ var time = TimeVal ();
+ time.tv_sec -= THREE_DAYS_AS_SEC;
+
+ var filters = new ArrayList<string> ();
+ filters.add (ADDED_VARIABLE + " > \"" + time.to_iso8601 () + "\"");
+
+ base (parent.id + "New",
+ parent,
+ "New",
+ item_factory,
+ triplets,
+ filters);
+ }
+}
diff --git a/src/plugins/tracker/rygel-tracker-pictures.vala b/src/plugins/tracker/rygel-tracker-pictures.vala
index 75593f6..28636c7 100644
--- a/src/plugins/tracker/rygel-tracker-pictures.vala
+++ b/src/plugins/tracker/rygel-tracker-pictures.vala
@@ -33,6 +33,7 @@ public class Rygel.Tracker.Pictures : CategoryContainer {
this.add_child (new Tags (this, this.item_factory));
this.add_child (new Years (this, this.item_factory));
this.add_child (new Titles (this, this.item_factory));
+ this.add_child (new New (this, this.item_factory));
}
}
diff --git a/src/plugins/tracker/rygel-tracker-videos.vala b/src/plugins/tracker/rygel-tracker-videos.vala
index c0be593..65da5bf 100644
--- a/src/plugins/tracker/rygel-tracker-videos.vala
+++ b/src/plugins/tracker/rygel-tracker-videos.vala
@@ -33,6 +33,7 @@ public class Rygel.Tracker.Videos : CategoryContainer {
this.add_child (new Tags (this, this.item_factory));
this.add_child (new Years (this, this.item_factory));
this.add_child (new Titles (this, this.item_factory));
+ this.add_child (new New (this, this.item_factory));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]