[hyena/gtk3] [gt3] Fix warning on theming but still have to migrate GtkColors system



commit 4aea7823e634e9fb3b6c19bdc281a782f0ecb208
Author: Olivier Dufour <olivier duff gmail com>
Date:   Tue May 3 13:38:55 2011 +0200

    [gt3] Fix warning on theming but still have to migrate GtkColors system

 Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs       |   27 ++++++++++++-----------
 Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs        |    9 +++++--
 Hyena.Gui/Hyena.Gui.Theming/ThemeTestModule.cs |    4 +-
 3 files changed, 22 insertions(+), 18 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs b/Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs
index 4e73dec..9da90fe 100644
--- a/Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs
+++ b/Hyena.Gui/Hyena.Gui.Theming/GtkColors.cs
@@ -34,15 +34,15 @@ namespace Hyena.Gui.Theming
 {
     public enum GtkColorClass
     {
+        Base,
         Light,
-        Mid,
         Dark,
-        Base,
         Text,
+        Border,
         Background,
         Foreground
     }
-
+// TODO remove base text light datk when all migration done on widgets
     public class GtkColors
     {
         private Cairo.Color [] gtk_colors;
@@ -58,7 +58,7 @@ namespace Hyena.Gui.Theming
                     return;
                 } else if (widget != null) {
                     widget.Realized -= OnWidgetRealized;
-                    widget.StyleSet -= OnWidgetStyleSet;
+                    widget.StyleUpdated -= OnWidgetStyleUpdated;
                 }
 
                 widget = value;
@@ -68,7 +68,7 @@ namespace Hyena.Gui.Theming
                 }
 
                 widget.Realized += OnWidgetRealized;
-                widget.StyleSet += OnWidgetStyleSet;
+                widget.StyleUpdated += OnWidgetStyleUpdated;
             }
         }
 
@@ -81,7 +81,7 @@ namespace Hyena.Gui.Theming
             RefreshColors ();
         }
 
-        private void OnWidgetStyleSet (object o, StyleSetArgs args)
+        private void OnWidgetStyleUpdated (object o, EventArgs args)
         {
             RefreshColors ();
         }
@@ -103,16 +103,18 @@ namespace Hyena.Gui.Theming
 
             refreshing = true;
 
-            int sn = (int)StateType.Insensitive + 1;
+            int sn = (int)StateType.Insensitive + 1;//5
             int cn = (int)GtkColorClass.Foreground + 1;
 
             if (gtk_colors == null) {
                 gtk_colors = new Cairo.Color[sn * cn];
             }
 
+            StateFlags[] states = new StateFlags[] {StateFlags.Normal, StateFlags.Active, StateFlags.Prelight, StateFlags.Selected, StateFlags.Insensitive, StateFlags.Inconsistent, StateFlags.Focused};
+
             for (int c = 0, i = 0; c < cn; c++) {
                 for (int s = 0; s < sn; s++, i++) {
-                    Gdk.Color color = Gdk.Color.Zero;
+                    Gdk.RGBA color = Gdk.RGBA.Zero;
 
                     if (widget != null && widget.IsRealized) {
                         switch ((GtkColorClass)c) {
@@ -121,14 +123,13 @@ namespace Hyena.Gui.Theming
                             case GtkColorClass.Dark:       color = widget.Style.DarkColors[s];  break;
                             case GtkColorClass.Base:       color = widget.Style.BaseColors[s];  break;
                             case GtkColorClass.Text:       color = widget.Style.TextColors[s];  break;
-                            case GtkColorClass.Background: color = widget.Style.Backgrounds[s]; break;
-                            case GtkColorClass.Foreground: color = widget.Style.Foregrounds[s]; break;
+                            case GtkColorClass.Border:     widget.StyleContext.GetBorderColor (states[s], color); break;
+                            case GtkColorClass.Background: color = widget.StyleContext.GetBackgroundColor (states[s]); break;
+                            case GtkColorClass.Foreground: widget.StyleContext.GetColor (states[s], color); break;
                         }
-                    } else {
-                        color = new Gdk.Color (0, 0, 0);
                     }
 
-                    gtk_colors[c * sn + s] = CairoExtensions.GdkColorToCairoColor (color);
+                    gtk_colors[c * sn + s] = new Cairo.Color (color.Red, color.Green, color.Blue, color.Alpha);
                 }
             }
 
diff --git a/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs b/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
index 0d37799..99f0050 100644
--- a/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
+++ b/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
@@ -43,8 +43,11 @@ namespace Hyena.Gui.Theming
 
         public static Cairo.Color GetCairoTextMidColor (Widget widget)
         {
-            Cairo.Color text_color = CairoExtensions.GdkColorToCairoColor (widget.Style.Foreground (StateType.Normal));
-            Cairo.Color background_color = CairoExtensions.GdkColorToCairoColor (widget.Style.Background (StateType.Normal));
+			Gdk.RGBA color;
+			widget.StyleContext.GetColor (StateFlags.Normal, color);
+            Cairo.Color text_color = new Cairo.Color (color.Red, color.Green, color.Blue, color.Alpha);
+			color = widget.StyleContext.GetBackgroundColor (StateFlags.Normal);
+            Cairo.Color background_color = new Cairo.Color (color.Red, color.Green, color.Blue, color.Alpha);
             return CairoExtensions.AlphaBlend (text_color, background_color, 0.5);
         }
 
@@ -55,7 +58,7 @@ namespace Hyena.Gui.Theming
             rule_color = CairoExtensions.ColorShade (ViewFill, 0.95);
 
             // On Windows we use Normal b/c Active incorrectly returns black (at least on XP)
-            border_color = Colors.GetWidgetColor (GtkColorClass.Dark,
+            border_color = Colors.GetWidgetColor (GtkColorClass.Border,
               Hyena.PlatformDetection.IsWindows ? StateType.Normal : StateType.Active
             );
         }
diff --git a/Hyena.Gui/Hyena.Gui.Theming/ThemeTestModule.cs b/Hyena.Gui/Hyena.Gui.Theming/ThemeTestModule.cs
index 9ad741f..a3ca911 100644
--- a/Hyena.Gui/Hyena.Gui.Theming/ThemeTestModule.cs
+++ b/Hyena.Gui/Hyena.Gui.Theming/ThemeTestModule.cs
@@ -73,9 +73,9 @@ namespace Hyena.Gui.Theming
         {
             private Theme theme;
 
-            protected override void OnStyleSet (Style previous_style)
+            protected override void OnStyleUpdated ()
             {
-                base.OnStyleSet (previous_style);
+                base.OnStyleUpdated ();
                 theme = ThemeEngine.CreateTheme (this);
                 theme.Context.Radius = 10;
             }



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