[gnome-shell] [panel] Ellipsize long application titles, don't push clock around



commit 01c493565f33bd4088e2889b2779faf53b5f0032
Author: Colin Walters <walters verbum org>
Date:   Tue May 25 10:21:22 2010 -0400

    [panel] Ellipsize long application titles, don't push clock around
    
    First, simply set the ellipsize flag on the application menu labels.
    Next, rework how we lay out the panel components so that the center
    box is always centered and constrains the left and right, rather
    than pushing it around.
    
    Previously, as part of making the shell not obviously explode if
    one had a lot of tray icons, we allowed them to push the clock over.
    Instead, go back to just failing in this case; we need to exile legacy
    tray icons, not be slightly less ugly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=592640

 js/ui/panel.js |   37 ++++++++++---------------------------
 1 files changed, 10 insertions(+), 27 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 1104645..0e52148 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -6,6 +6,7 @@ const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
+const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Tweener = imports.ui.tweener;
@@ -56,6 +57,7 @@ TextShadower.prototype = {
         this.actor.add_actor(this._label);
         for (let i = 0; i < 4; i++) {
             let actor = new St.Label({ style_class: 'label-shadow' });
+            actor.clutter_text.ellipsize = Pango.EllipsizeMode.END;
             this.actor.add_actor(actor);
         }
         this._label.raise_top();
@@ -838,44 +840,25 @@ Panel.prototype = {
             let [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1);
             let [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1);
             let [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_width(-1);
-            let leftWidth, centerWidth, rightWidth;
-            if (allocWidth < (leftNaturalWidth + centerNaturalWidth + rightNaturalWidth)) {
-                leftWidth = leftMinWidth;
-                centerWidth = centerMinWidth;
-                rightWidth = rightMinWidth;
-            } else {
-                leftWidth = leftNaturalWidth;
-                centerWidth = centerNaturalWidth;
-                rightWidth = rightNaturalWidth;
-            }
 
-            let x;
+            let sideWidth, centerWidth;
+            centerWidth = centerNaturalWidth;
+            sideWidth = (allocWidth - centerWidth) / 2;
+
             let childBox = new Clutter.ActorBox();
             childBox.x1 = 0;
             childBox.y1 = 0;
-            childBox.x2 = x = childBox.x1 + leftWidth;
+            childBox.x2 = childBox.x1 + Math.floor(sideWidth);
             childBox.y2 = allocHeight;
             this._leftBox.allocate(childBox, flags);
 
-            let centerNaturalX = Math.floor(allocWidth / 2 - (centerWidth / 2));
-            /* Check left side */
-            if (x < centerNaturalX) {
-                /* We didn't overflow the left, use the natural. */
-                x = centerNaturalX;
-            }
-            /* Check right side */
-            if (x + centerWidth > (allocWidth - rightWidth)) {
-                x = allocWidth - rightWidth - centerWidth;
-            }
-            childBox = new Clutter.ActorBox();
-            childBox.x1 = x;
+            childBox.x1 = Math.ceil(sideWidth);
             childBox.y1 = 0;
-            childBox.x2 = x = childBox.x1 + centerWidth;
+            childBox.x2 = childBox.x1 + centerWidth;
             childBox.y2 = allocHeight;
             this._centerBox.allocate(childBox, flags);
 
-            childBox = new Clutter.ActorBox();
-            childBox.x1 = allocWidth - rightWidth;
+            childBox.x1 = allocWidth - Math.min(Math.floor(sideWidth), rightNaturalWidth);
             childBox.y1 = 0;
             childBox.x2 = allocWidth;
             childBox.y2 = allocHeight;



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