Re: [Banshee-List] [RFC] Compact Video Playback Mode for NowPlaying
- From: "Ivan N. Zlatev" <contact i-nz net>
- To: banshee-list gnome org
- Subject: Re: [Banshee-List] [RFC] Compact Video Playback Mode for NowPlaying
- Date: Sun, 17 Aug 2008 16:15:12 +0300
On Sun, Aug 17, 2008 at 4:10 PM, Ivan N. Zlatev <contact i-nz net> wrote:
>
> The following patch series for review adds a compact video playback mode to the NowPlaying extension (bug #545597). This mode is basically a plain window with only the video inside. This allows watching a podcast/show while doing something else at the same time. Such a mode is already present in Totem and I have personally found it very handy.
>
> The user visibly changes are a "Compact" toolbar button next to the "Fullscreen" one and an additional "h/H" shortcut key to switch back to normal mode.
>
> The patches are a logically following string of small self-contained changes to hopefully allow easier review. In addition I will drop in the full diff to make it easier to apply.
The full patch as said is attached to this mail.
--
Kind Regards,
Ivan N. Zlatev
diff --git a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenAdapter.cs b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenAdapter.cs
index de17bc5..5125200 100644
--- a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenAdapter.cs
+++ b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenAdapter.cs
@@ -54,6 +54,7 @@ namespace Banshee.NowPlaying
} catch (Exception e) {
Log.Exception ("IFullscreenAdapter extension failed, so disabling", e);
DisposeAdapter ();
+ DefaultFullscreen (window, fullscreen);
}
return;
diff --git a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
index 0e5270b..5d3cbcf 100644
--- a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
+++ b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
@@ -42,6 +42,7 @@ namespace Banshee.NowPlaying
private Gtk.Window parent;
private FullscreenControls controls;
private InterfaceActionService action_service;
+ private bool auto_show_controls;
public FullscreenWindow (Window parent) : base (WindowType.Toplevel)
{
@@ -50,10 +51,9 @@ namespace Banshee.NowPlaying
this.parent = parent;
this.action_service = ServiceManager.Get<InterfaceActionService> ();
+ this.auto_show_controls = false;
AddAccelGroup (action_service.UIManager.AccelGroup);
-
- SetupWidget ();
}
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
@@ -75,8 +75,9 @@ namespace Banshee.NowPlaying
uint slow_seek = player.Length > 0 ? (uint)(player.Length * 0.05) : fixed_seek; // 5% or fixed
switch (evnt.Key) {
+ case Gdk.Key.H:
+ case Gdk.Key.h:
case Gdk.Key.Escape:
- Unfullscreen ();
Hide ();
return true;
case Gdk.Key.C:
@@ -95,12 +96,14 @@ namespace Banshee.NowPlaying
case Gdk.Key.Right:
case Gdk.Key.rightarrow:
player.Position += mod ? fast_seek : slow_seek;
- ShowControls ();
+ if (auto_show_controls)
+ ShowControls ();
break;
case Gdk.Key.Left:
case Gdk.Key.leftarrow:
player.Position -= mod ? fast_seek : slow_seek;
- ShowControls ();
+ if (auto_show_controls)
+ ShowControls ();
break;
}
@@ -109,38 +112,16 @@ namespace Banshee.NowPlaying
#region Widgetry and show/hide logic
- private void SetupWidget ()
- {
- Deletable = false;
- TransientFor = null;
- Decorated = false;
- CanFocus = true;
-
- ConfigureWindow ();
- }
-
- private void ConfigureWindow ()
- {
- Gdk.Screen screen = Screen;
- int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
- Gdk.Rectangle bounds = screen.GetMonitorGeometry (monitor);
- Move (bounds.X, 0);
- SetDefaultSize (bounds.Width, bounds.Height);
- }
-
protected override void OnRealized ()
{
Events |= Gdk.EventMask.PointerMotionMask;
base.OnRealized ();
-
- Screen.SizeChanged += OnScreenSizeChanged;
}
protected override void OnUnrealized ()
{
base.OnUnrealized ();
- Screen.SizeChanged -= OnScreenSizeChanged;
}
protected override bool OnDeleteEvent (Gdk.Event evnt)
@@ -152,40 +133,34 @@ namespace Banshee.NowPlaying
protected override void OnShown ()
{
base.OnShown ();
+
if (Child != null) {
Child.Show ();
}
- OnHideCursorTimeout ();
- ConfigureWindow ();
+ if (auto_show_controls)
+ OnHideCursorTimeout ();
+
HasFocus = true;
parent.AddNotification ("is-active", ParentActiveNotification);
}
protected override void OnHidden ()
{
+ if (cursor_update_position_timeout_id > 0)
+ GLib.Source.Remove (cursor_update_position_timeout_id);
+ ShowCursor ();
base.OnHidden ();
DestroyControls ();
parent.RemoveNotification ("is-active", ParentActiveNotification);
}
- private void OnScreenSizeChanged (object o, EventArgs args)
- {
- ConfigureWindow ();
- }
-
private void ParentActiveNotification (object o, GLib.NotifyArgs args)
{
// 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;
+ if (parent.IsActive)
Hide ();
- } else {
- parent.GdkWindow.SkipPagerHint = true;
- parent.GdkWindow.SkipTaskbarHint = true;
- }
}
#endregion
@@ -238,6 +213,10 @@ namespace Banshee.NowPlaying
}
}
+ public bool AutoShowPlaybackControls {
+ get { return auto_show_controls; }
+ set { auto_show_controls = value; }
+ }
#endregion
#region Mouse Cursor Logic
@@ -254,6 +233,9 @@ namespace Banshee.NowPlaying
protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt)
{
+ if (!auto_show_controls)
+ return base.OnMotionNotifyEvent (evnt);
+
if (cursor_is_hidden) {
if (Math.Abs (hide_cursor_x - evnt.X) > CursorShowMovementThreshold ||
Math.Abs (hide_cursor_y - evnt.Y) > CursorShowMovementThreshold) {
diff --git a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
index 5be2011..d146ed4 100644
--- a/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
+++ b/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
@@ -42,13 +42,22 @@ namespace Banshee.NowPlaying
{
private NowPlayingSource source;
private Hyena.Widgets.RoundedFrame frame;
- private Gtk.Window video_window;
+ private FullscreenWindow video_window;
private FullscreenAdapter fullscreen_adapter;
private ScreensaverManager screensaver;
private NowPlayingContents contents;
public NowPlayingInterface ()
{
+
+ InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
+ uia_service.SourceActions.AddImportant (
+ new ActionEntry ("CompactModeAction", Stock.LeaveFullscreen,
+ Catalog.GetString ("Compact"), null,
+ Catalog.GetString ("Displays the video in a minimalistic video window"),
+ OnCompactMode)
+ );
+
GtkElementsService service = ServiceManager.Get<GtkElementsService> ();
contents = new NowPlayingContents ();
@@ -96,6 +105,14 @@ namespace Banshee.NowPlaying
}
}
+ private void OnCompactMode (object o, EventArgs args)
+ {
+ MoveVideoExternal (false);
+ video_window.AutoShowPlaybackControls = false;
+ video_window.ShowAll ();
+ ServiceManager.Get<GtkElementsService> ().PrimaryWindow.Hide ();
+ }
+
protected override void OnRealized ()
{
base.OnRealized ();
@@ -149,6 +166,7 @@ namespace Banshee.NowPlaying
private void OnFullscreenWindowHidden (object o, EventArgs args)
{
+ ServiceManager.Get<GtkElementsService> ().PrimaryWindow.Show ();
MoveVideoInternal ();
DisableFullscreenAction ();
}
@@ -157,11 +175,13 @@ namespace Banshee.NowPlaying
{
if (fullscreen) {
MoveVideoExternal (true);
+ video_window.AutoShowPlaybackControls = true;
video_window.Show ();
fullscreen_adapter.Fullscreen (video_window, true);
screensaver.Inhibit ();
} else {
screensaver.UnInhibit ();
+ video_window.AutoShowPlaybackControls = false;
fullscreen_adapter.Fullscreen (video_window, false);
video_window.Hide ();
}
diff --git a/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml b/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml
index 6b938de..f1b8a5a 100644
--- a/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml
+++ b/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml
@@ -2,6 +2,7 @@
<toolbar name="HeaderToolbar">
<placeholder name="SourceActions">
<toolitem action="FullScreenAction" />
+ <toolitem action="CompactModeAction" />
</placeholder>
</toolbar>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]