[banshee/gtk3: 2/8] Start porting some API usage to 3.x



commit 8893491eb20988747b3a584def3f42045813d802
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Thu Apr 21 19:24:19 2011 +0200

    Start porting some API usage to 3.x
    
    This commit includes Lastfm.Gui and some straightforward changes in
    Banshee.Widgets. Still a long way to go.

 .../Banshee.Widgets/CustomActionProxy.cs           |    5 ++-
 .../Banshee.Widgets/DiscUsageDisplay.cs            |    5 +--
 .../Banshee.Widgets/HoverImageButton.cs            |    6 ++--
 .../Banshee.Widgets/LinearProgress.cs              |    6 ++--
 .../Banshee.Widgets/Banshee.Widgets/LinkLabel.cs   |   33 ++++++++++++++------
 .../Banshee.Widgets/Banshee.Widgets/SearchEntry.cs |   10 +++---
 .../Banshee.Widgets/StreamPositionLabel.cs         |   19 +++++++++--
 .../Banshee.Widgets/VolumeButton.cs                |    8 ++--
 .../Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs    |    9 ++---
 9 files changed, 62 insertions(+), 39 deletions(-)
---
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs
index d28a505..349f67d 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs
@@ -117,8 +117,9 @@ namespace Banshee.Widgets
                 }
             }
 
-            if (item != null) {
-                action.ConnectProxy (item);
+            var activatable = item as Activatable;
+            if (activatable != null) {
+                activatable.RelatedAction = action;
             }
         }
 
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/DiscUsageDisplay.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/DiscUsageDisplay.cs
index 3760b56..7acb5b1 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/DiscUsageDisplay.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/DiscUsageDisplay.cs
@@ -104,13 +104,13 @@ namespace Banshee.Widgets
             base.OnSizeAllocated(rect);
         }
 
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
             if(!IsRealized) {
                 return false;
             }
 
-            Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow);
+            CairoHelper.TransformToWindow (cr, this, GdkWindow);
 
             foreach(Gdk.Rectangle rect in evnt.Region.GetRectangles()) {
                 cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
@@ -118,7 +118,6 @@ namespace Banshee.Widgets
                 Draw(cr);
             }
 
