appDisplay: Show full app name on hover

This commit is contained in:
Florian Müllner 2018-06-21 18:03:31 +02:00 committed by Ray Strode
parent a52390187b
commit d727fe3eeb
2 changed files with 56 additions and 0 deletions

View File

@ -1402,6 +1402,14 @@ StScrollBar {
}
.app-well-hover-text {
text-align: center;
color: $osd_fg_color;
background-color: $osd_bg_color;
border-radius: 5px;
padding: 3px;
}
.app-well-app-running-dot { //running apps indicator
width: 10px; height: 3px;
background-color: $selected_bg_color;

View File

@ -1628,6 +1628,20 @@ var AppIcon = new Lang.Class({
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
this._hoverText = null;
this._hoverTimeoutId = 0;
if (this.icon.label) {
this._hoverText = new St.Label({ style_class: 'app-well-hover-text',
text: this.icon.label.text,
visible: false });
this._hoverText.clutter_text.line_wrap = true;
Main.layoutManager.addChrome(this._hoverText);
this.actor.connect('notify::hover', this._syncHoverText.bind(this));
this.connect('sync-tooltip', this._syncHoverText.bind(this));
}
this._menu = null;
this._menuManager = new PopupMenu.PopupMenuManager(this);
@ -1659,12 +1673,39 @@ var AppIcon = new Lang.Class({
this.app.disconnect(this._stateChangedId);
this._stateChangedId = 0;
this._removeMenuTimeout();
this._removeHoverTimeout();
if (this._hoverText)
this._hoverText.destroy();
this._hoverText = null;
},
_createIcon(iconSize) {
return this.app.create_icon_texture(iconSize);
},
_syncHoverText() {
if (this.shouldShowTooltip()) {
if (this._hoverTimeoutId)
return;
this._hoverTimeoutId = Mainloop.timeout_add(300, () => {
this._hoverText.style = `max-width: ${2 * this.icon.iconSize}px;`;
this._hoverText.ensure_style();
let [x, y] = this.icon.label.get_transformed_position();
let offset = (this._hoverText.width - this.icon.label.width) / 2;
this._hoverText.set_position(Math.floor(x - offset), Math.floor(y));
this._hoverText.show();
this._hoverTimeoutId = 0;
return GLib.SOURCE_REMOVE;
});
} else {
this._removeHoverTimeout();
this._hoverText.hide();
}
},
_removeMenuTimeout() {
if (this._menuTimeoutId > 0) {
Mainloop.source_remove(this._menuTimeoutId);
@ -1672,6 +1713,13 @@ var AppIcon = new Lang.Class({
}
},
_removeHoverTimeout() {
if (this._hoverTimeoutId > 0) {
Mainloop.source_remove(this._hoverTimeoutId);
this._hoverTimeoutId = 0;
}
},
_updateRunningStyle() {
if (this.app.state != Shell.AppState.STOPPED)
this._dot.show();