[gnome-shell] [MessageTray] Use #StWidget:track-hover
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [MessageTray] Use #StWidget:track-hover
- Date: Wed, 24 Mar 2010 14:14:35 +0000 (UTC)
commit 994b4c0007bde1cebd5573b2589237386b38651f
Author: Dan Winship <danw gnome org>
Date: Mon Mar 15 12:20:10 2010 -0400
[MessageTray] Use #StWidget:track-hover
St.Widget's new "hover" property takes reactive children into account
when deciding whether or not the pointer has actually left the actor,
so it works better than the code that used to be here.
https://bugzilla.gnome.org/show_bug.cgi?id=610726
js/ui/messageTray.js | 62 +++++++++++++++++++++-----------------------------
1 files changed, 26 insertions(+), 36 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 63d0d5d..69231c0 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -359,7 +359,9 @@ function MessageTray() {
MessageTray.prototype = {
_init: function() {
this.actor = new St.BoxLayout({ name: 'message-tray',
- reactive: true });
+ reactive: true,
+ track_hover: true });
+ this.actor.connect('notify::hover', Lang.bind(this, this._onTrayHoverChanged));
this._notificationBin = new St.Bin({ reactive: true,
x_align: St.Align.MIDDLE });
@@ -368,22 +370,15 @@ MessageTray.prototype = {
this._notificationQueue = [];
this._notification = null;
- this._summaryBin = new St.BoxLayout();
+ this._summaryBin = new St.Bin({ x_align: St.Align.END });
this.actor.add(this._summaryBin);
this._summary = new St.BoxLayout({ name: 'summary-mode',
- reactive: true });
- this._summaryBin.add(this._summary, { x_align: St.Align.END,
- x_fill: false,
- expand: true });
- this._summary.connect('enter-event',
- Lang.bind(this, this._onSummaryEntered));
- this._summary.connect('leave-event',
- Lang.bind(this, this._onSummaryLeft));
+ reactive: true,
+ track_hover: true });
+ this._summary.connect('notify::hover', Lang.bind(this, this._onSummaryHoverChanged));
+ this._summaryBin.child = this._summary;
this._summaryBin.opacity = 0;
- this.actor.connect('enter-event', Lang.bind(this, this._onTrayEntered));
- this.actor.connect('leave-event', Lang.bind(this, this._onTrayLeft));
-
this._trayState = State.HIDDEN;
this._trayLeftTimeoutId = 0;
this._pointerInTray = false;
@@ -439,7 +434,7 @@ MessageTray.prototype = {
return;
}
- let iconBox = new St.Bin({ reactive: true });
+ let iconBox = new St.Clickable({ reactive: true });
iconBox.child = source.createIcon(ICON_SIZE);
this._summary.insert_actor(iconBox, 0);
this._summaryNeedsToBeShown = true;
@@ -448,7 +443,7 @@ MessageTray.prototype = {
source.connect('notify', Lang.bind(this, this._onNotify));
- iconBox.connect('button-release-event', Lang.bind(this,
+ iconBox.connect('clicked', Lang.bind(this,
function () {
source.clicked();
}));
@@ -537,32 +532,27 @@ MessageTray.prototype = {
this._updateState();
},
- _onSummaryEntered: function() {
- this._pointerInSummary = true;
+ _onSummaryHoverChanged: function() {
+ this._pointerInSummary = this._summary.hover;
this._updateState();
},
- _onSummaryLeft: function() {
- this._pointerInSummary = false;
- this._updateState();
- },
+ _onTrayHoverChanged: function() {
+ if (this.actor.hover) {
+ if (this._trayLeftTimeoutId) {
+ Mainloop.source_remove(this._trayLeftTimeoutId);
+ this._trayLeftTimeoutId = 0;
+ return;
+ }
- _onTrayEntered: function() {
- if (this._trayLeftTimeoutId) {
- Mainloop.source_remove(this._trayLeftTimeoutId);
- this._trayLeftTimeoutId = 0;
- return;
+ this._pointerInTray = true;
+ this._updateState();
+ } else {
+ // We wait just a little before hiding the message tray in case the
+ // user quickly moves the mouse back into it.
+ let timeout = MESSAGE_TRAY_TIMEOUT * 1000;
+ this._trayLeftTimeoutId = Mainloop.timeout_add(timeout, Lang.bind(this, this._onTrayLeftTimeout));
}
-
- this._pointerInTray = true;
- this._updateState();
- },
-
- _onTrayLeft: function() {
- // We wait just a little before hiding the message tray in case the
- // user quickly moves the mouse back into it.
- let timeout = MESSAGE_TRAY_TIMEOUT * 1000;
- this._trayLeftTimeoutId = Mainloop.timeout_add(timeout, Lang.bind(this, this._onTrayLeftTimeout));
},
_onTrayLeftTimeout: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]