[gnome-shell] More global-ization



commit d8cabbee0be2323fa44b1fd966b593393e358753
Author: Dan Winship <danw gnome org>
Date:   Fri Sep 11 17:23:23 2009 -0400

    More global-ization

 js/ui/appDisplay.js    |    6 ++----
 js/ui/appIcon.js       |    2 +-
 js/ui/docDisplay.js    |    2 +-
 js/ui/lookingGlass.js  |    4 +---
 js/ui/panel.js         |    2 +-
 js/ui/sidebar.js       |    7 -------
 js/ui/windowManager.js |   14 ++++++--------
 js/ui/workspaces.js    |    8 ++++----
 8 files changed, 16 insertions(+), 29 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index c12f575..39bf747 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -507,8 +507,6 @@ WellMenu.prototype = {
         }));
         this.actor.add_actor(this._arrow);
 
-        let stage = Shell.Global.get().stage;
-
         // Chain our visibility and lifecycle to that of the source
         source.actor.connect('notify::mapped', Lang.bind(this, function () {
             if (!source.actor.mapped)
@@ -516,7 +514,7 @@ WellMenu.prototype = {
         }));
         source.actor.connect('destroy', Lang.bind(this, function () { this.actor.destroy(); }));
 
-        stage.add_actor(this.actor);
+        global.stage.add_actor(this.actor);
     },
 
     _getPreferredWidth: function(actor, forHeight, alloc) {
@@ -568,7 +566,7 @@ WellMenu.prototype = {
             }
         }
 
