[polari] chatView: Improve link hover handling



commit 4f7cec7c6bdebd9c863eb2da6ae8864325176131
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Dec 22 20:45:50 2015 +0100

    chatView: Improve link hover handling
    
    Links are added with two text tags, one for generic styling shared
    between all links and one url-specific one to handle interaction.
    However with the hover styling added in commit cd69f6ce, we now
    always override the foreground color specified by the generic tag.
    This usually does not matter as the colors match, except that we
    update the shared 'url' tag on style changes, but not the url-specific
    ones. As hovering is a transient state, we don't care much about
    updating hovered links immediately, but for links that are not
    currently hovered, we shouldn't wait until the pointer moves over
    the link again; simply stop overriding the 'url' tag in that case.

 src/chatView.js |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index d475c9b..6dc54c1 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -325,7 +325,7 @@ const ChatView = new Lang.Class({
 
         context.save();
         context.set_state(Gtk.StateFlags.LINK);
-        this._linkColor = context.get_color(context.get_state());
+        let linkColor = context.get_color(context.get_state());
         this._activeNickColor = context.get_color(context.get_state());
 
         context.set_state(Gtk.StateFlags.LINK | Gtk.StateFlags.PRELIGHT);
@@ -352,7 +352,7 @@ const ChatView = new Lang.Class({
           { name: 'action',
             foreground_rgba: dimColor },
           { name: 'url',
-            foreground_rgba: this._linkColor }
+            foreground_rgba: linkColor }
         ];
         tags.forEach(function(tagProps) {
             let tag = tagTable.lookup(tagProps.name);
@@ -1146,10 +1146,7 @@ const ChatView = new Lang.Class({
         let tag = new ButtonTag();
         tag.connect('notify::hover', Lang.bind(this,
             function() {
-                if (tag.hover)
-                    tag.foreground_rgba = this._hoveredLinkColor;
-                else
-                    tag.foreground_rgba = this._linkColor;
+                tag.foreground_rgba = tag.hover ? this._hoveredLinkColor : null;
             }));
         tag.connect('clicked',
             function() {


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