[hyena/gtk3] [gtk3] Fix style warning in widgets



commit 2acaf1a78dc9afed7b153e37332794191e7afc6b
Author: Olivier Dufour <olivier duff gmail com>
Date:   Tue May 3 13:34:08 2011 +0200

    [gtk3] Fix style warning in widgets

 Hyena.Gui/Hyena.Gui/GtkUtilities.cs        |    6 +++---
 Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs  |    3 +--
 Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs |    2 +-
 Hyena.Gui/Hyena.Widgets/MessageBar.cs      |   25 +++----------------------
 Hyena.Gui/Hyena.Widgets/PulsingButton.cs   |    3 ++-
 Hyena.Gui/Hyena.Widgets/RatingEntry.cs     |    2 --
 Hyena.Gui/Hyena.Widgets/RoundedFrame.cs    |    4 ++--
 Hyena.Gui/Hyena.Widgets/SegmentedBar.cs    |    4 +++-
 Hyena.Gui/Hyena.Widgets/WrapLabel.cs       |    4 ++--
 9 files changed, 17 insertions(+), 36 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui/GtkUtilities.cs b/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
index b50d1bb..2fe635c 100644
--- a/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
+++ b/Hyena.Gui/Hyena.Gui/GtkUtilities.cs
@@ -128,15 +128,15 @@ namespace Hyena.Gui
 
         public static void AdaptGtkRcStyle (Widget adaptee, GLib.GType adapter, string widgetPath, string classPath)
         {
-            Style style = Gtk.Rc.GetStyleByPaths (adaptee.Settings, widgetPath, classPath, adapter);
+            StyleContext style = Gtk.Rc.GetStyleByPaths (adaptee.Settings, widgetPath, classPath, adapter);
             if (style == null) {
                 return;
             }
 
-            foreach (StateType state in Enum.GetValues (typeof (StateType))) {
+            foreach (StateFlags state in Enum.GetValues (typeof (StateFlags))) {
                 adaptee.ModifyBase (state, style.Base (state));
                 adaptee.ModifyBg (state, style.Background (state));
-                adaptee.ModifyFg (state, style.Foreground (state));
+                adaptee.OverrideColor (state, style.Foreground (state));
                 adaptee.ModifyText (state, style.Text (state));
             }
         }
diff --git a/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs b/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
index dd3661e..fdbf4ea 100644
--- a/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
+++ b/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
@@ -126,8 +126,7 @@ namespace Hyena.Widgets
 
             Window = new Gdk.Window (Parent.Window, attributes, 0);
             Window.UserData = Handle;
-            Window.Background = Style.Background (State);
-            Style.Attach (Window);
+            Window.BackgroundRgba = StyleContext.GetBackgroundColor (StateFlags);
         }
 
         protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
diff --git a/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs b/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
index f231ac9..1128813 100644
--- a/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
+++ b/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
@@ -91,7 +91,7 @@ namespace Hyena.Widgets
 
                 args.Cr.Save ();
 
-                var color = Parent.Style.Background (StateType.Normal);
+                var color = Parent.StyleContext.GetBackgroundColor (StateFlags.Normal);
                 // Fill only the visible area in solid color, to be most efficient
                 args.Cr.SetSourceRGB (color.Red, color.Green, color.Blue);
                 args.Cr.Rectangle (0, 0, widget.Allocation.Width, widget.Allocation.Height);
diff --git a/Hyena.Gui/Hyena.Widgets/MessageBar.cs b/Hyena.Gui/Hyena.Widgets/MessageBar.cs
index c0f6d11..569ecbb 100644
--- a/Hyena.Gui/Hyena.Widgets/MessageBar.cs
+++ b/Hyena.Gui/Hyena.Widgets/MessageBar.cs
@@ -55,10 +55,6 @@ namespace Hyena.Widgets
         {
             win = new Window (WindowType.Popup);
             win.Name = "gtk-tooltips";
-            win.EnsureStyle ();
-            win.StyleSet += delegate {
-                Style = win.Style;
-            };
 
             HBox shell_box = new HBox ();
             shell_box.Spacing = 10;
@@ -99,8 +95,6 @@ namespace Hyena.Widgets
 
             Add (shell_box);
 
-            EnsureStyle ();
-
             BorderWidth = 3;
         }
 