-        let activeWorkspace = Shell.Global.get().screen.get_active_workspace();
+        let activeWorkspace = global.screen.get_active_workspace();
 
         let currentWorkspaceWindows = windows.filter(function (w) {
             return w.get_workspace() == activeWorkspace;
diff --git a/js/ui/appIcon.js b/js/ui/appIcon.js
index 6cc5fd9..5ca1cfd 100644
--- a/js/ui/appIcon.js
+++ b/js/ui/appIcon.js
@@ -58,7 +58,7 @@ AppIcon.prototype = {
                                         text: appInfo.get_name() });
         nameBox.add_actor(this._name);
         this._glowBox = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
-        let glowPath = GLib.filename_to_uri(Shell.Global.get().imagedir + 'app-well-glow.png', '');
+        let glowPath = GLib.filename_to_uri(global.imagedir + 'app-well-glow.png', '');
         for (let i = 0; i < this._windows.length && i < 3; i++) {
             let glow = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
                                                                           glowPath, -1, -1);
diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js
index dcb29ea..11f9039 100644
--- a/js/ui/docDisplay.js
+++ b/js/ui/docDisplay.js
@@ -102,7 +102,7 @@ DocDisplayItem.prototype = {
     _resetTimeDisplay: function(currentSecs) {
         let lastSecs = this._docInfo.timestamp;
         let timeDelta = currentSecs - lastSecs;
-        let [text, nextUpdate] = Shell.Global.get().format_time_relative_pretty(timeDelta);
+        let [text, nextUpdate] = global.format_time_relative_pretty(timeDelta);
         this._timeoutTime = currentSecs + nextUpdate;
         this._setDescriptionText(text);
     }
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 120af32..cd83b92 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -35,7 +35,6 @@ var commandHeader = "const Clutter = imports.gi.Clutter; " +
                     "const Tweener = imports.ui.tweener; " +
                     /* Utility functions...we should probably be able to use these
                      * in the shell core code too. */
-                    "const global = Shell.Global.get(); " +
                     "const stage = global.stage; " +
                     "const color = function(pixel) { let c= new Clutter.Color(); c.from_pixel(pixel); return c; }; " +
                     /* Special lookingGlass functions */
@@ -519,8 +518,7 @@ LookingGlass.prototype = {
     },
 
     _resizeTo: function(actor) {
-        let stage = Shell.Global.get().stage;
-        let stageWidth = stage.width;
+        let stage = global.stage;
         let myWidth = stage.width * 0.7;
         let myHeight = stage.height * 0.7;
         let [srcX, srcY] = actor.get_transformed_position();
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 3ef12c2..2fbc1d8 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -66,7 +66,7 @@ function AppPanelMenu() {
 
 AppPanelMenu.prototype = {
     _init: function() {
-        this._metaDisplay = Shell.Global.get().screen.get_display();
+        this._metaDisplay = global.screen.get_display();
 
         this._focusedApp = null;
         this._activeSequence = null;
diff --git a/js/ui/sidebar.js b/js/ui/sidebar.js
index 840b39e..9e2ebd3 100644
--- a/js/ui/sidebar.js
+++ b/js/ui/sidebar.js
@@ -21,13 +21,6 @@ const SIDEBAR_PADDING = 4;
 const SIDEBAR_COLLAPSED_WIDTH = Widget.COLLAPSED_WIDTH + 3 * WidgetBox.WIDGETBOX_PADDING + SIDEBAR_PADDING;
 const SIDEBAR_EXPANDED_WIDTH = Widget.EXPANDED_WIDTH + 3 * WidgetBox.WIDGETBOX_PADDING + SIDEBAR_PADDING;
 
-// The maximum height of the sidebar would be extending from just
-// below the panel to just above the taskbar. Since the taskbar is
-// just a temporary hack and it would be too hard to do this the right
-// way, we just hardcode its size.
-const HARDCODED_TASKBAR_HEIGHT = 24;
-const MAXIMUM_SIDEBAR_HEIGHT = Shell.Global.get().screen_height - Panel.PANEL_HEIGHT - HARDCODED_TASKBAR_HEIGHT;
-
 function Sidebar() {
     this._init();
 }
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index da03878..73303db 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -3,7 +3,6 @@
 const Clutter = imports.gi.Clutter;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
-const Shell = imports.gi.Shell;
 
 const AltTab = imports.ui.altTab;
 const Main = imports.ui.main;
@@ -19,8 +18,7 @@ WindowManager.prototype = {
     _init : function() {
         let me = this;
 
-        this._global = Shell.Global.get();
-        this._shellwm = this._global.window_manager;
+        this._shellwm = global.window_manager;
         this._minimizing = [];
         this._maximizing = [];
         this._unmaximizing = [];
@@ -255,20 +253,20 @@ WindowManager.prototype = {
         if (direction == Meta.MotionDirection.UP ||
             direction == Meta.MotionDirection.UP_LEFT ||
             direction == Meta.MotionDirection.UP_RIGHT)
-                yDest = this._global.screen_height;
+                yDest = global.screen_height;
         else if (direction == Meta.MotionDirection.DOWN ||
             direction == Meta.MotionDirection.DOWN_LEFT ||
             direction == Meta.MotionDirection.DOWN_RIGHT)
-                yDest = -this._global.screen_height;
+                yDest = -global.screen_height;
 
         if (direction == Meta.MotionDirection.LEFT ||
             direction == Meta.MotionDirection.UP_LEFT ||
             direction == Meta.MotionDirection.DOWN_LEFT)
-                xDest = this._global.screen_width;
+                xDest = global.screen_width;
         else if (direction == Meta.MotionDirection.RIGHT ||
                  direction == Meta.MotionDirection.UP_RIGHT ||
                  direction == Meta.MotionDirection.DOWN_RIGHT)
-                xDest = -this._global.screen_width;
+                xDest = -global.screen_width;
 
         let switchData = {};
         this._switchData = switchData;
@@ -276,7 +274,7 @@ WindowManager.prototype = {
         switchData.outGroup = new Clutter.Group();
         switchData.windows = [];
 
-        let wgroup = this._global.window_group;
+        let wgroup = global.window_group;
         wgroup.add_actor(switchData.inGroup);
         wgroup.add_actor(switchData.outGroup);
 
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index 5bd33a9..39c48b5 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -1102,7 +1102,7 @@ Workspaces.prototype = {
             }
         }
         activeWorkspace.actor.raise_top();
-        this._positionWorkspaces(global);
+        this._positionWorkspaces();
 
         let lastWorkspace = this._workspaces[this._workspaces.length - 1];
         lastWorkspace.updateRemovable(true);
@@ -1196,7 +1196,7 @@ Workspaces.prototype = {
         let activeWorkspaceIndex = global.screen.get_active_workspace_index();
         let activeWorkspace = this._workspaces[activeWorkspaceIndex];
 
-        this._positionWorkspaces(global);
+        this._positionWorkspaces();
         activeWorkspace.actor.raise_top();
 
         for (let w = 0; w < this._workspaces.length; w++)
@@ -1237,7 +1237,7 @@ Workspaces.prototype = {
     // first row.)
     //
     // FIXME: need to make the metacity internal layout agree with this!
-    _positionWorkspaces : function(global) {
+    _positionWorkspaces : function() {
         let gridWidth = Math.ceil(Math.sqrt(this._workspaces.length));
         let gridHeight = Math.ceil(this._workspaces.length / gridWidth);
 
@@ -1307,7 +1307,7 @@ Workspaces.prototype = {
         newLastWorkspace.updateRemovable();
 
         // Figure out the new layout
-        this._positionWorkspaces(global);
+        this._positionWorkspaces();
         let newScale = this._workspaces[0].scale;
         let newGridWidth = Math.ceil(Math.sqrt(newNumWorkspaces));
         let newGridHeight = Math.ceil(newNumWorkspaces / newGridWidth);



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