[hyena/gtk3] Theming: Remove the GtkColors class



commit 078d7dccfbbc924c45bced66746b625594588b74
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Fri Jul 15 19:51:54 2011 +0200

    Theming: Remove the GtkColors class
    
    GtkColors was providing a quick color lookup for various color types
    (foreground, background, text, dark, etc.) for all possible widget
    states.
    With the new theming infrastructure in GTK 3, colors can now depend on
    the style class: "background", "button", "entry", etc.
    So keeping a lookup cache for colors is not feasible anymore. Widgets
    should use the StyleContext API to figure out their colors.

 Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs |  157 ------------------------------
 Hyena.Gui/Hyena.Gui.Theming/Theme.cs     |   20 ++---
 Hyena.Gui/Hyena.Gui.csproj               |    1 -
 Hyena.Gui/Makefile.am                    |    1 -
 4 files changed, 7 insertions(+), 172 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Theming/Theme.cs b/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
index f5d47bc..f9adfd6 100644
--- a/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
+++ b/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
@@ -40,7 +40,6 @@ namespace Hyena.Gui.Theming
     {
         private static Cairo.Color black = new Cairo.Color (0, 0, 0);
         private Stack<ThemeContext> contexts = new Stack<ThemeContext> ();
-        private GtkColors colors;
 
         private Cairo.Color selection_fill;
         private Cairo.Color selection_stroke;
@@ -50,22 +49,17 @@ namespace Hyena.Gui.Theming
 
         private Cairo.Color text_mid;
 
-        public GtkColors Colors {
-            get { return colors; }
-        }
-
         public Widget Widget { get; private set; }
 
-        public Theme (Widget widget) : this (widget, new GtkColors ())
-        {
-        }
-
-        public Theme (Widget widget, GtkColors colors)
+        public Theme (Widget widget)
         {
             this.Widget = widget;
-            this.colors = colors;
-            this.colors.Refreshed += delegate { OnColorsRefreshed (); };
-            this.colors.Widget = widget;
+            if (widget.IsRealized) {
+                OnColorsRefreshed ();
+            }
+
+            widget.Realized += delegate { OnColorsRefreshed (); };
+            widget.StyleUpdated += delegate { OnColorsRefreshed (); };
 
             PushContext ();
         }
diff --git a/Hyena.Gui/Hyena.Gui.csproj b/Hyena.Gui/Hyena.Gui.csproj
index 1e59adb..43c60e7 100644
--- a/Hyena.Gui/Hyena.Gui.csproj
+++ b/Hyena.Gui/Hyena.Gui.csproj
@@ -129,7 +129,6 @@
     <Compile Include="Hyena.Widgets\MessageBar.cs" />
     <Compile Include="Hyena.Widgets\AnimatedImage.cs" />
     <Compile Include="Hyena.Gui.Theming\Theme.cs" />
-    <Compile Include="Hyena.Gui.Theming\GtkColors.cs" />
     <Compile Include="Hyena.Gui.Theming\ThemeContext.cs" />
     <Compile Include="Hyena.Gui.Theming\ThemeEngine.cs" />
     <Compile Include="Hyena.Gui.Theming\GtkTheme.cs" />
diff --git a/Hyena.Gui/Makefile.am b/Hyena.Gui/Makefile.am
index e8767ee..175f279 100644
--- a/Hyena.Gui/Makefile.am
+++ b/Hyena.Gui/Makefile.am
@@ -75,7 +75,6 @@ SOURCES =  \
 	Hyena.Gui.Theatrics/SingleActorStage.cs \
 	Hyena.Gui.Theatrics/Stage.cs \
 	Hyena.Gui.Theatrics/Tests/ChoreographerTests.cs \
-	Hyena.Gui.Theming/GtkColors.cs \
 	Hyena.Gui.Theming/GtkTheme.cs \
 	Hyena.Gui.Theming/Theme.cs \
 	Hyena.Gui.Theming/ThemeContext.cs \



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