-            CairoExtensions.DisposeContext (cr);
             return false;
         }
 
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/HoverImageButton.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/HoverImageButton.cs
index 547e063..a57ee52 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/HoverImageButton.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/HoverImageButton.cs
@@ -147,14 +147,14 @@ namespace Banshee.Widgets
             return base.OnButtonReleaseEvent(evnt);
         }
 
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
-            base.OnExposeEvent(evnt);
+            base.OnDrawn (cr);
 
             PropagateExpose(Child, evnt);
 
             if(HasFocus && draw_focus) {
-                Style.PaintFocus(Style, GdkWindow, StateType.Normal, evnt.Area, this, "button",
+                Style.PaintFocus(Style, cr, StateType.Normal, this, "button",
                     0, 0, Allocation.Width, Allocation.Height);
             }
 
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/LinearProgress.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/LinearProgress.cs
index 9bcbd47..b70730f 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/LinearProgress.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/LinearProgress.cs
@@ -35,7 +35,7 @@ namespace Banshee.Widgets
     public class LinearProgress : Gtk.DrawingArea
     {
         private double fraction;
-        private static Gdk.GC bar_gc = null;
+        private static Cairo.Context bar_gc = null;
 
         public LinearProgress()
         {
@@ -44,10 +44,10 @@ namespace Banshee.Widgets
             QueueDraw();
         }
 
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
             if(bar_gc == null) {
-                bar_gc = new Gdk.GC(GdkWindow);
+                bar_gc = Gdk.CairoHelper.Create (GdkWindow);
                 Gdk.Color color = Hyena.Gui.GtkUtilities.ColorBlend(Style.Background(StateType.Normal),
                     Style.Foreground(StateType.Normal));
                 bar_gc.Background = color;
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/LinkLabel.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/LinkLabel.cs
index 27370a2..e743a9f 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/LinkLabel.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/LinkLabel.cs
@@ -102,7 +102,7 @@ namespace Banshee.Widgets
             }
         }
 
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
             if(!IsDrawable) {
                 return false;
@@ -122,24 +122,37 @@ namespace Banshee.Widgets
             return false;
         }
 
-        protected override void OnSizeRequested (ref Requisition requisition)
+        protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
         {
             if (label == null) {
-                base.OnSizeRequested (ref requisition);
+                base.OnGetPreferredWidth (out minimum_width, out natural_width);
                 return;
             }
 
-            requisition.Width = 0;
-            requisition.Height = 0;
+            minimum_height = natural_height = 0;
 
             Requisition child_requisition = label.SizeRequest ();
-            requisition.Width = Math.Max (requisition.Width, child_requisition.Width);
-            requisition.Height += child_requisition.Height;
+            natural_height += child_requisition.Height;
 
-            requisition.Width += ((int)BorderWidth + padding) * 2;
-            requisition.Height += ((int)BorderWidth + padding) * 2;
+            natural_height += ((int)BorderWidth + padding) * 2;
+            minimum_height = natural_height;
+        }
+
+        protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
+        {
+            if (label == null) {
+                base.OnGetPreferredWidth (out minimum_width, out natural_width);
+                return;
+            }
+
+            minimum_width = natural_width = 0;
+
+            Requisition child_requisition = label.SizeRequest ();
+            natural_width = Math.Max (natural_width, child_requisition.Width);
+
+            natural_width += ((int)BorderWidth + padding) * 2;
 
-            base.OnSizeRequested (ref requisition);
+            minimum_width = natural_width;
         }
 
         protected override void OnSizeAllocated (Gdk.Rectangle allocation)
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
index 369990d..bdd6fa5 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
@@ -255,9 +255,9 @@ namespace Banshee.Widgets
             return base.OnKeyPressEvent (evnt);
         }
 
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
-            Style.PaintFlatBox (entry.Style, GdkWindow, State, ShadowType.None, evnt.Area, this,
+            Style.PaintFlatBox (entry.Style, cr, State, ShadowType.None, this,
                 "entry_bg", 0, 0, Allocation.Width, Allocation.Height);
             PropagateExpose(Child, evnt);
             Style.PaintShadow(entry.Style, GdkWindow, StateType.Normal,
@@ -459,7 +459,7 @@ namespace Banshee.Widgets
             private Gdk.Window text_window;
             private SearchEntry parent;
             private Pango.Layout layout;
-            private Gdk.GC text_gc;
+            private Cairo.Context text_gc;
 
             public FramelessEntry(SearchEntry parent) : base()
             {
@@ -482,14 +482,14 @@ namespace Banshee.Widgets
                     return;
                 }
 
-                text_gc = new Gdk.GC(text_window);
+                text_gc = Gdk.CairoHelper.Create (text_window);
                 text_gc.Copy(Style.TextGC(StateType.Normal));
                 Gdk.Color color_a = parent.Style.Base(StateType.Normal);
                 Gdk.Color color_b = parent.Style.Text(StateType.Normal);
                 text_gc.RgbFgColor = Hyena.Gui.GtkUtilities.ColorBlend(color_a, color_b);
             }
 
-            protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+            protected override bool OnDrawn (Cairo.Context cr)
             {
                 // The Entry's GdkWindow is the top level window onto which
                 // the frame is drawn; the actual text entry is drawn into a
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
index 48bd04f..dbf63f7 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
@@ -89,20 +89,31 @@ namespace Banshee.Widgets
             first_style_set = true;
         }
 
-        protected override void OnSizeRequested (ref Gtk.Requisition requisition)
+        protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
         {
+            minimum_height = natural_height = default(int);
             if (!IsRealized || layout == null) {
                 return;
             }
 
             int width, height;
             layout.GetPixelSize (out width, out height);
+            minimum_height = natural_height = height;
+        }
+
+        protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
+        {
+            minimum_width = natural_width = default(int);
+            if (!IsRealized || layout == null) {
+                return;
+            }
 
-            requisition.Width = width;
-            requisition.Height = height;
+            int width, height;
+            layout.GetPixelSize (out width, out height);
+            minimum_width = natural_width = width;
         }
 
-        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+        protected override bool OnDrawn (Cairo.Context cr)
         {
             int bar_width = (int)((double)Allocation.Width * buffering_progress);
             bool render_bar = false;
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/VolumeButton.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/VolumeButton.cs
index 1ec8f0e..02d2cf7 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/VolumeButton.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/VolumeButton.cs
@@ -54,7 +54,7 @@ namespace Bacon
         private const int SCALE_SIZE = 100;
         private const int CLICK_TIMEOUT = 250;
 
-        private Tooltips tooltips = new Tooltips();
+        private Tooltip tooltip = new Tooltip ();
 
         private Window dock;
         private VolumeScale slider;
@@ -98,7 +98,7 @@ namespace Bacon
             WidgetEventAfter += OnWidgetEventAfter;
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
             if(dock != null) {
                 dock.Destroy();
@@ -134,7 +134,7 @@ namespace Bacon
             dock.Hidden += OnDockHidden;
 
             Frame frame = new Frame();
-            frame.Shadow = ShadowType.Out;
+            frame.ShadowType = ShadowType.Out;
             frame.Show();
 
             dock.Add(frame);
@@ -553,7 +553,7 @@ namespace Bacon
                     (slider.Adjustment.Upper - slider.Adjustment.Lower) * 100.0));
             }
 
-            tooltips.SetTip(this, tip, null);
+            tooltip.Text = tip;
         }
 
         private bool AdjustVolume(int direction)
diff --git a/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs b/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs
index e6df094..6570715 100644
--- a/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs
+++ b/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginDialog.cs
@@ -47,7 +47,6 @@ namespace Lastfm.Gui
         public AccountLoginDialog (Account account, bool addCloseButton) : base ()
         {
             Title = Catalog.GetString ("Log in to Last.fm");
-            HasSeparator = false;
             BorderWidth = 5;
 
             IconName = "gtk-dialog-authentication";
@@ -90,15 +89,15 @@ namespace Lastfm.Gui
 
             vbox.PackStart (login_form, true, true, 0);
 
-            VBox.PackStart (hbox, true, true, 0);
-            VBox.Remove (ActionArea);
-            VBox.Spacing = 10;
+            ContentArea.PackStart (hbox, true, true, 0);
+            ContentArea.Remove (ActionArea);
+            ContentArea.Spacing = 10;
 
             HBox bottom_box = new HBox ();
             bottom_box.PackStart (new Badge (account), true, true, 5);
             bottom_box.PackStart (ActionArea, false, false, 0);
             bottom_box.ShowAll ();
-            VBox.PackEnd (bottom_box, false, false, 0);
+            ContentArea.PackEnd (bottom_box, false, false, 0);
 
             if (addCloseButton) {
                 AddButton (Stock.Cancel, ResponseType.Cancel);



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