[hyena/gtk3: 9/13] [GTK3] Fix 20 warnings more



commit 2611349bd473124044c9b3f943f7206473e43935
Author: Olivier Dufour <olivier duff gmail com>
Date:   Fri Apr 22 23:39:53 2011 +0200

    [GTK3] Fix 20 warnings more

 Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs |    6 ++++-
 Hyena.Gui/Hyena.Widgets/GrabHandle.cs      |    9 ++++++-
 Hyena.Gui/Hyena.Widgets/MenuButton.cs      |    9 +++----
 Hyena.Gui/Hyena.Widgets/RatingEntry.cs     |   13 +++++++---
 Hyena.Gui/Hyena.Widgets/RoundedFrame.cs    |    3 +-
 Hyena.Gui/Hyena.Widgets/SegmentedBar.cs    |    3 +-
 Hyena.Gui/Hyena.Widgets/WrapLabel.cs       |   32 +++++++++++++++++++++++++--
 7 files changed, 58 insertions(+), 17 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs b/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
index d662b62..f231ac9 100644
--- a/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
+++ b/Hyena.Gui/Hyena.Widgets/ComplexMenuItem.cs
@@ -81,7 +81,9 @@ namespace Hyena.Widgets
                 width = Allocation.Width;
                 height = Allocation.Height;
 
-                ShadowType shadow_type = (ShadowType)StyleGetProperty("selected-shadow-type");
+                //ShadowType shadow_type = (ShadowType)StyleGetProperty("selected-shadow-type");
+                StyleContext.State = StateFlags.Prelight | StateFlags.Selected;
+                Gtk.Render.Frame (StyleContext, args.Cr, x, y, width, height);
                 Gtk.Render.Background (StyleContext, args.Cr, x, y, width, height);
                 //Gtk.Style.PaintBox(Style, args.Cr, StateType.Prelight, shadow_type,
                 //    widget, "menuitem", x, y, width, height);
@@ -107,6 +109,8 @@ namespace Hyena.Widgets
                 y = Parent.Allocation.Y - widget.Allocation.Y;
                 width = Parent.Allocation.Width;
                 height = Parent.Allocation.Height;
+                StyleContext.State = StateFlags.Normal;
+                Gtk.Render.Frame (StyleContext, args.Cr, x, y, width, height);
                 Gtk.Render.Background (StyleContext, args.Cr, x, y, width, height);
                 //Gtk.Style.PaintBox(Style, args.Cr, StateType.Normal, ShadowType.Out,
                 //    widget, "menu", x, y, width, height);
diff --git a/Hyena.Gui/Hyena.Widgets/GrabHandle.cs b/Hyena.Gui/Hyena.Widgets/GrabHandle.cs
index e9a5c67..28dd833 100644
--- a/Hyena.Gui/Hyena.Widgets/GrabHandle.cs
+++ b/Hyena.Gui/Hyena.Widgets/GrabHandle.cs
@@ -53,8 +53,13 @@ namespace Hyena.Widgets
 
             da.Drawn += (o, a) => {
                 if (da.IsDrawable) {
-                    Gtk.Style.PaintHandle (da.Style, a.Cr, da.State, ShadowType.In,
-                        this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation);
+                    //TODO: check if transform is needed for render funct, but seems not according to this example:
+                    //http://developer.gnome.org/gtk3/stable/GtkStyleContext.html#id545216
+                    //CairoHelper.TransformToWindow (a.Cr, da, da.Window);
+                    da.StyleContext.State = StateFlags.Active;
+                    Gtk.Render.Handle (da.StyleContext, a.Cr, 0, 0, da.Allocation.Width, da.Allocation.Height);
+                    //Gtk.Style.PaintHandle (da.Style, a.Cr, da.State, ShadowType.In,
+                    //    this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation);
                 }
             };
         }
diff --git a/Hyena.Gui/Hyena.Widgets/MenuButton.cs b/Hyena.Gui/Hyena.Widgets/MenuButton.cs
index 622b114..de509f9 100644
--- a/Hyena.Gui/Hyena.Widgets/MenuButton.cs
+++ b/Hyena.Gui/Hyena.Widgets/MenuButton.cs
@@ -123,14 +123,12 @@ namespace Hyena.Widgets
 
         protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
         {
-            var requisition = size_widget.SizeRequest ();
-            minimum_height = natural_height = requisition.Height;
+            size_widget.GetPreferredHeight (out minimum_height, out natural_height);
         }
 
         protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
         {
-            var requisition = size_widget.SizeRequest ();
-            minimum_width = natural_width = requisition.Width;
+            size_widget.GetPreferredHeight (out minimum_width, out natural_width);
         }
 
         protected override void OnSizeAllocated (Rectangle allocation)