@@ -133,25 +127,12 @@ namespace Hyena.Widgets
             cr.Save ();
             CairoHelper.TransformToWindow (cr, this, Window);
 
-            Gdk.Color color = Style.Background (StateType.Normal);
-            theme.DrawFrame (cr, Allocation, CairoExtensions.GdkColorToCairoColor (color));
+            Gdk.RGBA color = StyleContext.GetBackgroundColor (StateFlags.Normal);
+            theme.DrawFrame (cr, Allocation, new Cairo.Color (color.Red, color.Green, color.Blue, color.Alpha));
             cr.Restore ();
             return base.OnDrawn (cr);
         }
-
-        private bool changing_style = false;
-        protected override void OnStyleSet (Gtk.Style previousStyle)
-        {
-            if (changing_style) {
-                return;
-            }
-
-            changing_style = true;
-            Style = win.Style;
-            label.Style = Style;
-            changing_style = false;
-        }
-
+		
         public void RemoveButton (Button button)
         {
             button_box.Remove (button);
diff --git a/Hyena.Gui/Hyena.Widgets/PulsingButton.cs b/Hyena.Gui/Hyena.Widgets/PulsingButton.cs
index 953e0bf..e6d9d95 100644
--- a/Hyena.Gui/Hyena.Widgets/PulsingButton.cs
+++ b/Hyena.Gui/Hyena.Widgets/PulsingButton.cs
@@ -96,7 +96,8 @@ namespace Hyena.Widgets
             double r = Math.Min (Allocation.Width, Allocation.Height) / 2;
             double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine);
 
-            Cairo.Color color = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Selected));
+			Gdk.RGBA rgba = StyleContext.GetBackgroundColor (StateFlags.Selected);
+			Cairo.Color color = new Cairo.Color (rgba.Red, rgba.Green, rgba.Blue, rgba.Alpha);
             Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r);
             color.A = alpha;
             fill.AddColorStop (0, color);
diff --git a/Hyena.Gui/Hyena.Widgets/RatingEntry.cs b/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
index 957cad9..1f02384 100644
--- a/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
+++ b/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
@@ -246,8 +246,6 @@ namespace Hyena.Widgets
         protected Requisition SizeRequested ()
         {
             var requisition = new Requisition ();
-            //TODO check if exist equivalent in stylecontext that I do not found...
-            //EnsureStyle ();
 
             Pango.FontMetrics metrics = PangoContext.GetMetrics (StyleContext.GetFont (StateFlags), PangoContext.Language);
             renderer.Size = ((int)(metrics.Ascent + metrics.Descent) + 512) >> 10; // PANGO_PIXELS(d)
diff --git a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
index fb213d9..bc32d99 100644
--- a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
+++ b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
@@ -88,9 +88,9 @@ namespace Hyena.Widgets
 
 #region Gtk.Widget Overrides
 
-        protected override void OnStyleSet (Style previous_style)
+        protected override void OnStyleUpdated ()
         {
-            base.OnStyleSet (previous_style);
+            base.OnStyleUpdated ();
             theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
             frame_width = (int)theme.Context.Radius + 1;
         }
diff --git a/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs b/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
index 54d42c8..b1dcadf 100644
--- a/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
+++ b/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
@@ -484,7 +484,9 @@ namespace Hyena.Widgets
             }
 
             Pango.Layout layout = null;
-            Color text_color = CairoExtensions.GdkColorToCairoColor (Style.Foreground (State));
+			Gdk.RGBA rgba;
+			StyleContext.GetColor (StateFlags, rgba);
+            Color text_color = new Cairo.Color (rgba.Red, rgba.Green, rgba.Blue, rgba.Alpha);
             Color box_stroke_color = new Color (0, 0, 0, 0.6);
 
             int x = 0;
diff --git a/Hyena.Gui/Hyena.Widgets/WrapLabel.cs b/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
index 1e794e9..93ea92a 100644
--- a/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
+++ b/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
@@ -74,11 +74,11 @@ namespace Hyena.Widgets
             QueueResize ();
         }
 
-        protected override void OnStyleSet (Style previous_style)
+        protected override void OnStyleUpdated ()
         {
             CreateLayout ();
             UpdateLayout ();
-            base.OnStyleSet (previous_style);
+            base.OnStyleUpdated ();
         }
 
         protected override void OnRealized ()



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