[rygel] tracker: Add title-based hierarchies



commit 75a603f88f381d77e73a6703d28a537e91b31321
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Dec 8 18:23:44 2010 +0200

    tracker: Add title-based hierarchies
    
    Under each category container, add a container providing a title-based
    hierarchy: One container for each unique starting character of all the titles
    available for the contegory in question. Something like this:
    
    Music
      |
      |----> Genre
              |..
      ^
      |----> Titles
              |
              |---> A
                    |
                    |--> Alpha
                    |--> alright
              ^
              |---> B
                    |
                    |--> Bravo
                    |--> brave
                    |..
              ^
      ^       |..
      |..

 src/plugins/tracker/Makefile.am                 |    1 +
 src/plugins/tracker/rygel-tracker-music.vala    |    1 +
 src/plugins/tracker/rygel-tracker-pictures.vala |    1 +
 src/plugins/tracker/rygel-tracker-titles.vala   |   81 +++++++++++++++++++++++
 src/plugins/tracker/rygel-tracker-videos.vala   |    1 +
 5 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index f93b5af..2c78a5c 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -19,6 +19,7 @@ librygel_media_tracker_la_SOURCES = rygel-tracker-root-container.vala \
 				    rygel-tracker-metadata-values.vala \
 				    rygel-tracker-tags.vala \
 				    rygel-tracker-years.vala \
+				    rygel-tracker-titles.vala \
 				    rygel-tracker-albums.vala \
 				    rygel-tracker-artists.vala \
 				    rygel-tracker-genre.vala \
diff --git a/src/plugins/tracker/rygel-tracker-music.vala b/src/plugins/tracker/rygel-tracker-music.vala
index 2a82201..751b2a0 100644
--- a/src/plugins/tracker/rygel-tracker-music.vala
+++ b/src/plugins/tracker/rygel-tracker-music.vala
@@ -34,6 +34,7 @@ public class Rygel.Tracker.Music : CategoryContainer {
         this.add_child (new Albums (this));
         this.add_child (new Genre (this));
         this.add_child (new Tags (this, item_factory));
+        this.add_child (new Titles (this, this.item_factory));
     }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-pictures.vala b/src/plugins/tracker/rygel-tracker-pictures.vala
index 42e761b..09776e6 100644
--- a/src/plugins/tracker/rygel-tracker-pictures.vala
+++ b/src/plugins/tracker/rygel-tracker-pictures.vala
@@ -34,6 +34,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));
     }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-titles.vala b/src/plugins/tracker/rygel-tracker-titles.vala
new file mode 100644
index 0000000..684d9e3
--- /dev/null
+++ b/src/plugins/tracker/rygel-tracker-titles.vala
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * 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.
+ */
+
+/**
+ * Container providing a title-based hierarchy.
+ *
+ * Under each category container, add a container providing a title-based
+ * hierarchy: One container for each unique starting character of all the titles
+ * available for the contegory in question. Something like this:
+ *
+ * Music
+ *   |
+ *   |----> Genre
+ *           |..
+ *   ^
+ *   |----> Titles
+ *           |
+ *           |---> A
+ *                 |
+ *                 |--> Alpha
+ *                 |--> alright
+ *           ^
+ *           |---> B
+ *                 |
+ *                 |--> Bravo
+ *                 |--> brave
+ *                 |..
+ *           ^
+ *   ^       |..
+ *   |..
+ */
+public class Rygel.Tracker.Titles : MetadataValues {
+    private const string[] KEY_CHAIN = { "nie:title", null };
+
+    public Titles (MediaContainer parent, ItemFactory item_factory) {
+        base (parent.id + "Titles",
+              parent,
+              _("Titles"),
+              item_factory,
+              KEY_CHAIN);
+    }
+
+    // The parent class will only create a child container for each unique
+    // title this method returns so we don't need to worry about multiple
+    // containers being created for each letter.
+    protected override string? create_title_for_value (string value) {
+        var c = value.get_char_validated ();
+
+        if (unlikely (c < 0)) {
+            return null;
+        }
+
+        return c.to_string ().up ();
+    }
+
+    protected override string create_filter (string variable, string value) {
+        var title = this.create_title_for_value (value);
+
+        return "regex(" + variable + ", \"^" + title + "\", \"i\")";
+    }
+}
diff --git a/src/plugins/tracker/rygel-tracker-videos.vala b/src/plugins/tracker/rygel-tracker-videos.vala
index 9ae8fec..c0be593 100644
--- a/src/plugins/tracker/rygel-tracker-videos.vala
+++ b/src/plugins/tracker/rygel-tracker-videos.vala
@@ -32,6 +32,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));
     }
 }
 



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