[gnome-shell/wip/message-tray: 1/14] Add a toggle-message-tray keybinding to move the windows up/down



commit f01fd0005784aa3960eae0f7cf8f1bfcd6f2f871
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Jul 14 13:07:24 2012 +0200

    Add a toggle-message-tray keybinding to move the windows up/down
    
    The default value is <Super>m.
    
    Only the windows on the primary monitor are moved because the
    secondary does not have a message tray.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681392

 data/org.gnome.shell.gschema.xml.in.in |    7 +++
 js/ui/messageTray.js                   |   81 +++++++++++++++++++++++++++++++-
 2 files changed, 86 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.shell.gschema.xml.in.in b/data/org.gnome.shell.gschema.xml.in.in
index ac4a1e3..866732f 100644
--- a/data/org.gnome.shell.gschema.xml.in.in
+++ b/data/org.gnome.shell.gschema.xml.in.in
@@ -87,6 +87,13 @@ value here is from the GsmPresenceStatus enumeration.</_summary>
         Keybinding to open the application menu.
       </_description>
     </key>
+    <key name="toggle-message-tray" type="as">
+      <default>["&lt;Super&gt;m"]</default>
+      <_summary>Keybinding to toggle the visibility of the message tray</_summary>
+      <_description>
+        Keybinding to toggle the visibility of the message tray.
+      </_description>
+    </key>
     <key name="toggle-recording" type="as">
       <default><![CDATA[['<Control><Shift><Alt>r']]]></default>
       <_summary>Keybinding to toggle the screen recorder</_summary>
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 762f168..bdab57e 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -21,6 +21,8 @@ const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
 const Util = imports.misc.util;
 
+const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
+
 const ANIMATION_TIME = 0.2;
 const NOTIFICATION_TIMEOUT = 4;
 const SUMMARY_TIMEOUT = 1;
@@ -1547,6 +1549,8 @@ const MessageTray = new Lang.Class({
         this._notificationRemoved = false;
         this._reNotifyAfterHideNotification = null;
         this._inFullscreen = false;
+        this._tweening = 0;
+        this._windowsShifted = 0;
 
         this._corner = new Clutter.Rectangle({ width: 1,
                                                height: 1,
@@ -1590,6 +1594,11 @@ const MessageTray = new Lang.Class({
         this._isScreenLocked = false;
         Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._onScreenLockStatusChanged));
 
+        global.display.add_keybinding('toggle-message-tray',
+                                      new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
+                                      Meta.KeyBindingFlags.NONE,
+                                      Lang.bind(this, this.toggle));
+
         this._summaryItems = [];
         // We keep a list of new summary items that were added to the summary since the last
         // time it was shown to the user. We automatically show the summary to the user if there
@@ -2243,19 +2252,87 @@ const MessageTray = new Lang.Class({
     },
 
     _showTray: function() {
+        // Bail out if we are in the middle of tweening the tray or the
+        // windows.
+        if (this._tweening != 0)
+            return;
+
         this._tween(this.actor, '_trayState', State.SHOWN,
                     { y: -this.actor.height,
                       time: ANIMATION_TIME,
-                      transition: 'easeOutQuad'
+                      transition: 'easeOutQuad',
+                      onComplete:
+                      { apply: Lang.bind(this, function() {
+                            this._tweening--;
+                        })
+                      }
                     });
+        this._tweening++;
+
+        // Don't move the windows up if we are in the overview.
+        if (this._overviewVisible)
+            return;
+
+        let actors = global.get_window_actors();
+        for (let i = 0; i < actors.length; i++) {
+            let window = actors[i].metaWindow;
+            if (!window.is_on_primary_monitor())
+                continue;
+
+            Tweener.addTween(actors[i],
+                             { y: actors[i].y - this.actor.height,
+                               time: ANIMATION_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: Lang.bind(this, function() {
+                                   this._tweening--;
+                               })
+                             });
+            this._windowsShifted++;
+            this._tweening++;
+        }
     },
 
     _hideTray: function() {
+        // Bail out if we are in the middle of tweening the tray or the
+        // windows.
+        if (this._tweening != 0)
+            return;
+
         this._tween(this.actor, '_trayState', State.HIDDEN,
                     { y: 0,
                       time: ANIMATION_TIME,
-                      transition: 'easeOutQuad'
+                      transition: 'easeOutQuad',
+                      onComplete:
+                      { apply: Lang.bind(this, function() {
+                            this._tweening--;
+                        })
+                      }
                     });
+        this._tweening++;
+
+        // Don't move the windows down if had not moved them up. We can't use
+        // this._overviewVisible to check whether we were in the overview
+        // because it gets unset before this method is invoked.
+        if (this._windowsShifted == 0)
+            return;
+
+        let actors = global.get_window_actors();
+        for (let i = 0; i < actors.length; i++) {
+            let window = actors[i].metaWindow;
+            if (!window.is_on_primary_monitor())
+                continue;
+
+            Tweener.addTween(actors[i],
+                             { y: actors[i].y + this.actor.height,
+                               time: ANIMATION_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: Lang.bind(this, function() {
+                                   this._windowsShifted--;
+                                   this._tweening--;
+                               })
+                             });
+            this._tweening++;
+        }
     },
 
     _onIdleMonitorWatch: function(monitor, id, userBecameIdle) {



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