[gnome-shell] [panel] Fix RTL for appMenu, allocation, other misc.



commit 347196d35caab7de26431b47722fc146400ed698
Author: Colin Walters <walters verbum org>
Date:   Mon Mar 1 11:30:31 2010 -0500

    [panel] Fix RTL for appMenu, allocation, other misc.
    
    Other misc includes:
    * Remove some unused CSS
    * Readd comments
    
    https://bugzilla.gnome.org/show_bug.cgi?id=611288

 data/theme/gnome-shell.css |    6 ------
 js/ui/panel.js             |   40 ++++++++++++++++++++++++++++------------
 2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index e038640..03bbaa3 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -117,12 +117,6 @@ StTooltip {
 }
 
 #appMenu {
-    spacing: 4px;
-}
-
-.app-menu-icon {
-    width: 24px;
-    height: 24px;
 }
 
 .panel-button {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index da56cb1..d4f3430 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -185,11 +185,11 @@ AppPanelMenu.prototype = {
 
     _getPreferredWidth: function(actor, forHeight, alloc) {
         let [minSize, naturalSize] = this._iconBox.get_preferred_width(forHeight);
-        alloc.min_size = Math.floor(minSize / 2);
-        alloc.natural_size = Math.floor(naturalSize / 2);
+        alloc.min_size = minSize;
+        alloc.natural_size = naturalSize;
         [minSize, naturalSize] = this._label.actor.get_preferred_width(forHeight);
-        alloc.min_size += minSize;
-        alloc.natural_size += naturalSize;
+        alloc.min_size = alloc.min_size + Math.max(0, minSize - Math.floor(alloc.min_size / 2));
+        alloc.natural_size = alloc.natural_size + Math.max(0, naturalSize - Math.floor(alloc.natural_size / 2));
     },
 
     _getPreferredHeight: function(actor, forWidth, alloc) {
@@ -210,20 +210,35 @@ AppPanelMenu.prototype = {
 
         let [minWidth, minHeight, naturalWidth, naturalHeight] = this._iconBox.get_preferred_size();
 
+        let direction = this.actor.get_direction();
+
         let yPadding = Math.floor(Math.max(0, allocHeight - naturalHeight) / 2);
-        childBox.x1 = 0;
         childBox.y1 = yPadding;
-        childBox.x2 = childBox.x1 + Math.min(naturalWidth, allocWidth);
-        childBox.y2 = childBox.y1 + Math.min(allocHeight, naturalHeight);
+        childBox.y2 = childBox.y1 + Math.min(naturalHeight, allocHeight);
+        if (direction == St.TextDirection.LTR) {
+            childBox.x1 = 0;
+            childBox.x2 = childBox.x1 + Math.min(naturalWidth, allocWidth);
+        } else {
+            childBox.x1 = Math.max(0, allocWidth - naturalWidth);
+            childBox.x2 = allocWidth;
+        }
         this._iconBox.allocate(childBox, flags);
 
+        let iconWidth = childBox.x2 - childBox.x1;
+
         let [minWidth, minHeight, naturalWidth, naturalHeight] = this._label.actor.get_preferred_size();
 
         yPadding = Math.floor(Math.max(0, allocHeight - naturalHeight) / 2);
-        childBox.x1 = Math.floor(childBox.x2 / 2);  // Pull in width of iconBox
         childBox.y1 = yPadding;
-        childBox.x2 = childBox.x1 + Math.min(naturalWidth, allocWidth);
-        childBox.y2 = childBox.y1 + Math.min(allocHeight, naturalHeight);
+        childBox.y2 = childBox.y1 + Math.min(naturalHeight, allocHeight);
+
+        if (direction == St.TextDirection.LTR) {
+            childBox.x1 = Math.floor(iconWidth / 2);
+            childBox.x2 = Math.min(childBox.x1 + naturalWidth, allocWidth);
+        } else {
+            childBox.x2 = allocWidth - Math.floor(iconWidth / 2);
+            childBox.x1 = Math.max(0, childBox.x2 - naturalWidth);
+        }
         this._label.actor.allocate(childBox, flags);
     },
 
@@ -273,9 +288,10 @@ AppPanelMenu.prototype = {
             // Because loading the texture is async, we may not have it yet.
             // If we don't, just create an empty one for now.
             if (faded == null)
-                faded = new Clutter.Texture({ width: AppDisplay.APPICON_SIZE,
-                                              height: AppDisplay.APPICON_SIZE });
+                faded = new Clutter.Texture({ width: this._sourceIcon.width,
+                                              height: this._sourceIcon.height });
             this._sourceIcon.connect('notify::cogl-texture', Lang.bind(this, function () {
+                // TODO should be caching this
                 faded = Shell.fade_app_icon(icon);
                 this._iconBox.set_child(faded);
             }));



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