[banshee/gtk3] NowPlaying: Port the extension to GTK 3
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gtk3] NowPlaying: Port the extension to GTK 3
- Date: Sun, 17 Jul 2011 11:46:37 +0000 (UTC)
commit 252924d32ad1f7fddcae128a3571da11a6c265c9
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sun Jul 17 13:42:57 2011 +0200
NowPlaying: Port the extension to GTK 3
.../Banshee.NowPlaying/FullscreenWindow.cs | 42 ++++++++----------
.../Banshee.NowPlaying/NowPlayingInterface.cs | 2 +-
.../Banshee.NowPlaying/OverlayWindow.cs | 45 +++++++++++---------
.../Banshee.NowPlaying/VideoDisplay.cs | 14 ++++--
.../Banshee.NowPlaying/XOverlayVideoDisplay.cs | 18 ++++----
5 files changed, 61 insertions(+), 60 deletions(-)
---
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
index dc57fde..8ace3b3 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
@@ -56,10 +56,14 @@ namespace Banshee.NowPlaying
SetupWidget ();
}
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ protected override bool OnDrawn (Cairo.Context cr)
{
- evnt.Window.DrawRectangle (Style.BlackGC, true, Allocation);
- return base.OnExposeEvent (evnt);
+ cr.Save ();
+ cr.SetSourceRGB (0.0, 0.0, 0.0);
+ cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
+ cr.Fill ();
+ cr.Restore ();
+ return base.OnDrawn (cr);
}
protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
@@ -122,7 +126,7 @@ namespace Banshee.NowPlaying
private void ConfigureWindow ()
{
Gdk.Screen screen = Screen;
- int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
+ int monitor = screen.GetMonitorAtWindow (parent.Window);
Gdk.Rectangle bounds = screen.GetMonitorGeometry (monitor);
Move (bounds.X, bounds.Y);
Resize (bounds.Width, bounds.Height);
@@ -142,7 +146,7 @@ namespace Banshee.NowPlaying
base.OnRealized ();
- GdkWindow.OverrideRedirect = true;
+ Window.OverrideRedirect = true;
Screen.SizeChanged += OnScreenSizeChanged;
}
@@ -188,12 +192,12 @@ namespace Banshee.NowPlaying
// If our parent window is ever somehow activated while we are
// visible, this will ensure we merge back into the parent
if (parent.IsActive) {
- parent.GdkWindow.SkipPagerHint = false;
- parent.GdkWindow.SkipTaskbarHint = false;
+ parent.Window.SkipPagerHint = false;
+ parent.Window.SkipTaskbarHint = false;
parent.RemoveNotification ("is-active", ParentActiveNotification);
} else {
- parent.GdkWindow.SkipPagerHint = true;
- parent.GdkWindow.SkipTaskbarHint = true;
+ parent.Window.SkipPagerHint = true;
+ parent.Window.SkipTaskbarHint = true;
}
}
@@ -237,7 +241,7 @@ namespace Banshee.NowPlaying
int cursor_x, cursor_y;
int window_x, window_y;
- controls.GdkWindow.Screen.Display.GetPointer (out cursor_x, out cursor_y);
+ controls.Window.Screen.Display.GetPointer (out cursor_x, out cursor_y);
controls.GetPosition (out window_x, out window_y);
Gdk.Rectangle box = new Gdk.Rectangle (window_x, window_y,
@@ -313,29 +317,19 @@ namespace Banshee.NowPlaying
private void ShowCursor ()
{
cursor_is_hidden = false;
- GdkWindow.Cursor = null;
+ Window.Cursor = null;
}
private void HideCursor ()
{
- if (GdkWindow == null) {
+ if (Window == null) {
return;
}
- Gdk.Pixmap pixmap = Gdk.Pixmap.CreateBitmapFromData (GdkWindow, "0x0", 1, 1);
- if (pixmap == null) {
- return;
- }
-
- UpdateHiddenCursorPosition ();
- cursor_is_hidden = true;
-
- Gdk.Color color = new Gdk.Color (0, 0, 0);
- Gdk.Cursor cursor = new Gdk.Cursor (pixmap, pixmap, color, color, 0, 0);
+ Gdk.Cursor cursor = new Gdk.Cursor (Gdk.CursorType.BlankCursor);
- GdkWindow.Cursor = cursor;
+ Window.Cursor = cursor;
- pixmap.Dispose ();
cursor.Dispose ();
}
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
index 5aa028d..97450e9 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
@@ -150,7 +150,7 @@ namespace Banshee.NowPlaying
}
previous_fullscreen_handler = service.ViewActions.Fullscreen;
- primary_window_is_fullscreen = (primary_window.GdkWindow.State & Gdk.WindowState.Fullscreen) != 0;
+ primary_window_is_fullscreen = (primary_window.Window.State & Gdk.WindowState.Fullscreen) != 0;
service.ViewActions.Fullscreen = FullscreenHandler;
DisableFullscreenAction ();
}
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs
index 0f6ba0e..ee25b54 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs
@@ -62,7 +62,7 @@ namespace Banshee.NowPlaying
Decorated = false;
DestroyWithParent = true;
- AllowGrow = true;
+ Resizable = true;
KeepAbove = true;
TransientFor = toplevel;
@@ -76,12 +76,12 @@ namespace Banshee.NowPlaying
protected override void OnRealized ()
{
- composited = CompositeUtils.IsComposited (Screen) && CompositeUtils.SetRgbaColormap (this);
+ composited = Screen.IsComposited && CompositeUtils.SetRgbaVisual (this);
AppPaintable = composited;
base.OnRealized ();
- GdkWindow.OverrideRedirect = true;
+ Window.OverrideRedirect = true;
ShapeWindow ();
Relocate ();
@@ -98,16 +98,27 @@ namespace Banshee.NowPlaying
return base.OnConfigureEvent (evnt);
}
- protected override void OnSizeRequested (ref Requisition requisition)
+ protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
{
+ minimum_height = natural_height = 0;
+
+ if (Child != null) {
+ Child.GetPreferredHeight (out minimum_height, out natural_height);
+ }
+ }
+
+ protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
+ {
+ minimum_width = natural_width = 0;
+
if (Child != null) {
- requisition = Child.SizeRequest ();
+ Child.GetPreferredWidth (out minimum_width, out natural_width);
}
if (width_scale > 0 && width_scale <= 1 && TransientFor != null) {
- int monitor_num = Screen.GetMonitorAtWindow (TransientFor.GdkWindow);
+ int monitor_num = Screen.GetMonitorAtWindow (TransientFor.Window);
Gdk.Rectangle monitor = Screen.GetMonitorGeometry (monitor_num < 0 ? 0 : monitor_num);
- requisition.Width = (int)(monitor.Width * width_scale);
+ minimum_width = natural_width = (int)(monitor.Width * width_scale);
}
}
@@ -131,23 +142,17 @@ namespace Banshee.NowPlaying
Relocate ();
}
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ protected override bool OnDrawn (Cairo.Context cr)
{
- if (!composited || evnt.Window != GdkWindow) {
- return base.OnExposeEvent (evnt);
+ if (!composited) {
+ return base.OnDrawn (cr);
}
- Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window);
-
- Gdk.Color color = Style.Background (State);
+ Gdk.RGBA color = StyleContext.GetBackgroundColor (StateFlags);
- ShapeSurface (cr, new Cairo.Color (color.Red / (double) ushort.MaxValue,
- color.Blue / (double) ushort.MaxValue,
- color.Green / (double) ushort.MaxValue,
- 0.85));
+ ShapeSurface (cr, new Cairo.Color (color.Red, color.Blue, color.Green, 0.85));
- CairoExtensions.DisposeContext (cr);
- return base.OnExposeEvent (evnt);
+ return base.OnDrawn (cr);
}
protected virtual void ShapeSurface (Cairo.Context cr, Cairo.Color color)
@@ -171,7 +176,7 @@ namespace Banshee.NowPlaying
int x, y;
- toplevel.GdkWindow.GetOrigin (out x, out y);
+ toplevel.Window.GetOrigin (out x, out y);
int x_origin = x;
int y_origin = y;
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
index 3c5e1c8..ef8e785 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
@@ -56,7 +56,7 @@ namespace Banshee.NowPlaying
protected abstract Gdk.Window RenderWindow { get; }
- protected abstract void ExposeVideo (Gdk.EventExpose evnt);
+ protected abstract void ExposeVideo ();
protected override void OnDestroyed ()
{
@@ -64,17 +64,21 @@ namespace Banshee.NowPlaying
ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
}
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ protected override bool OnDrawn (Cairo.Context cr)
{
- RenderWindow.DrawRectangle (Style.BlackGC, true,
- new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height));
+ // We want to draw on RenderWindow so we need another Cairo.Context
+ Cairo.Context cr_window = Gdk.CairoHelper.Create (RenderWindow);
+ cr_window.SetSourceRGB (0.0, 0.0, 0.0);
+ cr_window.Rectangle (0, 0, Allocation.Width, Allocation.Height);
+ cr_window.Paint ();
+ ((IDisposable)cr_window).Dispose ();
if (RenderWindow == null || !RenderWindow.IsVisible) {
return true;
}
if (!is_idle && ServiceManager.PlayerEngine.VideoDisplayContextType != VideoDisplayContextType.Unsupported) {
- ExposeVideo (evnt);
+ ExposeVideo ();
}
return true;
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs
index de924f5..c9db112 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs
@@ -43,16 +43,16 @@ namespace Banshee.NowPlaying
public XOverlayVideoDisplay () : base ()
{
- WidgetFlags = WidgetFlags.NoWindow;
+ HasWindow = false;
CreateVideoWindow ();
}
protected override void OnRealized ()
{
- WidgetFlags |= WidgetFlags.Realized;
+ IsRealized = true;
CreateVideoWindow ();
- GdkWindow = Parent.GdkWindow;
- video_window.Reparent (GdkWindow, 0, 0);
+ Window = Parent.Window;
+ video_window.Reparent (Window, 0, 0);
video_window.MoveResize (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
video_window.ShowUnraised ();
}
@@ -70,21 +70,19 @@ namespace Banshee.NowPlaying
Width = 0,
Height = 0,
Visual = Visual,
- Wclass = Gdk.WindowClass.InputOutput,
- Colormap = Colormap,
+ Wclass = Gdk.WindowWindowClass.InputOutput,
EventMask = (int)(Gdk.EventMask.ExposureMask | Gdk.EventMask.VisibilityNotifyMask)
};
Gdk.WindowAttributesType attributes_mask =
Gdk.WindowAttributesType.X |
Gdk.WindowAttributesType.Y |
- Gdk.WindowAttributesType.Visual |
- Gdk.WindowAttributesType.Colormap;
+ Gdk.WindowAttributesType.Visual;
video_window = new Gdk.Window (null, attributes, attributes_mask);
video_window.UserData = Handle;
- video_window.SetBackPixmap (null, false);
+ video_window.BackgroundPattern = null;
if (ServiceManager.PlayerEngine.VideoDisplayContextType == VideoDisplayContextType.GdkWindow) {
ServiceManager.PlayerEngine.VideoDisplayContext = video_window.Handle;
@@ -137,7 +135,7 @@ namespace Banshee.NowPlaying
return false;
}
- protected override void ExposeVideo (Gdk.EventExpose evnt)
+ protected override void ExposeVideo ()
{
if (ServiceManager.PlayerEngine.VideoDisplayContextType == VideoDisplayContextType.GdkWindow) {
ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]