[gnome-shell/wip/gdm-shell: 11/16] overview: Make optional



commit 423fa3698702d9f18a6b6b06c0190f3d6b5a9b6c
Author: Ray Strode <rstrode redhat com>
Date:   Mon Aug 22 14:26:13 2011 -0400

    overview: Make optional
    
    In preparation for using the shell at the login screen, we'll need
    to be able to run the shell without an activities overview.
    
    This commit prefaces code that accesses the overview state with a
    to check first to see if there is an overview to access.

 js/ui/ctrlAltTab.js         |    2 +-
 js/ui/layout.js             |   13 +++++--
 js/ui/main.js               |   13 ++++---
 js/ui/messageTray.js        |   68 +++++++++++++++++++++-----------------
 js/ui/notificationDaemon.js |    7 ++--
 js/ui/panel.js              |   77 +++++++++++++++++++++++--------------------
 js/ui/windowManager.js      |   32 +++++++++--------
 7 files changed, 118 insertions(+), 94 deletions(-)
---
diff --git a/js/ui/ctrlAltTab.js b/js/ui/ctrlAltTab.js
index d0845a3..5412b7c 100644
--- a/js/ui/ctrlAltTab.js
+++ b/js/ui/ctrlAltTab.js
@@ -99,7 +99,7 @@ CtrlAltTabManager.prototype = {
         let items = this._items.filter(function (item) { return item.proxy.mapped; });
 
         // And add the windows metacity would show in its Ctrl-Alt-Tab list
-        if (!Main.overview.visible) {
+        if (!Main.overview || !Main.overview.visible) {
             let screen = global.screen;
             let display = screen.get_display();
             let windows = display.get_tab_list(Meta.TabList.DOCKS, screen, screen.get_active_workspace ());
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 8484ca7..c3597b4 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -73,6 +73,9 @@ LayoutManager.prototype = {
             this._hotCorners[i].destroy();
         this._hotCorners = [];
 
+        if (!Main.overview)
+            return;
+
         // build new hot corners
         for (let i = 0; i < this.monitors.length; i++) {
             if (i == this.primaryIndex)
@@ -443,10 +446,12 @@ Chrome.prototype = {
     },
 
     init: function() {
-        Main.overview.connect('showing',
-                             Lang.bind(this, this._overviewShowing));
-        Main.overview.connect('hidden',
-                             Lang.bind(this, this._overviewHidden));
+        if (Main.overview) {
+            Main.overview.connect('showing',
+                                 Lang.bind(this, this._overviewShowing));
+            Main.overview.connect('hidden',
+                                 Lang.bind(this, this._overviewHidden));
+        }
     },
 
     _allocated: function(actor, box, flags) {
diff --git a/js/ui/main.js b/js/ui/main.js
index 5cde541..a417f30 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -191,7 +191,8 @@ function start() {
     panel.startStatusArea();
     panel.startupAnimation();
 
-    global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
+    if (overview)
+        global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
 
     global.stage.connect('captured-event', _globalKeyPressHandler);
 
@@ -544,11 +545,11 @@ function _globalKeyPressHandler(actor, event) {
 
     // Other bindings are only available when the overview is up and
     // no modal dialog is present.
-    if (!overview.visible || modalCount > 1)
+    if ((overview && !overview.visible) || modalCount > 1)
         return false;
 
     // This isn't a Meta.KeyBindingAction yet
-    if (symbol == Clutter.Super_L || symbol == Clutter.Super_R) {
+    if (overview && (symbol == Clutter.Super_L || symbol == Clutter.Super_R)) {
         overview.hide();
         return true;
     }
@@ -574,7 +575,8 @@ function _globalKeyPressHandler(actor, event) {
             getRunDialog().open();
             return true;
         case Meta.KeyBindingAction.PANEL_MAIN_MENU:
-            overview.hide();
+            if (overview)
+                overview.hide();
             return true;
         case Meta.KeyBindingAction.SWITCH_PANELS:
             ctrlAltTabManager.popup(modifierState & Clutter.ModifierType.SHIFT_MASK);
@@ -741,7 +743,8 @@ function activateWindow(window, time, workspaceNum) {
         window.activate(time);
     }
 
-    overview.hide();
+    if (overview)
+        overview.hide();
 }
 
 // TODO - replace this timeout with some system to guess when the user might
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 00fe91f..8df35cf 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -218,14 +218,16 @@ FocusGrabber.prototype = {
         this._capturedEventId = 0;
         this._togglingFocusGrabMode = false;
 
-        Main.overview.connect('showing', Lang.bind(this,
-            function() {
-                this._toggleFocusGrabMode();
-            }));
-        Main.overview.connect('hidden', Lang.bind(this,
-            function() {
-                this._toggleFocusGrabMode();
-            }));
+        if (Main.overview) {
+            Main.overview.connect('showing', Lang.bind(this,
+                function() {
+                    this._toggleFocusGrabMode();
+                }));
+            Main.overview.connect('hidden', Lang.bind(this,
+                function() {
+                    this._toggleFocusGrabMode();
+                }));
+        }
     },
 
     grabFocus: function(actor) {
@@ -237,7 +239,7 @@ FocusGrabber.prototype = {
         this._prevFocusedWindow = global.display.focus_window;
         this._prevKeyFocusActor = global.stage.get_key_focus();
 
-        if (!Main.overview.visible)
+        if (!Main.overview || !Main.overview.visible)
             global.set_stage_input_mode(Shell.StageInputMode.FOCUSED);
 
         // Use captured-event to notice clicks outside the focused actor
@@ -1325,7 +1327,11 @@ MessageTray.prototype = {
         this._notificationExpandedId = 0;
         this._summaryBoxPointerState = State.HIDDEN;
         this._summaryBoxPointerTimeoutId = 0;
-        this._overviewVisible = Main.overview.visible;
+        if (Main.overview && Main.overview.visible) {
+            this._overviewVisible = true;
+        } else {
+            this._overviewVisible = false;
+        }
         this._notificationRemoved = false;
         this._reNotifyAfterHideNotification = null;
 
@@ -1336,26 +1342,28 @@ MessageTray.prototype = {
 
         this._setSizePosition();
 
-        Main.overview.connect('showing', Lang.bind(this,
-            function() {
-                this._overviewVisible = true;
-                if (this._locked) {
-                    this._unsetClickedSummaryItem();
-                    this._unlock();
-                } else {
-                    this._updateState();
-                }
-            }));
-        Main.overview.connect('hiding', Lang.bind(this,
-            function() {
-                this._overviewVisible = false;
-                if (this._locked) {
-                    this._unsetClickedSummaryItem();
-                    this._unlock();
-                } else {
-                    this._updateState();
-                }
-            }));
+        if (Main.overview) {
+            Main.overview.connect('showing', Lang.bind(this,
+                function() {
+                    this._overviewVisible = true;
+                    if (this._locked) {
+                        this._unsetClickedSummaryItem();
+                        this._unlock();
+                    } else {
+                        this._updateState();
+                    }
+                }));
+            Main.overview.connect('hiding', Lang.bind(this,
+                function() {
+                    this._overviewVisible = false;
+                    if (this._locked) {
+                        this._unsetClickedSummaryItem();
+                        this._unlock();
+                    } else {
+                        this._updateState();
+                    }
+                }));
+        }
 
         this._summaryItems = [];
         // We keep a list of new summary items that were added to the summary since the last
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 86bd4a2..ffd81ad 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -102,8 +102,9 @@ NotificationDaemon.prototype = {
 
         Shell.WindowTracker.get_default().connect('notify::focus-app',
             Lang.bind(this, this._onFocusAppChanged));
-        Main.overview.connect('hidden',
-            Lang.bind(this, this._onFocusAppChanged));
+        if (Main.overview)
+            Main.overview.connect('hidden',
+                Lang.bind(this, this._onFocusAppChanged));
     },
 
     _iconForNotificationData: function(icon, hints, size) {
@@ -506,7 +507,7 @@ Source.prototype = {
             this.notifications.length > 0)
             return false;
 
-        if (Main.overview.visible) {
+        if (Main.overview && Main.overview.visible) {
             // We can't just connect to Main.overview's 'hidden' signal,
             // because it's emitted *before* it calls popModal()...
             let id = global.connect('notify::stage-input-mode', Lang.bind(this,
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 91adc4c..012f9dc 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -268,15 +268,17 @@ AppMenuButton.prototype = {
         this.menu.addMenuItem(this._quitMenu);
         this._quitMenu.connect('activate', Lang.bind(this, this._onQuit));
 
-        this._visible = !Main.overview.visible;
-        if (!this._visible)
-            this.actor.hide();
-        Main.overview.connect('hiding', Lang.bind(this, function () {
-            this.show();
-        }));
-        Main.overview.connect('showing', Lang.bind(this, function () {
-            this.hide();
-        }));
+        if (Main.overview) {
+            this._visible = !Main.overview.visible;
+            if (!this._visible)
+                this.actor.hide();
+            Main.overview.connect('hiding', Lang.bind(this, function () {
+                this.show();
+            }));
+            Main.overview.connect('showing', Lang.bind(this, function () {
+                this.hide();
+            }));
+        }
 
         this._stop = true;
 
@@ -788,12 +790,14 @@ Panel.prototype = {
 
         this._statusArea = {};
 
-        Main.overview.connect('shown', Lang.bind(this, function () {
-            this.actor.add_style_class_name('in-overview');
-        }));
-        Main.overview.connect('hiding', Lang.bind(this, function () {
-            this.actor.remove_style_class_name('in-overview');
-        }));
+        if (Main.overview) {
+            Main.overview.connect('shown', Lang.bind(this, function () {
+                this.actor.add_style_class_name('in-overview');
+            }));
+            Main.overview.connect('hiding', Lang.bind(this, function () {
+                this.actor.remove_style_class_name('in-overview');
+            }));
+        }
 
         this._leftPointerBarrier = 0;
         this._rightPointerBarrier = 0;
@@ -816,27 +820,28 @@ Panel.prototype = {
         this.actor.connect('allocate', Lang.bind(this, this._allocate));
 
         /* Button on the left side of the panel. */
-        this._activitiesButton = new ActivitiesButton();
-        this._activities = this._activitiesButton.actor;
-        this._leftBox.add(this._activities);
-
-        // The activities button has a pretend menu, so as to integrate
-        // more cleanly with the rest of the panel
-        this._menus.addMenu(this._activitiesButton.menu);
-
-        // Synchronize the button's pseudo classes with its corner
-        this._activities.connect('style-changed', Lang.bind(this,
-            function(actor) {
-                let rtl = actor.get_direction() == St.TextDirection.RTL;
-                let corner = rtl ? this._rightCorner : this._leftCorner;
-                let pseudoClass = actor.get_style_pseudo_class();
-                corner.actor.set_style_pseudo_class(pseudoClass);
-            }));
-
-        this._appMenu = new AppMenuButton();
-        this._leftBox.add(this._appMenu.actor);
-
-        this._menus.addMenu(this._appMenu.menu);
+        if (Main.overview) {
+            this._activitiesButton = new ActivitiesButton();
+            this._activities = this._activitiesButton.actor;
+            this._leftBox.add(this._activities);
+
+            // The activities button has a pretend menu, so as to integrate
+            // more cleanly with the rest of the panel
+            this._menus.addMenu(this._activitiesButton.menu);
+
+            // Synchronize the button's pseudo classes with its corner
+            this._activities.connect('style-changed', Lang.bind(this,
+                function(actor) {
+                    let rtl = actor.get_direction() == St.TextDirection.RTL;
+                    let corner = rtl ? this._rightCorner : this._leftCorner;
+                    let pseudoClass = actor.get_style_pseudo_class();
+                    corner.actor.set_style_pseudo_class(pseudoClass);
+                }));
+
+            this._appMenu = new AppMenuButton();
+            this._leftBox.add(this._appMenu.actor);
+            this._menus.addMenu(this._appMenu.menu);
+        }
 
         /* center */
         this._dateMenu = new DateMenu.DateMenuButton();
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index e9c1192..554b83d 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -123,14 +123,16 @@ WindowManager.prototype = {
         this.setKeybindingHandler('switch_group_backward', Lang.bind(this, this._startAppSwitcher));
         this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher));
 
-        Main.overview.connect('showing', Lang.bind(this, function() {
-            for (let i = 0; i < this._dimmedWindows.length; i++)
-                this._undimWindow(this._dimmedWindows[i], true);
-        }));
-        Main.overview.connect('hiding', Lang.bind(this, function() {
-            for (let i = 0; i < this._dimmedWindows.length; i++)
-                this._dimWindow(this._dimmedWindows[i], true);
-        }));
+        if (Main.overview) {
+            Main.overview.connect('showing', Lang.bind(this, function() {
+                for (let i = 0; i < this._dimmedWindows.length; i++)
+                    this._undimWindow(this._dimmedWindows[i], true);
+            }));
+            Main.overview.connect('hiding', Lang.bind(this, function() {
+                for (let i = 0; i < this._dimmedWindows.length; i++)
+                    this._dimWindow(this._dimmedWindows[i], true);
+            }));
+        }
     },
 
     setKeybindingHandler: function(keybinding, handler){
@@ -152,7 +154,7 @@ WindowManager.prototype = {
     },
 
     _shouldAnimate : function(actor) {
-        if (Main.overview.visible || this._animationsBlocked > 0)
+        if ((Main.overview && Main.overview.visible) || this._animationsBlocked > 0)
             return false;
         if (actor && (actor.meta_window.get_window_type() != Meta.WindowType.NORMAL))
             return false;
@@ -252,14 +254,14 @@ WindowManager.prototype = {
         if (shouldDim && !window._dimmed) {
             window._dimmed = true;
             this._dimmedWindows.push(window);
-            if (!Main.overview.visible)
+            if (!Main.overview || !Main.overview.visible)
                 this._dimWindow(window, true);
         } else if (!shouldDim && window._dimmed) {
             window._dimmed = false;
             this._dimmedWindows = this._dimmedWindows.filter(function(win) {
                                                                  return win != window;
                                                              });
-            if (!Main.overview.visible)
+            if (!Main.overview || !Main.overview.visible)
                 this._undimWindow(window, true);
         }
     },
@@ -575,7 +577,7 @@ WindowManager.prototype = {
         if (indexToActivate != activeWorkspaceIndex)
             global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
 
-        if (!Main.overview.visible)
+        if (!Main.overview || !Main.overview.visible)
             this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.UP, indexToActivate);
     },
 
@@ -591,7 +593,7 @@ WindowManager.prototype = {
         if (indexToActivate != activeWorkspaceIndex)
             global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
 
-        if (!Main.overview.visible)
+        if (!Main.overview || !Main.overview.visible)
             this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate);
     },
 
@@ -604,7 +606,7 @@ WindowManager.prototype = {
         if (indexToActivate != activeWorkspaceIndex)
             global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
 
-        if (!Main.overview.visible)
+        if (!Main.overview || !Main.overview.visible)
             this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.UP, indexToActivate);
     },
 
@@ -617,7 +619,7 @@ WindowManager.prototype = {
         if (indexToActivate != activeWorkspaceIndex)
             global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
 
-        if (!Main.overview.visible)
+        if (!Main.overview || !Main.overview.visible)
             this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate);
     }
 };



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