[hyena/gtk3] ListView: work-around possible selection GTK3 Theme CSS bug



commit 2ad445774ebd6a20f46e113ce11e1847fd77ca19
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Wed Aug 14 10:59:55 2013 +0200

    ListView: work-around possible selection GTK3 Theme CSS bug
    
    In the case these two rules are defined in CSS:
    
    *:selected {
        background-color: @selected_bg_color;
    }
    
    .cell {
        background-color: @base_color;
    }
    
    They have the same CSS precedence, so then the last one applies.
    The solution to this is place the pseudo-class rule about the
    :selected state the last one. This is bad because it is very common
    to have this precedence clash in CSS files of Gtk themes, and
    because it is actually the case in the default Ubuntu theme (at
    least in 13.04), called Ambiance.
    
    This bug has been reported upstream (I have even provided a patch):
    https://bugs.launchpad.net/ubuntu/+source/ubuntu-themes/+bug/1211831
    
    But in the meantime we can add this workaround in hyena, along with
    a Hyena.Warning() to remind of the glitch.
    
    Side note: This rendering glitch is also affecting the SourceView
    treeview used in Banshee.ThickClient, and obviously this workaround
    doesn't help there, so we will have to either find another temporary
    workaround for that, or bug ubuntu-theme maintainers heavily.

 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs 
b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 4b93f4e..abe19de 100644
--- a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -317,6 +317,7 @@ namespace Hyena.Data.Gui
                     StyleContext.RenderBackground (cr, single_list_alloc.X, single_list_alloc.Y,
                         single_list_alloc.Width, single_list_alloc.Height);
                     StyleContext.RemoveRegion ("row");
+                    StyleContext.RemoveClass ("cell");
 
                     PaintReorderLine (cr, ri, single_list_alloc);
 
@@ -338,13 +339,25 @@ namespace Hyena.Data.Gui
                     }
 
                     if (selection_height > 0) {
-                        Cairo.Color selection_color = CairoExtensions.GdkRGBAToCairoColor 
(StyleContext.GetBackgroundColor (StateFlags.Selected));
+
+                        StyleContext.AddClass ("cell");
+                        var bg_selected_color = StyleContext.GetBackgroundColor (StateFlags.Selected);
+
+                        if (bg_selected_color.Equals (StyleContext.GetBackgroundColor (StateFlags.Normal))) {
+                            // see https://bugs.launchpad.net/bugs/1211831
+                            Hyena.Log.Warning ("Buggy CSS theme: same background-color for .cell:selected 
and .cell");
+                            StyleContext.RemoveClass ("cell");
+                            bg_selected_color = StyleContext.GetBackgroundColor (StateFlags.Selected);
+                            StyleContext.AddClass ("cell");
+                        }
+                        Cairo.Color selection_color = CairoExtensions.GdkRGBAToCairoColor 
(bg_selected_color);
 
                         if (!HasFocus || HeaderFocused)
                             selection_color = CairoExtensions.ColorShade (selection_color, 1.1);
 
                         Theme.DrawRowSelection (cr, list_rendering_alloc.X, selection_y, 
list_rendering_alloc.Width, selection_height,
                                                 true, true, selection_color, CairoCorners.All);
+                        StyleContext.RemoveClass ("cell");
                         selection_height = 0;
                     }
 


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