dash: properly restore item label on popup close

We simply hide the label when the popup is opened instead of relying
on the popup state when the hover state change.

To do this we replace the flag isMenuUp by a 'menu-state-changed' signal
on the AppWellIcon. This simplifies the dash label visibility handling
code that need additional changes for the bug.

https://bugzilla.gnome.org/show_bug.cgi?id=657315
This commit is contained in:
Stéphane Démurget 2012-11-03 21:03:33 +01:00
parent 10c104529f
commit ee2f12fe81
2 changed files with 21 additions and 4 deletions

View File

@ -479,7 +479,6 @@ const AppWellIcon = new Lang.Class({
Lang.bind(this, Lang.bind(this,
this._onStateChanged)); this._onStateChanged));
this._onStateChanged(); this._onStateChanged();
this.isMenuUp = false;
}, },
_onDestroy: function() { _onDestroy: function() {
@ -561,7 +560,8 @@ const AppWellIcon = new Lang.Class({
this._menuManager.addMenu(this._menu); this._menuManager.addMenu(this._menu);
} }
this.isMenuUp = true; this.emit('menu-state-changed', true);
this.actor.set_hover(true); this.actor.set_hover(true);
this._menu.popup(); this._menu.popup();
@ -578,7 +578,7 @@ const AppWellIcon = new Lang.Class({
_onMenuPoppedDown: function() { _onMenuPoppedDown: function() {
this.actor.sync_hover(); this.actor.sync_hover();
this.isMenuUp = false; this.emit('menu-state-changed', false);
}, },
_onActivate: function (event) { _onActivate: function (event) {

View File

@ -503,6 +503,10 @@ const Dash = new Lang.Class({
Lang.bind(this, function() { Lang.bind(this, function() {
display.actor.opacity = 255; display.actor.opacity = 255;
})); }));
display.connect('menu-state-changed',
Lang.bind(this, function(display, opened) {
this._itemMenuStateChanged(item, opened);
}));
let item = new DashItemContainer(); let item = new DashItemContainer();
item.setChild(display.actor); item.setChild(display.actor);
@ -518,8 +522,21 @@ const Dash = new Lang.Class({
return item; return item;
}, },
_itemMenuStateChanged: function(item, opened) {
// When the menu closes, it calls sync_hover, which means
// that the notify::hover handler does everything we need to.
if (opened) {
if (this._showLabelTimeoutId > 0) {
Mainloop.source_remove(this._showLabelTimeoutId);
this._showLabelTimeoutId = 0;
}
item.hideLabel();
}
},
_onHover: function (item) { _onHover: function (item) {
if (item.child.get_hover() && !item.child._delegate.isMenuUp) { if (item.child.get_hover()) {
if (this._showLabelTimeoutId == 0) { if (this._showLabelTimeoutId == 0) {
let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT; let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
this._showLabelTimeoutId = Mainloop.timeout_add(timeout, this._showLabelTimeoutId = Mainloop.timeout_add(timeout,