[rygel] core,external: Move string substitution to core



commit a39fbb917e04fd5392dcfbdbf7c80bd209d052d8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sun Oct 25 17:07:16 2009 +0200

    core,external: Move string substitution to core
    
    Now internal plugins can use the string substitution magic in title
    strings as well.

 src/plugins/external/rygel-external-container.vala |   11 -----------
 .../external/rygel-external-item-factory.vala      |    2 +-
 src/rygel/rygel-media-object.vala                  |   17 ++++++++++++++++-
 3 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-container.vala b/src/plugins/external/rygel-external-container.vala
index 83f6071..3571b5a 100644
--- a/src/plugins/external/rygel-external-container.vala
+++ b/src/plugins/external/rygel-external-container.vala
@@ -115,17 +115,6 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
         return media_object;
     }
 
-    public string substitute_keywords (string title) {
-        var new_title = title.replace ("@REALNAME@",
-                                       Environment.get_real_name ());
-        new_title = new_title.replace ("@USERNAME@",
-                                       Environment.get_user_name ());
-        new_title = new_title.replace ("@HOSTNAME@",
-                                       Environment.get_host_name ());
-
-        return new_title;
-    }
-
     // Private methods
     private MediaContainer? find_container (string id) {
         MediaContainer container = null;
diff --git a/src/plugins/external/rygel-external-item-factory.vala b/src/plugins/external/rygel-external-item-factory.vala
index 5cf9b7b..bd84bf6 100644
--- a/src/plugins/external/rygel-external-item-factory.vala
+++ b/src/plugins/external/rygel-external-item-factory.vala
@@ -67,7 +67,7 @@ public class Rygel.ExternalItemFactory {
                                   "Unknown"); /* UPnP Class Unknown atm */
 
         var value = object_props.lookup ("DisplayName");
-        item.title = parent.substitute_keywords (value.get_string ());
+        item.title = value.get_string ();
 
         value = item_props.lookup ("Type");
         string type = value.get_string ();
diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala
index 6d552b9..c05d2d4 100644
--- a/src/rygel/rygel-media-object.vala
+++ b/src/rygel/rygel-media-object.vala
@@ -28,7 +28,6 @@ using Gee;
  */
 public abstract class Rygel.MediaObject : GLib.Object {
     public string id;
-    public string title;
     public uint64 modified;
     public Gee.ArrayList<string> uris;
 
@@ -43,6 +42,22 @@ public abstract class Rygel.MediaObject : GLib.Object {
     public unowned MediaContainer parent;
     public MediaContainer parent_ref;
 
+    private string _title;
+    public string title {
+        get {
+            return _title;
+        }
+
+        set {
+            this._title = value.replace ("@REALNAME@",
+                                         Environment.get_real_name ());
+            _title = _title.replace ("@USERNAME@",
+                                     Environment.get_user_name ());
+            _title = _title.replace ("@HOSTNAME@",
+                                     Environment.get_host_name ());
+        }
+    }
+
     construct {
         uris = new ArrayList<string> ();
     }



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