[gnome-shell/overview-relayout: 1/18] linear-view: Remove the scrollbar



commit ca1c0fca45890cc59d5b1e4139a5ef9c96d95d79
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Jul 11 14:41:17 2010 +0200

    linear-view: Remove the scrollbar
    
    The scrollbar is the main culprit for cluttered controls in the
    linear view - all its functionality is already provided by the
    workspace indicators, so it is save to remove the scrollbar in
    order to clean up the interface.

 data/theme/gnome-shell.css |   12 -----
 js/ui/workspacesView.js    |  119 ++++++++++----------------------------------
 2 files changed, 27 insertions(+), 104 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index ee5b14e..b54fc32 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -308,10 +308,6 @@ StTooltip {
 }
 
 .workspaces-bar {
-    height: 48px;
-}
-
-.workspaces-bar {
     spacing: 5px;
 }
 
@@ -376,14 +372,6 @@ StTooltip {
     background-image: url("mosaic-view-active.svg");
 }
 
-#SwitchScroll {
-    height: 14px;
-}
-
-#SwitchScroll #hhandle {
-    border-radius: 7px;
-}
-
 /* Dash */
 
 #dash {
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 91a15c9..19b77f8 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -691,14 +691,23 @@ SingleView.prototype = {
         this.actor.set_clip(x, y, width, height);
         this._activeWorkspaceX = 0; // x offset of active ws while dragging
         this._activeWorkspaceY = 0; // y offset of active ws while dragging
-        this._scroll = null;
         this._lostWorkspaces = [];
         this._animating = false; // tweening
-        this._scrolling = false; // dragging scroll bar or desktop
-        this._animatingScroll = false; // programatically move the scroll bar
+        this._scrolling = false; // dragging desktop
+        this._animatingScroll = false; // programatically update the adjustment
         this._inDrag = false; // dragging a window
         this._lastMotionTime = -1; // used to track "stopping" while dragging workspaces
 
+        let active = global.screen.get_active_workspace_index();
+        this._scrollAdjustment = new St.Adjustment({ value: active,
+                                                     lower: 0,
+                                                     page_increment: 1,
+                                                     page_size: 1,
+                                                     step_increment: 0,
+                                                     upper: this._workspaces.length });
+        this._scrollAdjustment.connect('notify::value',
+                                       Lang.bind(this, this._onScroll));
+
         this._dragIndex = -1;
 
         this._buttonPressId = 0;
@@ -800,7 +809,7 @@ SingleView.prototype = {
 
         this._computeWorkspacePositions();
         this._updateWorkspaceActors(showAnimation);
-        this._scrollScrollBarToIndex(active, showAnimation);
+        this._updateScrollAdjustment(active, showAnimation);
     },
 
     // _setWorkspaceDraggable:
@@ -875,7 +884,7 @@ SingleView.prototype = {
                 // If the user has moved more than half a workspace, we want to "settle"
                 // to the new workspace even if the user stops dragging rather "throws"
                 // by releasing during the drag.
-                let noStop = Math.abs(activate - this._scroll.adjustment.value) > 0.5;
+                let noStop = Math.abs(activate - this._scrollAdjustment.value) > 0.5;
 
                 // We detect if the user is stopped by comparing the timestamp of the button
                 // release with the timestamp of the last motion. Experimentally, a difference
@@ -906,7 +915,7 @@ SingleView.prototype = {
                 let dx = this._dragX - stageX;
                 let primary = global.get_primary_monitor();
 
-                this._scroll.adjustment.value += (dx / primary.width);
+                this._scrollAdjustment.value += (dx / primary.width);
                 this._dragX = stageX;
                 this._lastMotionTime = event.get_time();
 
@@ -1078,14 +1087,14 @@ SingleView.prototype = {
         this._updateWorkspaceActors(false);
     },
 
-    _scrollScrollBarToIndex: function(index, showAnimation) {
-        if (!this._scroll || this._scrolling)
+    _updateScrollAdjustment: function(index, showAnimation) {
+        if (this._scrolling)
             return;
 
         this._animatingScroll = true;
 
         if (showAnimation) {
-            Tweener.addTween(this._scroll.adjustment, {
+            Tweener.addTween(this._scrollAdjustment, {
                value: index,
                time: WORKSPACE_SWITCH_TIME,
                transition: 'easeOutQuad',
@@ -1095,7 +1104,7 @@ SingleView.prototype = {
                    })
             });
         } else {
-            this._scroll.adjustment.value = index;
+            this._scrollAdjustment.value = index;
             this._animatingScroll = false;
         }
     },
@@ -1106,12 +1115,11 @@ SingleView.prototype = {
         for (let l = 0; l < lostWorkspaces.length; l++)
             lostWorkspaces[l].disconnectAll();
 
-        if (this._scroll != null)
-            Tweener.addTween(this._scroll.adjustment,
-                             { upper: newNumWorkspaces,
-                               time: WORKSPACE_SWITCH_TIME,
-                               transition: 'easeOutQuad'
-                             });
+        Tweener.addTween(this._scrollAdjustment,
+                         { upper: newNumWorkspaces,
+                           time: WORKSPACE_SWITCH_TIME,
+                           transition: 'easeOutQuad'
+                         });
 
         if (newNumWorkspaces > oldNumWorkspaces) {
             for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
@@ -1129,12 +1137,9 @@ SingleView.prototype = {
         }
 
         this._scrollToActive(true);
-        this._updatePanelVisibility();
     },
 
     _activeWorkspaceChanged: function(wm, from, to, direction) {
-        this._updatePanelVisibility();
-
         if (this._scrolling)
             return;
 
@@ -1169,7 +1174,7 @@ SingleView.prototype = {
     },
 
     _dragBegin: function() {
-        if (!this._scroll || this._scrolling)
+        if (this._scrolling)
             return;
 
         this._inDrag = true;
@@ -1273,8 +1278,7 @@ SingleView.prototype = {
             this._workspaces[i].setReservedSlot(null);
     },
 
-    // handle changes to the scroll bar's adjustment:
-    // sync the workspaces' positions to the position of the scroll bar handle
+    // sync the workspaces' positions to the value of the scroll adjustment
     // and change the active workspace if appropriate
     _onScroll: function(adj) {
         if (this._animatingScroll)
@@ -1285,20 +1289,7 @@ SingleView.prototype = {
 
         if (active != current) {
             let metaWorkspace = this._workspaces[current].metaWorkspace;
-
-            if (!this._scrolling) {
-                // This here is a little tricky - we get here when StScrollBar
-                // animates paging; we switch the active workspace, but
-                // leave out any extra animation (just like we would do when
-                // the handle was dragged)
-                // If StScrollBar emitted scroll-start before and scroll-stop
-                // after the animation, this would not be necessary
-                this._scrolling = true;
-                metaWorkspace.activate(global.get_current_time());
-                this._scrolling = false;
-            } else {
-                metaWorkspace.activate(global.get_current_time());
-            }
+            metaWorkspace.activate(global.get_current_time());
         }
 
         let last = this._workspaces.length - 1;
@@ -1306,8 +1297,6 @@ SingleView.prototype = {
         let lastWorkspaceX = this._workspaces[last].actor.x;
         let workspacesWidth = lastWorkspaceX - firstWorkspaceX;
 
-        // The scrollbar is hidden when there is only one workspace, so
-        // adj.upper should at least be 2 - but better be safe than sorry
         if (adj.upper == 1)
             return;
 
@@ -1321,12 +1310,6 @@ SingleView.prototype = {
             this._workspaces[i].actor.visible = Math.abs(i - adj.value) <= 1;
             this._workspaces[i].actor.x += dx;
         }
-
-        if (!this._scrolling && active == adj.value) {
-            // Again, work around the paging in StScrollBar: simulate
-            // the effect of scroll-stop
-            this._updateWorkspaceActors(false);
-        }
     },
 
     // handle scroll wheel events:
@@ -1353,37 +1336,6 @@ SingleView.prototype = {
                                        pack_start: true,
                                        vertical: true });
 
-        let active = global.screen.get_active_workspace_index();
-        let adj = new St.Adjustment({ value: active,
-                                      lower: 0,
-                                      page_increment: 1,
-                                      page_size: 1,
-                                      step_increment: 0,
-                                      upper: this._workspaces.length });
-        this._scroll = new St.ScrollBar({ adjustment: adj,
-                                          vertical: false,
-                                          name: 'SwitchScroll' });
-
-        // we have set adj.step_increment to 0, so all scroll wheel events
-        // are processed with this handler - this allows us to animate the
-        // workspace switch
-        this._scroll.connect('scroll-event',
-            Lang.bind(this, this._onScrollEvent));
-
-        this._scroll.adjustment.connect('notify::value',
-            Lang.bind(this, this._onScroll));
-
-
-        this._scroll.connect('scroll-start', Lang.bind(this,
-            function() {
-                this._scrolling = true;
-            }));
-        this._scroll.connect('scroll-stop', Lang.bind(this,
-            function() {
-                this._scrolling = false;
-                this._scrollToActive(true);
-            }));
-
         let indicator = new WorkspaceIndicator(Lang.bind(this, function(i) {
             if (this._workspaces[i] != undefined)
                 this._workspaces[i].metaWorkspace.activate(global.get_current_time());
@@ -1398,26 +1350,9 @@ SingleView.prototype = {
         }), Lang.bind(this, this._onScrollEvent));
 
         actor.add(indicator.actor, { expand: true, x_fill: true, y_fill: true });
-        actor.add(this._scroll, { expand: true,
-                                  x_fill: true,
-                                  y_fill: false,
-                                  y_align: St.Align.START });
-
-        this._updatePanelVisibility();
-
         return actor;
     },
 
-    _updatePanelVisibility: function() {
-        let showSwitches = (global.screen.n_workspaces > 1);
-        if (this._scroll != null) {
-            Tweener.addTween(this._scroll,
-                             { opacity: showSwitches ? 255 : 0,
-                               time: WORKSPACE_SWITCH_TIME,
-                               transition: 'easeOutQuad' });
-        }
-    },
-
     addWorkspace: function() {
         let ws = GenericWorkspacesView.prototype.addWorkspace.call(this);
         if (ws != null)



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