[gnome-shell] notification: be compatible with various names of the icon data hint



commit 68c482ec324fd908e6d9bece8399dcf9a71f4dae
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jan 19 16:30:01 2011 +0100

    notification: be compatible with various names of the icon data hint
    
    The hint changed its name during various iterations of the
    notification daemon spec; be compatible with all of them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=639959

 js/ui/notificationDaemon.js |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 0b377a8..6306279 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -146,9 +146,9 @@ NotificationDaemon.prototype = {
                 return new St.Icon({ icon_name: icon,
                                      icon_type: St.IconType.FULLCOLOR,
                                      icon_size: size });
-        } else if (hints.icon_data) {
+        } else if (hints['image-data']) {
             let [width, height, rowStride, hasAlpha,
-                 bitsPerSample, nChannels, data] = hints.icon_data;
+                 bitsPerSample, nChannels, data] = hints['image-data'];
             return textureCache.load_from_raw(data, data.length, hasAlpha,
                                               width, height, rowStride, size);
         } else {
@@ -238,6 +238,15 @@ NotificationDaemon.prototype = {
 
         hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
 
+        // Be compatible with the various hints for image data
+        // 'image-data' is the latest name of this hint, introduced in 1.2
+        if (!hints['image-data']) {
+            if (hints['image_data'])
+                hints['image-data'] = hints['image_data']; // version 1.1 of the spec
+            else if (hints['icon_data'])
+                hints['image-data'] = hints['icon_data']; // previous versions of the spec
+        }
+
         let ndata = { appName: appName,
                       icon: icon,
                       summary: summary,



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