@@ -161,7 +159,8 @@ namespace Hyena.Widgets
 
         private void PositionMenu (Menu menu, out int x, out int y, out bool push_in)
         {
-            Gtk.Requisition menu_req = menu.SizeRequest ();
+            Gtk.Requisition menu_req, nat_req;
+            menu.GetPreferredSize (menu_req, nat_req);
             int monitor_num = Screen.GetMonitorAtWindow (Window);
             Gdk.Rectangle monitor = Screen.GetMonitorGeometry (monitor_num < 0 ? 0 : monitor_num);
 
diff --git a/Hyena.Gui/Hyena.Widgets/RatingEntry.cs b/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
index d4405f6..4accfd1 100644
--- a/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
+++ b/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
@@ -274,10 +274,15 @@ namespace Hyena.Widgets
 
             if (HasFrame) {
                 int y_mid = (int)Math.Round ((Allocation.Height - renderer.Height) / 2.0);
-                Gtk.Style.PaintFlatBox (Style, cr, State, ShadowType.None, this, "entry",
-                    Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
-                Gtk.Style.PaintShadow (Style, cr, State, ShadowType.In,
-                    this, "entry", Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
+                this.StyleContext.State = StateFlags.Normal;
+                Gtk.Render.Frame (StyleContext, cr, Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
+                Gtk.Render.Background (StyleContext, cr, Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
+                //Gtk.Style.PaintFlatBox (Style, cr, State, ShadowType.None, this, "entry",
+                //    Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
+                this.StyleContext.State = StateFlags.Active;
+                Gtk.Render.Frame (StyleContext, cr, Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
+                //Gtk.Style.PaintShadow (Style, cr, State, ShadowType.In,
+                //    this, "entry", Allocation.X, Allocation.Y + y_mid, Allocation.Width, renderer.Height);
             }
 
             CairoHelper.TransformToWindow (cr, this, Window);
diff --git a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
index 2e6a1e1..fb213d9 100644
--- a/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
+++ b/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
@@ -112,7 +112,8 @@ namespace Hyena.Widgets
             var requisition = new Requisition ();
             if (child != null && child.Visible) {
                 // Add the child's width/height
-                Requisition child_requisition = child.SizeRequest ();
+                Requisition child_requisition, nat_requisition;
+                child.GetPreferredSize (child_requisition, nat_requisition);
                 requisition.Width = Math.Max (0, child_requisition.Width);
                 requisition.Height = child_requisition.Height;
             } else {
diff --git a/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs b/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
index 9fdbdc2..54d42c8 100644
--- a/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
+++ b/Hyena.Gui/Hyena.Widgets/SegmentedBar.cs
@@ -627,7 +627,8 @@ namespace Hyena.Widgets
             SetSizeRequest (350, -1);
 
             Gdk.Geometry limits = new Gdk.Geometry ();
-            limits.MinWidth = SizeRequest ().Width;
+            int nat_width;
+            GetPreferredWidth (out limits.MinWidth, out nat_width);
             limits.MaxWidth = Gdk.Screen.Default.Width;
             limits.MinHeight = -1;
             limits.MaxHeight = -1;
diff --git a/Hyena.Gui/Hyena.Widgets/WrapLabel.cs b/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
index 74cf9a7..1e794e9 100644
--- a/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
+++ b/Hyena.Gui/Hyena.Widgets/WrapLabel.cs
@@ -107,9 +107,35 @@ namespace Hyena.Widgets
                 int lw, lh;
                 layout.GetPixelSize (out lw, out lh);
                 int y = Allocation.Y + (Allocation.Height - lh) / 2;
+                
+                //TODO include in a utils class or find one in gtk
+                switch (State) {
+                    case StateType.Active:
+                        StyleContext.State = StateFlags.Active;
+                    break;
+                    case StateType.Focused:
+                        StyleContext.State = StateFlags.Selected;
+                    break;
+                    case StateType.Inconsistent:
+                        StyleContext.State = StateFlags.Inconsistent;
+                    break;
+                    case StateType.Insensitive:
+                        StyleContext.State = StateFlags.Insensitive;
+                    break;
+                    case StateType.Normal:
+                        StyleContext.State = StateFlags.Normal;
+                    break;
+                    case StateType.Prelight:
+                        StyleContext.State = StateFlags.Prelight;
+                    break;
+                    case StateType.Selected:
+                        StyleContext.State = StateFlags.Selected;
+                    break;
+                }
 
-                Gtk.Style.PaintLayout (Style, cr, State, false,
-                    this, null, Allocation.X, y, layout);
+                Gtk.Render.Layout (StyleContext, cr, Allocation.X, y, layout);
+                //Gtk.Style.PaintLayout (Style, cr, State, false,
+                //    this, null, Allocation.X, y, layout);
             }
 
             return true;



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