[gnome-shell/wip/new-notfications: 7/14] messageTray: Remove support for notifications with images



commit d0c6182f734f7cbd04362fe158b25f517e6c0777
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Dec 4 22:45:44 2013 -0500

    messageTray: Remove support for notifications with images
    
    This sufficiently complicates the code, and won't fit in the
    new design.

 data/theme/gnome-shell.css  |    8 -----
 js/ui/messageTray.js        |   64 +------------------------------------------
 js/ui/notificationDaemon.js |    8 +-----
 3 files changed, 2 insertions(+), 78 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 1e0ec2a..97420ea 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -1495,14 +1495,6 @@ StScrollBar StButton#vhandle:active {
     height: 36px;
 }
 
-/* We use row-span = 2 for the image cell, which prevents its height preferences to be
-   taken into account during allocation, so its height ends up being limited by the height
-   of the content in the other rows. To avoid showing a stretched image, we set the minimum
-   height of the table to be ICON_SIZE + IMAGE_SIZE + spacing-rows = 24 + 125 + 10 = 159 */
-.notification-with-image {
-    min-height: 159px;
-}
-
 .summary-boxpointer {
     -arrow-border-radius: 15px;
     -arrow-background-color: rgba(0,0,0,0.9);
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 24880bb..52dfb0d 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -484,8 +484,6 @@ const Notification = new Lang.Class({
 
     ICON_SIZE: 24,
 
-    IMAGE_SIZE: 125,
-
     _init: function(source, title, banner, params) {
         this.source = source;
         this.title = title;
@@ -506,7 +504,6 @@ const Notification = new Lang.Class({
         this._titleDirection = Clutter.TextDirection.DEFAULT;
         this._spacing = 0;
         this._scrollPolicy = Gtk.PolicyType.AUTOMATIC;
-        this._imageBin = null;
         this._soundName = null;
         this._soundFile = null;
         this._soundPlayed = false;
@@ -538,14 +535,6 @@ const Notification = new Lang.Class({
                                            y_expand: false,
                                            y_fill: false });
 
-        // This is an empty cell that overlaps with this._bannerBox cell to ensure
-        // that this._bannerBox cell expands horizontally, while not forcing the
-        // this._imageBin that is also in col: 2 to expand horizontally.
-        this._table.add(new St.Bin(), { row: 0,
-                                        col: 2,
-                                        y_expand: false,
-                                        y_fill: false });
-
         this._titleLabel = new St.Label();
         this._bannerBox.add_actor(this._titleLabel);
         this._bannerUrlHighlighter = new URLHighlighter();
@@ -610,10 +599,8 @@ const Notification = new Lang.Class({
             this._actionArea = null;
             this._buttonBox = null;
         }
-        if (params.clear)
-            this.unsetImage();
 
-        if (!this._scrollArea && !this._actionArea && !this._imageBin)
+        if (!this._scrollArea && !this._actionArea)
             this._table.remove_style_class_name('multi-line-notification');
 
         if (params.gicon) {
@@ -702,7 +689,6 @@ const Notification = new Lang.Class({
                                                visible: this.expanded });
         this._table.add(this._scrollArea, { row: 1,
                                             col: 2 });
-        this._updateLastColumnSettings();
         this._contentArea = new St.BoxLayout({ style_class: 'notification-body',
                                                vertical: true });
         this._scrollArea.add_actor(this._contentArea);
@@ -783,53 +769,9 @@ const Notification = new Lang.Class({
 
         this._table.add_style_class_name('multi-line-notification');
         this._table.add(this._actionArea, props);
-        this._updateLastColumnSettings();
         this.updated();
     },
 
-    _updateLastColumnSettings: function() {
-        if (this._scrollArea)
-            this._table.child_set(this._scrollArea, { col: this._imageBin ? 2 : 1,
-                                                      col_span: this._imageBin ? 1 : 2 });
-        if (this._actionArea)
-            this._table.child_set(this._actionArea, { col: this._imageBin ? 2 : 1,
-                                                      col_span: this._imageBin ? 1 : 2 });
-    },
-
-    setImage: function(image) {
-        this.unsetImage();
-
-        if (!image)
-            return;
-
-        this._imageBin = new St.Bin({ opacity: 230,
-                                      child: image,
-                                      visible: this.expanded });
-
-        this._table.add_style_class_name('multi-line-notification');
-        this._table.add_style_class_name('notification-with-image');
-        this._addBannerBody();
-        this._updateLastColumnSettings();
-        this._table.add(this._imageBin, { row: 1,
-                                          col: 1,
-                                          row_span: 2,
-                                          x_expand: false,
-                                          y_expand: false,
-                                          x_fill: false,
-                                          y_fill: false });
-    },
-
-    unsetImage: function() {
-        if (this._imageBin) {
-            this._table.remove_style_class_name('notification-with-image');
-            this._table.remove_actor(this._imageBin);
-            this._imageBin = null;
-            this._updateLastColumnSettings();
-            if (!this._scrollArea && !this._actionArea)
-                this._table.remove_style_class_name('multi-line-notification');
-        }
-    },
-
     addButton: function(button, callback) {
         if (!this._buttonBox) {
             let box = new St.BoxLayout({ style_class: 'notification-actions' });
@@ -1046,8 +988,6 @@ const Notification = new Lang.Class({
         this.actor.remove_style_class_name('notification-unexpanded');
 
         // Show additional content that we keep hidden in banner mode
-        if (this._imageBin)
-            this._imageBin.show();
         if (this._actionArea)
             this._actionArea.show();
         if (this._scrollArea)
@@ -1086,8 +1026,6 @@ const Notification = new Lang.Class({
         this.expanded = false;
 
         // Hide additional content that we keep hidden in banner mode
-        if (this._imageBin)
-            this._imageBin.hide();
         if (this._actionArea)
             this._actionArea.hide();
         if (this._scrollArea)
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index a04ed35..37c59de 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -378,8 +378,6 @@ const FdoNotificationDaemon = new Lang.Class({
         let gicon = this._iconForNotificationData(icon, hints);
         let gimage = this._imageForNotificationData(hints);
 
-        let image = null;
-
         // If an icon is not specified, we use 'image-data' or 'image-path' hint for an icon
         // and don't show a large image. There are currently many applications that use
         // notify_notification_set_icon_from_pixbuf() from libnotify, which in turn sets
@@ -388,10 +386,7 @@ const FdoNotificationDaemon = new Lang.Class({
         // So the logic here does the right thing for this case. If both an icon and either
         // one of 'image-data' or 'image-path' are specified, we show both an icon and
         // a large image.
-        if (gicon && gimage)
-            image = new St.Icon({ gicon: gimage,
-                                  icon_size: notification.IMAGE_SIZE });
-        else if (!gicon && gimage)
+        if (!gicon && gimage)
             gicon = gimage;
         else if (!gicon)
             gicon = this._fallbackIconForNotificationData(hints);
@@ -401,7 +396,6 @@ const FdoNotificationDaemon = new Lang.Class({
                                              clear: true,
                                              soundFile: hints['sound-file'],
                                              soundName: hints['sound-name'] });
-        notification.setImage(image);
 
         let hasDefaultAction = false;
 


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