[gnome-shell/overview-relayout: 13/18] workspaces-view: Swap workspace ordering for RTL locales
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/overview-relayout: 13/18] workspaces-view: Swap workspace ordering for RTL locales
- Date: Fri, 12 Nov 2010 20:49:09 +0000 (UTC)
commit 509dfbaa1ad6a35b3fc4e1dd7a5b659d99d5366e
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 12 13:32:06 2010 +0100
workspaces-view: Swap workspace ordering for RTL locales
Make the first workspace the right-most one in RTL locales, as one
would expect. Update all dragging/scrolling functions to behave
correctly.
js/ui/workspacesView.js | 55 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 42 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 1bd0f19..febdcff 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -431,8 +431,13 @@ WorkspacesView.prototype = {
workspace.opacity = (this._inDrag && w != active) ? 200 : 255;
workspace.scale = scale;
- workspace.x = this._x + this._activeWorkspaceX
- + (w - active) * (_width + this._spacing);
+ if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
+ workspace.x = this._x + this._activeWorkspaceX
+ - (w - active) * (_width + this._spacing);
+ } else {
+ workspace.x = this._x + this._activeWorkspaceX
+ + (w - active) * (_width + this._spacing);
+ }
workspace.y = this._y + this._activeWorkspaceY;
}
},
@@ -524,10 +529,17 @@ WorkspacesView.prototype = {
// of 0 or 1 millisecond indicates that the mouse is in motion, a larger
// difference indicates that the mouse is stopped.
if ((this._lastMotionTime > 0 && this._lastMotionTime > event.get_time() - 2) || noStop) {
- if (stageX > this._dragStartX && activate > 0)
- activate--;
- else if (stageX < this._dragStartX && activate < last)
- activate++;
+ if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
+ if (stageX < this._dragStartX && activate > 0)
+ activate--;
+ else if (stageX > this._dragStartX && activate < last)
+ activate++;
+ } else {
+ if (stageX > this._dragStartX && activate > 0)
+ activate--;
+ else if (stageX < this._dragStartX && activate < last)
+ activate++;
+ }
}
if (activate != active) {
@@ -548,7 +560,10 @@ WorkspacesView.prototype = {
let dx = this._dragX - stageX;
let primary = global.get_primary_monitor();
- this._scrollAdjustment.value += (dx / primary.width);
+ if (St.Widget.get_default_direction() == St.TextDirection.RTL)
+ this._scrollAdjustment.value -= (dx / primary.width);
+ else
+ this._scrollAdjustment.value += (dx / primary.width);
this._dragX = stageX;
this._lastMotionTime = event.get_time();
@@ -767,8 +782,14 @@ WorkspacesView.prototype = {
let primary = global.get_primary_monitor();
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
- let leftWorkspace = this._workspaces[activeWorkspaceIndex - 1];
- let rightWorkspace = this._workspaces[activeWorkspaceIndex + 1];
+ let leftWorkspace, rightWorkspace;
+ if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
+ leftWorkspace = this._workspaces[activeWorkspaceIndex + 1];
+ rightWorkspace = this._workspaces[activeWorkspaceIndex - 1];
+ } else {
+ leftWorkspace = this._workspaces[activeWorkspaceIndex - 1];
+ rightWorkspace = this._workspaces[activeWorkspaceIndex + 1];
+ }
let hoverWorkspace = null;
// reactive monitor edges
@@ -886,13 +907,21 @@ WorkspacesView.prototype = {
// manage the animation
_onScrollEvent: function(actor, event) {
let direction = event.get_scroll_direction();
+ let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
let current = global.screen.get_active_workspace_index();
let last = global.screen.n_workspaces - 1;
let activate = current;
- if (direction == Clutter.ScrollDirection.DOWN && current < last)
- activate++;
- else if (direction == Clutter.ScrollDirection.UP && current > 0)
- activate--;
+ if (direction == Clutter.ScrollDirection.DOWN) {
+ if (rtl && current > 0)
+ activate--;
+ else if (!rtl && current < last)
+ activate++;
+ } else if (direction == Clutter.ScrollDirection.UP) {
+ if (rtl && current < last)
+ activate++;
+ else if (!rtl && current > 0)
+ activate--;
+ }
if (activate != current) {
let metaWorkspace = this._workspaces[activate].metaWorkspace;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]