[rygel] core: Expose Rygel logo on UPnP network



commit a8a9132497c26072fc0849a8fb4739869ee936a7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu May 6 04:02:30 2010 +0300

    core: Expose Rygel logo on UPnP network
    
    If the plugin does not provide an icon, use rygel logo.

 src/rygel/Makefile.am                    |    4 +++-
 src/rygel/cstuff.vapi                    |    3 +++
 src/rygel/rygel-plugin.vala              |   30 ++++++++++++++++++++++++++++++
 src/rygel/rygel-root-device-factory.vala |   13 ++++++++-----
 4 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index 3cf421d..b74928e 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -2,10 +2,12 @@ if UNINSTALLED
 shareddir = $(abs_top_builddir)/data
 desktopdir = $(shareddir)
 plugindir = $(abs_top_builddir)/src/plugins
+icondir = $(shareddir)/icons
 else
 shareddir = $(datadir)/rygel
 desktopdir = $(datadir)/applications
 plugindir = $(libdir)/rygel-1.0
+icondir = $(datadir)/icons/hicolor
 endif
 
 AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
@@ -20,7 +22,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 	    -I$(top_srcdir) \
 	    -DDATA_DIR='"$(shareddir)"' -DSYS_CONFIG_DIR='"$(sysconfdir)"'\
 	    -DPLUGIN_DIR='"$(plugindir)"' -DDESKTOP_DIR='"$(desktopdir)"'\
-	    -include config.h
+	    -DICON_DIR='"$(icondir)"' -include config.h
 
 librygelincdir = $(includedir)/rygel-1.0
 
diff --git a/src/rygel/cstuff.vapi b/src/rygel/cstuff.vapi
index 546c8c6..04eba54 100644
--- a/src/rygel/cstuff.vapi
+++ b/src/rygel/cstuff.vapi
@@ -40,6 +40,9 @@ namespace CStuff {
         [CCode (cname = "PLUGIN_DIR")]
         public static const string PLUGIN_DIR;
 
+        [CCode (cname = "ICON_DIR")]
+        public static const string ICON_DIR;
+
         [CCode (cname = "PACKAGE_NAME")]
         public static const string PACKAGE_NAME;
 
diff --git a/src/rygel/rygel-plugin.vala b/src/rygel/rygel-plugin.vala
index cfddd76..6d8aca1 100644
--- a/src/rygel/rygel-plugin.vala
+++ b/src/rygel/rygel-plugin.vala
@@ -33,6 +33,19 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
     private static const string MEDIA_SERVER_DESC_PATH =
                                 BuildConfig.DATA_DIR + "/xml/MediaServer2.xml";
 
+    private static const string ICON_BIG = "file://" +
+                                           BuildConfig.ICON_DIR +
+                                           "/256x256/apps/rygel.png";
+    private static const string ICON_SMALL = "file://" +
+                                             BuildConfig.ICON_DIR +
+                                             "/32x32/apps/rygel.png";
+    private static const string ICON_MIME = "image/png";
+    private static const int ICON_DEPTH = 32;
+    private static const int ICON_BIG_WIDTH = 256;
+    private static const int ICON_BIG_HEIGHT = 256;
+    private static const int ICON_SMALL_WIDTH = 32;
+    private static const int ICON_SMALL_HEIGHT = 32;
+
     public string name;
     public string title;
     public string description;
@@ -45,6 +58,8 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
     public ArrayList<ResourceInfo> resource_infos;
     public ArrayList<IconInfo> icon_infos;
 
+    public ArrayList<IconInfo> default_icons;
+
     public Plugin (string  desc_path,
                    string  name,
                    string? title,
@@ -62,6 +77,21 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
 
         this.resource_infos = new ArrayList<ResourceInfo> ();
         this.icon_infos = new ArrayList<IconInfo> ();
+        this.default_icons = new ArrayList<IconInfo> ();
+
+        var icon = new IconInfo (ICON_MIME);
+        icon.uri = ICON_BIG;
+        icon.width = ICON_BIG_WIDTH;
+        icon.height = ICON_BIG_HEIGHT;
+        icon.depth = ICON_DEPTH;
+        this.default_icons.add (icon);
+
+        icon = new IconInfo (ICON_MIME);
+        icon.uri = ICON_SMALL;
+        icon.width = ICON_SMALL_WIDTH;
+        icon.height = ICON_SMALL_HEIGHT;
+        icon.depth = ICON_DEPTH;
+        this.default_icons.add (icon);
     }
 
     public Plugin.MediaServer (string  name,
diff --git a/src/rygel/rygel-root-device-factory.vala b/src/rygel/rygel-root-device-factory.vala
index 1b1046f..4f928aa 100644
--- a/src/rygel/rygel-root-device-factory.vala
+++ b/src/rygel/rygel-root-device-factory.vala
@@ -228,10 +228,13 @@ internal class Rygel.RootDeviceFactory {
 
     private void add_icons_to_desc (Xml.Node *device_element,
                                     Plugin    plugin) {
-        if (plugin.icon_infos == null || plugin.icon_infos.size == 0) {
-            debug (_("No icon provided by %s."), plugin.name);
+        var icons = plugin.icon_infos;
 
-            return;
+        if (icons == null || icons.size == 0) {
+            debug (_("No icon provided by plugin '%s'. Using Rygel logo.."),
+                   plugin.name);
+
+            icons = plugin.default_icons;
         }
 
         Xml.Node *icon_list_node = Utils.get_xml_element (device_element,
@@ -244,8 +247,8 @@ internal class Rygel.RootDeviceFactory {
             icon_list_node->set_content ("");
         }
 
-        foreach (IconInfo icon_info in plugin.icon_infos) {
-            add_icon_to_desc (icon_list_node, icon_info, plugin);
+        foreach (var icon in icons) {
+            add_icon_to_desc (icon_list_node, icon, plugin);
         }
     }
 



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