[california/wip/742310-black] More generic solution



commit d20ac76933a20f4838b41d2f4181a450b54d3944
Author: Jim Nelson <jim yorba org>
Date:   Tue Jan 6 15:20:20 2015 -0800

    More generic solution

 src/toolkit/toolkit.vala               |   16 ++++++++++++++++
 src/view/agenda/agenda-controller.vala |    7 ++-----
 src/view/month/month-controller.vala   |    1 +
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/toolkit/toolkit.vala b/src/toolkit/toolkit.vala
index 7ade342..27f0298 100644
--- a/src/toolkit/toolkit.vala
+++ b/src/toolkit/toolkit.vala
@@ -165,4 +165,20 @@ private void on_state_flags_changed(Gtk.Widget widget, Gtk.StateFlags old_state_
         widget.unset_state_flags(Gtk.StateFlags.PRELIGHT);
 }
 
+public void unity_fixup_background(Gtk.Widget widget) {
+    widget.realize.connect(on_unity_fixup_realize);
+    
+    Gtk.Container? container = widget as Gtk.Container;
+    if (container == null)
+        return;
+    
+    container.foreach(unity_fixup_background);
+    container.add.connect(unity_fixup_background);
+}
+
+private void on_unity_fixup_realize(Gtk.Widget widget) {
+    Gdk.RGBA bg = widget.get_toplevel().get_style_context().get_background_color(Gtk.StateFlags.NORMAL);
+    widget.override_background_color(Gtk.StateFlags.NORMAL, bg);
+}
+
 }
diff --git a/src/view/agenda/agenda-controller.vala b/src/view/agenda/agenda-controller.vala
index 710e8f9..8e8f459 100644
--- a/src/view/agenda/agenda-controller.vala
+++ b/src/view/agenda/agenda-controller.vala
@@ -19,11 +19,6 @@ public class Controller : BaseObject, View.Controllable {
             _owner = controller;
             
             add_with_viewport(child);
-            
-            child.realize.connect(() => {
-                Gdk.RGBA bg = 
child.get_toplevel().get_style_context().get_background_color(Gtk.StateFlags.NORMAL);
-                child.override_background_color(Gtk.StateFlags.NORMAL, bg);
-            });
         }
     }
     
@@ -77,6 +72,8 @@ public class Controller : BaseObject, View.Controllable {
         this.palette = palette;
         
         container = new Container(this, listbox);
+        Toolkit.unity_fixup_background(container);
+        
         listbox_model = new Toolkit.ListBoxModel<Calendar.Date>(listbox, model_presentation);
         
         // Don't prelight the DateRows, as they can't be selected or activated
diff --git a/src/view/month/month-controller.vala b/src/view/month/month-controller.vala
index 4402461..67e7a3c 100644
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@ -99,6 +99,7 @@ public class Controller : BaseObject, View.Controllable {
         master_grid.row_homogeneous = false;
         master_grid.row_spacing = 0;
         master_grid.expand = true;
+        Toolkit.unity_fixup_background(master_grid);
         
         stack.transition_duration = Toolkit.SLOW_STACK_TRANSITION_DURATION_MSEC;
         


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