[gnome-shell] Make "global" global.



commit d0d79c5b3ee6edc0bc7d55f5ba2c8a3b5df96286
Author: Dan Winship <danw gnome org>
Date:   Tue Sep 8 16:12:50 2009 -0400

    Make "global" global.
    
    Rather than doing "let global = Shell.Global.get()" everywhere we
    need it, just create a global variable called "global".
    
    http://bugzilla.gnome.org/show_bug.cgi?id=594546

 js/ui/altTab.js         |    6 ------
 js/ui/appDisplay.js     |    2 --
 js/ui/chrome.js         |    4 ----
 js/ui/dash.js           |    6 ------
 js/ui/genericDisplay.js |    2 --
 js/ui/lookingGlass.js   |    6 ------
 js/ui/main.js           |   11 ++++-------
 js/ui/overview.js       |   12 ------------
 js/ui/panel.js          |    2 --
 js/ui/runDialog.js      |    5 -----
 js/ui/sidebar.js        |    2 --
 js/ui/widget.js         |    1 -
 js/ui/workspaces.js     |   27 ---------------------------
 13 files changed, 4 insertions(+), 82 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 745d0dc..3dfcac6 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -36,8 +36,6 @@ function AltTabPopup() {
 
 AltTabPopup.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
         this.actor = new Big.Box({ background_color : POPUP_BG_COLOR,
                                    corner_radius: POPUP_GRID_SPACING,
                                    padding: POPUP_GRID_SPACING,
@@ -140,8 +138,6 @@ AltTabPopup.prototype = {
     },
 
     show : function(initialSelection) {
-        let global = Shell.Global.get();
-
         global.window_group.add_actor(this._overlay);
         this._overlay.raise_top();
         this._overlay.show();
@@ -234,8 +230,6 @@ AltTabPopup.prototype = {
     },
 
     _adjust_overlay : function() {
-        let global = Shell.Global.get();
-
         if (this._selected && this._selected.icon_rect) {
             // We want to highlight a specific rectangle within the
             // task bar, so rearrange the pieces of the overlay to
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 36279f9..f6316ce 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1089,8 +1089,6 @@ AppWell.prototype = {
 
     // Draggable target interface
     acceptDrop : function(source, actor, x, y, time) {
-        let global = Shell.Global.get();
-
         let appSystem = Shell.AppSystem.get_default();
 
         let app = null;
diff --git a/js/ui/chrome.js b/js/ui/chrome.js
index 80c62aa..e5cf650 100644
--- a/js/ui/chrome.js
+++ b/js/ui/chrome.js
@@ -18,8 +18,6 @@ function Chrome() {
 
 Chrome.prototype = {
     _init: function() {
-        let global = Shell.Global.get();
-
         // The group itself has zero size so it doesn't interfere with DND
         this.actor = new Clutter.Group({ width: 0, height: 0 });
         global.stage.add_actor(this.actor);
@@ -238,7 +236,6 @@ Chrome.prototype = {
     },
 
     _windowsRestacked: function() {
-        let global = Shell.Global.get();
         let windows = global.get_windows();
 
         // The chrome layer should be visible unless there is a window
@@ -280,7 +277,6 @@ Chrome.prototype = {
     },
 
     _updateRegions: function() {
-        let global = Shell.Global.get();
         let rects = [], struts = [], i;
 
         delete this._updateRegionIdle;
diff --git a/js/ui/dash.js b/js/ui/dash.js
index 1b4b6a9..db40361 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -92,7 +92,6 @@ Pane.prototype = {
         let chromeTop = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
                                       spacing: 6 });
 
-        let global = Shell.Global.get();
         let closeIconUri = "file://" + global.imagedir + "close.svg";
         let closeIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
                                                                        closeIconUri,
@@ -288,7 +287,6 @@ SearchEntry.prototype = {
                                       padding_right: 4 });
         box.append(this._iconBox, Big.BoxPackFlags.END);
 
-        let global = Shell.Global.get();
         let magnifierUri = "file://" + global.imagedir + "magnifier.svg";
         this._magnifierIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
                                                                              magnifierUri, 18, 18);
@@ -408,7 +406,6 @@ BackLink.prototype = {
                                            border_right: SECTION_BORDER,
                                            border_color: SECTION_BORDER_COLOR });
 
-        let global = Shell.Global.get();
         let backIconUri = "file://" + global.imagedir + "back.svg";
         let backIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
                                                                       backIconUri,
@@ -557,8 +554,6 @@ function Dash() {
 
 Dash.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
         // dash and the popup panes need to be reactive so that the clicks in unoccupied places on them
         // are not passed to the transparent background underneath them. This background is used for the workspaces area when
         // the additional dash panes are being shown and it handles clicks by closing the additional panes, so that the user
@@ -786,7 +781,6 @@ Dash.prototype = {
     },
 
     show: function() {
-        let global = Shell.Global.get();
         global.stage.set_key_focus(this._searchEntry.entry);
     },
 
diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js
index 2ebdf8c..219bf0e 100644
--- a/js/ui/genericDisplay.js
+++ b/js/ui/genericDisplay.js
@@ -88,7 +88,6 @@ GenericDisplayItem.prototype = {
                                        spacing: DEFAULT_PADDING });
         this._infoContent.append(this._infoText, Big.BoxPackFlags.EXPAND);
 
-        let global = Shell.Global.get();
         let infoIconUri = "file://" + global.imagedir + "info.svg";
         let infoIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
                                                                       infoIconUri,
@@ -502,7 +501,6 @@ GenericDisplay.prototype = {
         Mainloop.idle_add(Lang.bind(this,
                                     function() {
                                         let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer();
-                                        let global = Shell.Global.get();
                                         let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE,
                                                                                   x, y);
                                         if (actor != null) {
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 57f2a23..dab0f52 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -249,7 +249,6 @@ function Inspector() {
 
 Inspector.prototype = {
     _init: function() {
-        let global = Shell.Global.get();
         let width = 150;
         let eventHandler = new Big.Box({ background_color: LG_BACKGROUND_COLOR,
                                          border: 1,
@@ -274,7 +273,6 @@ Inspector.prototype = {
         }));
 
         eventHandler.connect('button-press-event', Lang.bind(this, function (actor, event) {
-            let global = Shell.Global.get();
             Clutter.ungrab_pointer(eventHandler);
 
             let [stageX, stageY] = event.get_coords();
@@ -288,7 +286,6 @@ Inspector.prototype = {
         }));
 
         eventHandler.connect('motion-event', Lang.bind(this, function (actor, event) {
-            let global = Shell.Global.get();
             let [stageX, stageY] = event.get_coords();
             let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
                                                        stageX,
@@ -312,8 +309,6 @@ function LookingGlass() {
 
 LookingGlass.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
         this._idleHistorySaveId = 0;
         let historyPath = global.configdir + "/lookingglass-history.txt";
         this._historyFile = Gio.file_new_for_path(historyPath);
@@ -558,7 +553,6 @@ LookingGlass.prototype = {
         if (!Main.beginModal())
             return;
 
-        let global = Shell.Global.get();
         global.stage.set_key_focus(this._entry);
 
         Tweener.addTween(this.actor, { time: 0.5,
diff --git a/js/ui/main.js b/js/ui/main.js
index 8c000e7..c331410 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -33,7 +33,10 @@ let recorder = null;
 let inModal = false;
 
 function start() {
-    let global = Shell.Global.get();
+    // Add a binding for "global" in the global JS namespace; (gjs
+    // keeps the web browser convention of having that namespace be
+    // called "window".)
+    window.global = Shell.Global.get();
 
     Gio.DesktopAppInfo.set_desktop_env("GNOME");
 
@@ -102,7 +105,6 @@ function start() {
 }
 
 function _relayout() {
-    let global = Shell.Global.get();
     panel.actor.set_size(global.screen_width, Panel.PANEL_HEIGHT);
     overview.relayout();
 }
@@ -114,8 +116,6 @@ function _relayout() {
 // is called.)
 function _removeUnusedWorkspaces() {
 
-    let global = Shell.Global.get();
-
     let windows = global.get_windows();
     let maxWorkspace = 0;
     for (let i = 0; i < windows.length; i++) {
@@ -187,7 +187,6 @@ function _globalKeyPressHandler(actor, event) {
 // the stage. Returns true if we successfully grabbed the keyboard and
 // went modal, false otherwise
 function beginModal() {
-    let global = Shell.Global.get();
     let timestamp = global.screen.get_display().get_current_time();
 
     if (!global.begin_modal(timestamp))
@@ -200,7 +199,6 @@ function beginModal() {
 }
 
 function endModal() {
-    let global = Shell.Global.get();
     let timestamp = global.screen.get_display().get_current_time();
 
     global.end_modal(timestamp);
@@ -217,7 +215,6 @@ function createLookingGlass() {
 }
 
 function createAppLaunchContext() {
-    let global = Shell.Global.get();
     let screen = global.screen;
     let display = screen.get_display();
 
diff --git a/js/ui/overview.js b/js/ui/overview.js
index a3da235..436d665 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -82,8 +82,6 @@ Overview.prototype = {
     _init : function() {
         let me = this;
 
-        let global = Shell.Global.get();
-
         this._group = new Clutter.Group();
         this._group._delegate = this;
 
@@ -131,8 +129,6 @@ Overview.prototype = {
     },
 
     _recalculateGridSizes: function () {
-        let global = Shell.Global.get();
-
         wideScreen = (global.screen_width/global.screen_height > WIDE_SCREEN_CUT_OFF_RATIO);
 
         // We divide the screen into an imaginary grid which helps us determine the layout of
@@ -147,8 +143,6 @@ Overview.prototype = {
     },
 
     relayout: function () {
-        let global = Shell.Global.get();
-
         let screenHeight = global.screen_height;
         let screenWidth = global.screen_width;
 
@@ -277,8 +271,6 @@ Overview.prototype = {
         this.visible = true;
         this.animationInProgress = true;
 
-        let global = Shell.Global.get();
-
         this._dash.show();
 
         /* TODO: make this stuff dynamic */
@@ -334,8 +326,6 @@ Overview.prototype = {
         if (!this.visible || this._hideInProgress)
             return;
 
-        let global = Shell.Global.get();
-
         this.animationInProgress = true;
         this._hideInProgress = true;
         if (this._activeDisplayPane != null)
@@ -425,8 +415,6 @@ Overview.prototype = {
     },
 
     _hideDone: function() {
-        let global = Shell.Global.get();
-
         global.window_group.show();
 
         this._workspaces.destroy();
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 7e3b9dc..4e969c0 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -168,8 +168,6 @@ function Panel() {
 
 Panel.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
 
         this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL
                                  });
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index 052bd2d..c0d4b98 100644
--- a/js/ui/runDialog.js
+++ b/js/ui/runDialog.js
@@ -32,8 +32,6 @@ function RunDialog() {
 
 RunDialog.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
         this._isOpen = false;
 
         this._internalCommands = { 'lg':
@@ -43,13 +41,11 @@ RunDialog.prototype = {
                                    }),
 
                                    'r': Lang.bind(this, function() {
-                                       let global = Shell.Global.get();
                                        global.reexec_self();
                                    }),
 
                                    // Developer brain backwards compatibility
                                    'restart': Lang.bind(this, function() {
-                                       let global = Shell.Global.get();
                                        global.reexec_self();
                                    })
                                  };
@@ -181,7 +177,6 @@ RunDialog.prototype = {
         this._isOpen = true;
         this._group.show();
 
-        let global = Shell.Global.get();
         global.stage.set_key_focus(this._entry);
     },
 
diff --git a/js/ui/sidebar.js b/js/ui/sidebar.js
index 0c5c455..840b39e 100644
--- a/js/ui/sidebar.js
+++ b/js/ui/sidebar.js
@@ -34,8 +34,6 @@ function Sidebar() {
 
 Sidebar.prototype = {
     _init : function() {
-        let global = Shell.Global.get();
-
         // The top-left corner of the sidebar is fixed at:
         // x = -WidgetBox.WIDGETBOX_PADDING, y = Panel.PANEL_HEIGHT.
         // (The negative X is so that we don't see the rounded
diff --git a/js/ui/widget.js b/js/ui/widget.js
index 4ec371f..cd8fd42 100644
--- a/js/ui/widget.js
+++ b/js/ui/widget.js
@@ -163,7 +163,6 @@ ClockWidget.prototype = {
     },
 
     _updateCairo: function(time) {
-        let global = Shell.Global.get();
         Shell.draw_clock(this.collapsedActor,
                          time.getHours() % 12,
                          time.getMinutes());
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index 8dceba8..2a1b2ed 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -258,7 +258,6 @@ DesktopClone.prototype = {
             this.actor = new Clutter.Clone({ source: window.get_texture(),
                                              reactive: true });
         } else {
-            let global = Shell.Global.get();
             this.actor = new Clutter.Rectangle({ color: global.stage.color,
                                                  reactive: true,
                                                  width: global.screen_width,
@@ -290,7 +289,6 @@ function Workspace(workspaceNum, parentActor) {
 Workspace.prototype = {
     _init : function(workspaceNum, parentActor) {
         let me = this;
-        let global = Shell.Global.get();
 
         this.workspaceNum = workspaceNum;
         this._metaWorkspace = global.screen.get_workspace_by_index(workspaceNum);
@@ -364,7 +362,6 @@ Workspace.prototype = {
     },
 
     updateRemovable : function() {
-        let global = Shell.Global.get();
         let removable = (this._windows.length == 1 /* just desktop */ &&
                          this.workspaceNum != 0 &&
                          this.workspaceNum == global.screen.n_workspaces - 1);
@@ -466,7 +463,6 @@ Workspace.prototype = {
 
     // Mark the workspace selected/not-selected
     setSelected : function(selected) {
-        let global = Shell.Global.get();
         // Don't draw a frame if we only have one workspace
         if (selected && global.screen.n_workspaces > 1) {
             if (this._frame)
@@ -502,8 +498,6 @@ Workspace.prototype = {
     // is true, then the workspace is moving at the same time and we need to take
     // that into account
     positionWindows : function(workspaceZooming) {
-        let global = Shell.Global.get();
-
         let totalVisible = 0;
 
         for (let i = 1; i < this._windows.length; i++) {
@@ -611,7 +605,6 @@ Workspace.prototype = {
     },
 
     _windowRemoved : function(metaWorkspace, metaWin) {
-        let global = Shell.Global.get();
         let win = metaWin.get_compositor_private();
 
         // find the position of the window in our list
@@ -763,8 +756,6 @@ Workspace.prototype = {
 
     // Animates the addition of a new (empty) workspace
     slideIn : function(oldScale) {
-        let global = Shell.Global.get();
-
         if (this.gridCol > this.gridRow) {
             this.actor.set_position(global.screen_width, this.gridY);
             this.actor.set_scale(oldScale, oldScale);
@@ -786,7 +777,6 @@ Workspace.prototype = {
     
     // Animates the removal of a workspace
     slideOut : function(onComplete) {
-        let global = Shell.Global.get();
         let destX = this.actor.x, destY = this.actor.y;
 
         this._hideAllIcons();
@@ -813,8 +803,6 @@ Workspace.prototype = {
     },
     
     destroy : function() {
-        let global = Shell.Global.get();
-
         Tweener.removeTweens(this.actor);
         this.actor.destroy();
         this.actor = null;
@@ -911,7 +899,6 @@ Workspace.prototype = {
     },
 
     _removeSelf : function(actor, event) {
-        let global = Shell.Global.get();
         let screen = global.screen;
         let workspace = screen.get_workspace_by_index(this.workspaceNum);
 
@@ -921,8 +908,6 @@ Workspace.prototype = {
 
     // Draggable target interface
     acceptDrop : function(source, actor, x, y, time) {
-        let global = Shell.Global.get();
-
         if (source instanceof WindowClone) {
             let win = source.realWindow;
             if (this._isMyWindow(win))
@@ -959,8 +944,6 @@ function Workspaces(width, height, x, y, addButtonSize, addButtonX, addButtonY)
 
 Workspaces.prototype = {
     _init : function(width, height, x, y, addButtonSize, addButtonX, addButtonY) {
-        let global = Shell.Global.get();
-
         this.actor = new Clutter.Group();
 
         this._appIdFilter = null;
@@ -1074,7 +1057,6 @@ Workspaces.prototype = {
 
     // Should only be called from active Overview context
     activateWindowFromOverview: function (metaWindow, time) {
-        let global = Shell.Global.get();
         let activeWorkspaceNum = global.screen.get_active_workspace_index();
         let windowWorkspaceNum = metaWindow.get_workspace().index();
 
@@ -1090,7 +1072,6 @@ Workspaces.prototype = {
     },
 
     hide : function() {
-        let global = Shell.Global.get();
         let activeWorkspaceIndex = global.screen.get_active_workspace_index();
         let activeWorkspace = this._workspaces[activeWorkspaceIndex];
 
@@ -1102,8 +1083,6 @@ Workspaces.prototype = {
     },
 
     destroy : function() {
-        let global = Shell.Global.get();
-
         for (let w = 0; w < this._workspaces.length; w++)
             this._workspaces[w].destroy();
         this._workspaces = [];
@@ -1121,7 +1100,6 @@ Workspaces.prototype = {
 
     // Get the grid position of the active workspace.
     getActiveWorkspacePosition : function() {
-        let global = Shell.Global.get();
         let activeWorkspaceIndex = global.screen.get_active_workspace_index();
         let activeWorkspace = this._workspaces[activeWorkspaceIndex];
 
@@ -1176,8 +1154,6 @@ Workspaces.prototype = {
     },
 
     _workspacesChanged : function() {
-        let global = Shell.Global.get();
-
         let oldNumWorkspaces = this._workspaces.length;
         let newNumWorkspaces = global.screen.n_workspaces;
 
@@ -1262,8 +1238,6 @@ Workspaces.prototype = {
     },
 
     _appendNewWorkspace : function() {
-        let global = Shell.Global.get();
-
         global.screen.append_new_workspace(false, global.screen.get_display().get_current_time());
     },
 
@@ -1286,7 +1260,6 @@ AddWorkspaceButton.prototype = {
                                            height: buttonSize,
                                            reactive: true });
         this._acceptDropCallback = acceptDropCallback;
-        let global = Shell.Global.get();
         this.actor._delegate = this;
         this.actor.set_from_file(global.imagedir + 'add-workspace.svg');
     },



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