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



commit f9a18ce4d9f3a772d8b6cdd09210ecc4f14f7a80
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 c14709c..36d1f24 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -316,10 +316,6 @@ StTooltip {
 }
 
 .workspaces-bar {
-    height: 48px;
-}
-
-.workspaces-bar {
     spacing: 5px;
 }
 
@@ -384,14 +380,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 d7deab0..373fd04 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -692,14 +692,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;
@@ -801,7 +810,7 @@ SingleView.prototype = {
 
         this._computeWorkspacePositions();
         this._updateWorkspaceActors(showAnimation);
-        this._scrollScrollBarToIndex(active, showAnimation);
+        this._updateScrollAdjustment(active, showAnimation);
     },
 
     // _setWorkspaceDraggable:
@@ -876,7 +885,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
@@ -907,7 +916,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();
 
@@ -1079,14 +1088,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',
@@ -1096,7 +1105,7 @@ SingleView.prototype = {
                    })
             });
         } else {
-            this._scroll.adjustment.value = index;
+            this._scrollAdjustment.value = index;
             this._animatingScroll = false;
         }
     },
@@ -1107,12 +1116,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++) {
@@ -1130,12 +1138,9 @@ SingleView.prototype = {
         }
 
         this._scrollToActive(true);
-        this._updatePanelVisibility();
     },
 
     _activeWorkspaceChanged: function(wm, from, to, direction) {
-        this._updatePanelVisibility();
-
         if (this._scrolling)
             return;
 
@@ -1170,7 +1175,7 @@ SingleView.prototype = {
     },
 
     _dragBegin: function() {
-        if (!this._scroll || this._scrolling)
+        if (this._scrolling)
             return;
 
         this._inDrag = true;
@@ -1274,8 +1279,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)
@@ -1286,20 +1290,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;
@@ -1307,8 +1298,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;
 
@@ -1322,12 +1311,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:
@@ -1354,37 +1337,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());
@@ -1399,26 +1351,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]