dash: Add tooltip label to show applications icon

Make the tooltip dependent on whether we are currently dragging
on hover or not.

https://bugzilla.gnome.org/show_bug.cgi?id=682445
This commit is contained in:
Jasper St. Pierre 2012-08-22 06:46:28 -03:00
parent 983535224e
commit 3fafe0da07

View File

@ -250,6 +250,7 @@ const ShowAppsIcon = new Lang.Class({
this.toggleButton._delegate = this; this.toggleButton._delegate = this;
this.setChild(this.toggleButton); this.setChild(this.toggleButton);
this.setHover(false);
}, },
_createIcon: function(size) { _createIcon: function(size) {
@ -265,6 +266,11 @@ const ShowAppsIcon = new Lang.Class({
this.toggleButton.set_hover(hovered); this.toggleButton.set_hover(hovered);
if (this._iconActor) if (this._iconActor)
this._iconActor.set_hover(hovered); this._iconActor.set_hover(hovered);
if (hovered)
this.setLabelText(_("Remove from Favorites"));
else
this.setLabelText(_("Show Applications"));
}, },
// Rely on the dragged item being a favorite // Rely on the dragged item being a favorite
@ -330,6 +336,7 @@ const Dash = new Lang.Class({
this._showAppsIcon = new ShowAppsIcon(); this._showAppsIcon = new ShowAppsIcon();
this._showAppsIcon.icon.setIconSize(this.iconSize); this._showAppsIcon.icon.setIconSize(this.iconSize);
this._hookUpLabel(this._showAppsIcon);
this.showAppsButton = this._showAppsIcon.toggleButton; this.showAppsButton = this._showAppsIcon.toggleButton;
@ -428,6 +435,17 @@ const Dash = new Lang.Class({
Main.queueDeferredWork(this._workId); Main.queueDeferredWork(this._workId);
}, },
_hookUpLabel: function(item) {
item.child.connect('notify::hover', Lang.bind(this, function() {
this._onHover(item);
}));
Main.overview.connect('hiding', Lang.bind(this, function() {
this._labelShowing = false;
item.hideLabel();
}));
},
_createAppItem: function(app) { _createAppItem: function(app) {
let display = new AppDisplay.AppWellIcon(app, let display = new AppDisplay.AppWellIcon(app,
{ setSizeManually: true, { setSizeManually: true,
@ -447,25 +465,14 @@ const Dash = new Lang.Class({
item.setLabelText(app.get_name()); item.setLabelText(app.get_name());
// Override default AppWellIcon label_actor // Override default AppWellIcon label_actor
display.actor.label_actor = item.label; display.actor.label_actor = item.label;
display.icon.setIconSize(this.iconSize); display.icon.setIconSize(this.iconSize);
display.actor.connect('notify::hover', this._hookUpLabel(item);
Lang.bind(this, function() {
this._onHover(item, display)
}));
Main.overview.connect('hiding',
Lang.bind(this, function() {
this._labelShowing = false;
item.hideLabel();
}));
return item; return item;
}, },
_onHover: function (item, display) { _onHover: function (item) {
if (display.actor.get_hover() && !display.isMenuUp) { if (item.child.get_hover() && !item.child._delegate.isMenuUp) {
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,