[gnome-shell] Add icon buttons to notifications



commit d1e1afdaab41f37cf7d1179e6395b8ab09eb91d8
Author: Matt Novenstern <fisxoj gmail com>
Date:   Fri Jun 11 23:19:18 2010 +0200

    Add icon buttons to notifications
    
    Now if an id is passed to Notification.addButton that matches a theme icon,
    it will be displayed as an icon.  This is another in the implement the
    music player mockups series.
    http://live.gnome.org/GnomeShell/Design/Guidelines/MessageTray/MusicPlayer
    
    https://bugzilla.gnome.org/show_bug.cgi?id=621014

 data/theme/gnome-shell.css  |   13 +++++++++++++
 js/ui/messageTray.js        |   13 +++++++++++--
 js/ui/notificationDaemon.js |    3 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 24ac579..766ff8e 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -860,6 +860,19 @@ StTooltip {
     background: #808080;
 }
 
+.notification-icon-button {
+    border: 2px rgba(0,0,0,0.0);
+    border-radius: 5px;
+    padding: 5px;
+}
+.notification-icon-button:hover {
+    background: rgba(192,192,192,0.7);
+}
+
+.notification-icon-button:active {
+    background:  rgba(128,128,128,0.7);
+}
+
 .chat-received {
     background-gradient-direction: horizontal;
     background-gradient-start: #606060;
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 7ff36cd..7141501 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -19,6 +19,7 @@ const SUMMARY_TIMEOUT = 1;
 const HIDE_TIMEOUT = 0.2;
 
 const ICON_SIZE = 24;
+const BUTTON_ICON_SIZE = 36;
 
 const MAX_SOURCE_TITLE_WIDTH = 180;
 
@@ -262,8 +263,16 @@ Notification.prototype = {
             this._buttonBox = box;
         }
 
-        let button = new St.Button({ style_class: 'notification-button',
-                                     label: label });
+        let button = new St.Button();
+
+        if (Gtk.IconTheme.get_default().has_icon(id)) {
+            button.add_style_class_name('notification-icon-button');
+            button.child = St.TextureCache.get_default().load_icon_name(id, BUTTON_ICON_SIZE);
+        } else {
+            button.add_style_class_name('notification-button');
+            button.label = label;
+        }
+
         this._buttonBox.add(button);
         button.connect('clicked', Lang.bind(this, function() { this.emit('action-invoked', id); }));
     },
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index da3c929..026fb04 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -245,8 +245,9 @@ NotificationDaemon.prototype = {
             // 'body-images',
             'body-markup',
             // 'icon-multi',
-            'icon-static'
+            'icon-static',
             // 'sound',
+            'x-gnome-icon-buttons'
         ];
     },
 



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