[hyena/gtk3] ListView: always render background for all cells



commit cb845c4d7b0a336a7a2d896f2f79b744b2b43c97
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Thu Aug 8 18:26:05 2013 +0200

    ListView: always render background for all cells
    
    Previous commit[1] that replaced the VIEW class with the CELL one was
    not actually correct. By looking at the GtkTreeView code from master[2]
    we can notice that the VIEW is used at first, but the CELL is also used
    later, when drawing the cells.
    
    In hyena, the background of the cells was only being drawn when the
    RulesHint property was TRUE and the cell parity was odd, assuming
    that the background of a normal (even parity) cell would always match
    the background of the widget in the first rendering phase (when the
    VIEW class is used). Well, this assumption is not correct as soon as we
    find one case that refutes it: Ambience, the default Ubuntu (13.04)
    theme. Because of this, we need to draw the background of all cells
    (with the CELL class added, yes) regardless of the RulesHint property
    or the parity.
    
    Now, you may ask why after these 2 commits the rules still don't
    appear to work in Banshee GTK3? Well, we have to blame now the theme,
    because even if some work was done[3] in the past to allow stripped
    treeviews in general (affecting all apps which used GtkTreeViews
    configured with rules-hint==True), the bug has re-appeared again,
    and its fix wouldn't even work yet with Banshee (because it targets
    just the GtkTreeView particular widget instead of using the CSS class
    CELL mentioned earlier).
    
    [1] https://git.gnome.org/browse/hyena/commit/?h=gtk3&id=fd1adee656c0cb8be825f5e9b02c686cb1e46e3f
    [2] https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c
    [3] https://bugs.launchpad.net/bugs/945430

 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs 
b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 852f2cb..4b93f4e 100644
--- a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -132,9 +132,10 @@ namespace Hyena.Data.Gui
             }
             // treview style
             StyleContext.Save ();
-            StyleContext.AddClass ("cell");
 
+            StyleContext.AddClass ("view");
             StyleContext.RenderBackground (cr, 0, 0, Allocation.Width, Allocation.Height);
+            StyleContext.RemoveClass ("view");
 
             // FIXME: ViewLayout will never be null in the future but we'll need
             // to deterministically render a header somehow...
@@ -309,12 +310,13 @@ namespace Hyena.Data.Gui
                         selected_focus_alloc = single_list_alloc;
                     }
                 } else {
-                    if (rules_hint && ri % 2 != 0) {
-                        StyleContext.AddRegion ("row", RegionFlags.Odd);
-                        StyleContext.RenderBackground (cr, single_list_alloc.X, single_list_alloc.Y,
-                            single_list_alloc.Width, single_list_alloc.Height);
-                        StyleContext.RemoveRegion ("row");
+                    StyleContext.AddClass ("cell");
+                    if (rules_hint) { // TODO: check also 
gtk_widget_style_get(widget,"allow-rules",&allow_rules,NULL);
+                        StyleContext.AddRegion ("row", ri % 2 != 0 ? RegionFlags.Odd : RegionFlags.Even);
                     }
+                    StyleContext.RenderBackground (cr, single_list_alloc.X, single_list_alloc.Y,
+                        single_list_alloc.Width, single_list_alloc.Height);
+                    StyleContext.RemoveRegion ("row");
 
                     PaintReorderLine (cr, ri, single_list_alloc);
 


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