[california] Prevent black background for Agenda view w/ Unity: Bug #742310



commit f540528b51f775d88cee82c7dbabc43f65a945b5
Author: Jim Nelson <jim yorba org>
Date:   Tue Jan 6 15:45:08 2015 -0800

    Prevent black background for Agenda view w/ Unity: Bug #742310
    
    Black background fix was originally only seen with Toolkit.Decks, but
    Agenda view appears to have introduced it into main view, so a more
    generic solution is required.

 src/toolkit/toolkit-deck.vala          |   20 +++-----------------
 src/toolkit/toolkit.vala               |   29 +++++++++++++++++++++++++++++
 src/view/agenda/agenda-controller.vala |    2 ++
 src/view/month/month-controller.vala   |    1 +
 4 files changed, 35 insertions(+), 17 deletions(-)
---
diff --git a/src/toolkit/toolkit-deck.vala b/src/toolkit/toolkit-deck.vala
index 224cb61..b51ffb2 100644
--- a/src/toolkit/toolkit-deck.vala
+++ b/src/toolkit/toolkit-deck.vala
@@ -81,13 +81,13 @@ public class Deck : Gtk.Stack {
         
         if (home != null)
             add_card(home);
+        
+        Toolkit.unity_fixup_background(this);
     }
     
     ~Deck() {
-        foreach (Card card in ids.values) {
+        foreach (Card card in ids.values)
             card.map.disconnect(on_card_mapped);
-            card.realize.disconnect(on_card_realized);
-        }
     }
     
     private void on_child_to_top() {
@@ -156,9 +156,6 @@ public class Deck : Gtk.Stack {
             // i.e. home)
             card.map.connect(on_card_mapped);
             
-            // some theme issues with Unity
-            card.realize.connect(on_card_realized);
-            
             // add in order to ensure order is preserved if sparsely removed later
             list.add(card);
         }
@@ -190,7 +187,6 @@ public class Deck : Gtk.Stack {
             }
             
             card.map.disconnect(on_card_mapped);
-            card.realize.disconnect(on_card_realized);
             
             remove(card);
             
@@ -315,16 +311,6 @@ public class Deck : Gtk.Stack {
                 message("Card %s specifies initial focus that cannot focus", card.card_id);
         }
     }
-    
-    // When a child GtkScrolledWindow is visible, the entire GtkStack's background color goes black;
-    // this overrides the color and uses the toplevel's background color for the Card.  See:
-    // https://bugzilla.gnome.org/show_bug.cgi?id=735421
-    private void on_card_realized(Gtk.Widget card) {
-#if ENABLE_UNITY
-        Gdk.RGBA bg = card.get_toplevel().get_style_context().get_background_color(Gtk.StateFlags.NORMAL);
-        card.override_background_color(Gtk.StateFlags.NORMAL, bg);
-#endif
-    }
 }
 
 }
diff --git a/src/toolkit/toolkit.vala b/src/toolkit/toolkit.vala
index 7ade342..029137e 100644
--- a/src/toolkit/toolkit.vala
+++ b/src/toolkit/toolkit.vala
@@ -165,4 +165,33 @@ private void on_state_flags_changed(Gtk.Widget widget, Gtk.StateFlags old_state_
         widget.unset_state_flags(Gtk.StateFlags.PRELIGHT);
 }
 
+/**
+ * When a child GtkScrolledWindow is visible, the entire GtkStack's background color goes black;
+ * this overrides the color and uses the toplevel's background color for the child widget.  See:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=735421
+ * and https://bugzilla.gnome.org/show_bug.cgi?id=742310
+ */
+public void unity_fixup_background(Gtk.Widget widget) {
+#if ENABLE_UNITY
+    widget.realize.connect(on_unity_fixup_realize);
+    
+    Gtk.Container? container = widget as Gtk.Container;
+    if (container == null)
+        return;
+    
+    // Fixup all existing children
+    container.foreach(unity_fixup_background);
+    
+    // Fixup all added children
+    container.add.connect(unity_fixup_background);
+#endif
+}
+
+#if ENABLE_UNITY
+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);
+}
+#endif
+
 }
diff --git a/src/view/agenda/agenda-controller.vala b/src/view/agenda/agenda-controller.vala
index 3b85944..8e8f459 100644
--- a/src/view/agenda/agenda-controller.vala
+++ b/src/view/agenda/agenda-controller.vala
@@ -72,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 5a588a0..bb284fe 100644
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@ -90,6 +90,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]