diff options
author | Aaron Bockover <abock@gnome.org> | 2008-04-17 00:14:12 +0000 |
---|---|---|
committer | Aaron Bockover <abock@src.gnome.org> | 2008-04-17 00:14:12 +0000 |
commit | 4ff5a8a178975707461ebc59d60ede388f3709d2 (patch) | |
tree | 38152d2f2e5479929eec6673975e49c1e9703342 | |
parent | 20a47b74285981f350bc9f863dd2b15c99f40287 (diff) |
Add a gdb target
2008-04-16 Aaron Bockover <abock@gnome.org>
* Makefile.am: Add a gdb target
* src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs: Added
AddImportant override for ToggleActionEntry
* src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs: Moved
the fullscreen code
* src/Core/Banshee.hickClient/Banshee.Gui/ViewActions.cs: Implement the
fullscreen action and allow the fullscreen logic to be overridden
* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs:
The window that will house the fullscreen UI for video playback
* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs:
Add a property for getting the VideoDisplay widget
* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs:
Added a custom fullscreen handler that will fullscreen the video window
when fullscreen action is toggled and the now playing source is active
* src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs:
Inherit from GtkEventBox since it does what we needed and simplifies some
things; still has that CRITICAL warning though
* src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml: UI for
merging the fullscreen action into the toolbar
svn path=/trunk/banshee/; revision=3789
12 files changed, 265 insertions, 45 deletions
@@ -1,3 +1,33 @@ +2008-04-16 Aaron Bockover <abock@gnome.org> + + * Makefile.am: Add a gdb target + + * src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs: Added + AddImportant override for ToggleActionEntry + + * src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs: Moved + the fullscreen code + + * src/Core/Banshee.hickClient/Banshee.Gui/ViewActions.cs: Implement the + fullscreen action and allow the fullscreen logic to be overridden + + * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs: + The window that will house the fullscreen UI for video playback + + * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs: + Add a property for getting the VideoDisplay widget + + * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs: + Added a custom fullscreen handler that will fullscreen the video window + when fullscreen action is toggled and the now playing source is active + + * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs: + Inherit from GtkEventBox since it does what we needed and simplifies some + things; still has that CRITICAL warning though + + * src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml: UI for + merging the fullscreen action into the toolbar + 2008-04-16 Alexander Hixon <hixon.alexander@mediati.org> * build/build.environment.mk diff --git a/Makefile.am b/Makefile.am index 200db87e8..0706739e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,11 @@ run: $(MONO) --debug $(BANSHEE_DEV_MONO_OPTIONS) Nereid.exe --debug --uninstalled $(BANSHEE_DEV_OPTIONS); \ popd; +gdb: + @pushd bin; \ + gdb mono --eval-command="handle SIGXCPU SIG35 SIGPWR nostop noprint" --eval-command="b g_return_if_fail_warning" --eval-command="r --debug Nereid.exe --debug --uninstalled"; \ + popd; + test: @pushd tests; \ make test \ diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs index 7bca55e8a..8b67d8d83 100644 --- a/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs +++ b/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs @@ -55,6 +55,15 @@ namespace Banshee.Gui } } + public void AddImportant (params ToggleActionEntry [] action_entries) + { + base.Add (action_entries); + + foreach (ToggleActionEntry entry in action_entries) { + this[entry.name].IsImportant = true; + } + } + public void UpdateActions (bool visible, bool sensitive, params string [] action_names) { UpdateActions (visible, sensitive, null, action_names); diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs index a0199b6fc..fe3e8b240 100644 --- a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs +++ b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs @@ -36,8 +36,6 @@ namespace Banshee.Gui { public abstract class BaseClientWindow : Window { - private ToggleAction fullscreen_action; - private GtkElementsService elements_service; protected GtkElementsService ElementsService { get { return elements_service; } @@ -101,15 +99,6 @@ namespace Banshee.Gui private void InitializeWindow () { - fullscreen_action = (ToggleAction)action_service.ViewActions["FullScreenAction"]; - fullscreen_action.Activated += delegate { - if (fullscreen_action.Active) { - Fullscreen (); - } else { - Unfullscreen (); - } - }; - Initialize (); } @@ -177,6 +166,7 @@ namespace Banshee.Gui protected override bool OnWindowStateEvent (Gdk.EventWindowState evnt) { + ToggleAction fullscreen_action = (ToggleAction) ServiceManager.Get<InterfaceActionService> ().ViewActions["FullScreenAction"]; fullscreen_action.Active = (evnt.NewWindowState & Gdk.WindowState.Fullscreen) != 0; if ((evnt.NewWindowState & Gdk.WindowState.Withdrawn) == 0) { diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs index eba7f31b6..7b05814c2 100644 --- a/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs +++ b/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs @@ -39,7 +39,23 @@ namespace Banshee.Gui { public class ViewActions : BansheeActionGroup { + public delegate void FullscreenHandler (bool fullscreen); + private InterfaceActionService action_service; + private FullscreenHandler fullscreen_handler; + + public FullscreenHandler Fullscreen { + get { return fullscreen_handler; } + set { + fullscreen_handler = value; + + GtkElementsService service = ServiceManager.Get<GtkElementsService> (); + Gtk.ToggleAction action = this["FullScreenAction"] as Gtk.ToggleAction; + if (service != null && action != null && value == null) { + action.Active = (service.PrimaryWindow.GdkWindow.State & Gdk.WindowState.Fullscreen) != 0; + } + } + } public ViewActions (InterfaceActionService actionService) : base ("View") { @@ -51,12 +67,14 @@ namespace Banshee.Gui Catalog.GetString ("_Equalizer"), "<control>E", Catalog.GetString ("View the graphical equalizer"), OnShowEqualizer) }); - - Add (new ToggleActionEntry [] { - new ToggleActionEntry ("FullScreenAction", null, + + AddImportant (new ToggleActionEntry [] { + new ToggleActionEntry ("FullScreenAction", "gtk-fullscreen", Catalog.GetString ("_Fullscreen"), "F11", - Catalog.GetString ("Toggle Fullscreen Mode"), null, false), - + Catalog.GetString ("Toggle Fullscreen Mode"), OnFullScreen, false), + }); + + Add (new ToggleActionEntry [] { new ToggleActionEntry ("ShowCoverArtAction", null, Catalog.GetString ("Show Cover _Art"), null, Catalog.GetString ("Toggle display of album cover art"), null, false), @@ -64,6 +82,8 @@ namespace Banshee.Gui ServiceManager.PlayerEngine.StateChanged += OnPlayerEngineStateChanged; action_service = actionService; + + OnFullScreen (null, EventArgs.Empty); } private void OnPlayerEngineStateChanged (object o, PlayerEngineStateArgs args) @@ -78,5 +98,33 @@ namespace Banshee.Gui EqualizerWindow eqwin = new EqualizerWindow (); eqwin.Window.Show (); } + + private void OnFullScreen (object o, EventArgs args) + { + Gtk.ToggleAction action = this["FullScreenAction"] as Gtk.ToggleAction; + if (action == null) { + return; + } + + if (Fullscreen != null) { + Fullscreen (action.Active); + return; + } + + GtkElementsService service = ServiceManager.Get<GtkElementsService> (); + if (service == null || action == null) { + return; + } + + Gtk.Window window = service.PrimaryWindow; + + if (window == null) { + return; + } else if (action.Active) { + window.Fullscreen (); + } else { + window.Unfullscreen (); + } + } } } diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp index dd65fc1e5..ccc5eb7c4 100644 --- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp +++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp @@ -13,6 +13,8 @@ <File name="Banshee.NowPlaying/NowPlayingInterface.cs" subtype="Code" buildaction="Compile" /> <File name="Banshee.NowPlaying/VideoDisplay.cs" subtype="Code" buildaction="Compile" /> <File name="Resources/idle-logo.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Banshee.NowPlaying/FullscreenWindow.cs" subtype="Code" buildaction="Compile" /> + <File name="Resources/ActiveSourceUI.xml" subtype="Code" buildaction="EmbedAsResource" /> </Contents> <References> <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" /> diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs new file mode 100644 index 000000000..24faecf14 --- /dev/null +++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs @@ -0,0 +1,66 @@ +// +// FullScreenWindow.cs +// +// Authors: +// Larry Ewing <lewing@novell.com> +// Gabriel Burt <gburt@novell.com> +// Aaron Bockover <abockover@novell.com> +// +// Copyright (C) 2008 Novell, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using Gtk; +using Mono.Unix; + +namespace Banshee.NowPlaying +{ + public class FullscreenWindow : Window + { + public FullscreenWindow (string title, Window parent) : base (title) + { + 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); + + Decorated = false; + } + + protected void Close () + { + Destroy (); + } + + protected override bool OnKeyPressEvent (Gdk.EventKey evnt) + { + switch (evnt.Key) { + case Gdk.Key.Escape: + Close (); + return true; + } + + return base.OnKeyPressEvent (evnt); + } + } +} diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs index de5f714ad..da90d9fb8 100644 --- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs +++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs @@ -42,6 +42,10 @@ namespace Banshee.NowPlaying private NowPlayingSource source; private VideoDisplay video_display; private Hyena.Widgets.RoundedFrame frame; + + public VideoDisplay VideoDisplay { + get { return video_display; } + } public NowPlayingInterface () { diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs index c6f0aa873..86648ed5d 100644 --- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs +++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs @@ -35,6 +35,7 @@ using Banshee.ServiceStack; using Banshee.MediaEngine; using Banshee.Collection; +using Banshee.Gui; using Banshee.Sources.Gui; namespace Banshee.NowPlaying @@ -52,6 +53,7 @@ namespace Banshee.NowPlaying Properties.SetString ("Icon.Name", "applications-multimedia"); Properties.Set<ISourceContents> ("Nereid.SourceContents", new NowPlayingInterface ()); Properties.Set<bool> ("Nereid.SourceContents.HeaderVisible", false); + Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml"); ServiceManager.SourceManager.AddSource (this); @@ -80,5 +82,70 @@ namespace Banshee.NowPlaying public void Dispose () { } + +#region Video Fullscreen Override + + private Gtk.Window fullscreen_window; + private ViewActions.FullscreenHandler previous_fullscreen_handler; + + private void DisableFullscreenAction () + { + InterfaceActionService service = ServiceManager.Get<InterfaceActionService> (); + Gtk.ToggleAction action = service.ViewActions["FullScreenAction"] as Gtk.ToggleAction; + if (action != null) { + action.Active = false; + } + } + + public override void Activate () + { + InterfaceActionService service = ServiceManager.Get<InterfaceActionService> (); + if (service == null || service.ViewActions == null) { + return; + } + + previous_fullscreen_handler = service.ViewActions.Fullscreen; + service.ViewActions.Fullscreen = FullscreenHandler; + DisableFullscreenAction (); + } + + public override void Deactivate () + { + InterfaceActionService service = ServiceManager.Get<InterfaceActionService> (); + if (service == null || service.ViewActions == null) { + return; + } + + service.ViewActions.Fullscreen = previous_fullscreen_handler; + } + + private void OnFullscreenWindowDestroyed (object o, EventArgs args) + { + if (fullscreen_window != null) { + fullscreen_window.Destroyed -= OnFullscreenWindowDestroyed; + fullscreen_window = null; + } + + DisableFullscreenAction (); + } + + private void FullscreenHandler (bool fullscreen) + { + if (fullscreen) { + if (fullscreen_window == null) { + GtkElementsService service = ServiceManager.Get<GtkElementsService> (); + fullscreen_window = new FullscreenWindow (service.PrimaryWindow.Title, service.PrimaryWindow); + fullscreen_window.Destroyed += OnFullscreenWindowDestroyed; + } + + fullscreen_window.Show (); + fullscreen_window.Fullscreen (); + } else if (fullscreen_window != null) { + fullscreen_window.Destroy (); + } + } + +#endregion + } } diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs index fdb03f0d8..1f82744cc 100644 --- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs +++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs @@ -37,11 +37,21 @@ using Banshee.Gui; namespace Banshee.NowPlaying { - public class VideoDisplay : Gtk.Widget + public class VideoDisplay : Gtk.EventBox { private Gdk.Pixbuf idle_pixbuf; - private Gdk.Window video_window; private bool render_idle = true; + + private bool fullscreen = false; + public bool FullScreen { + get { return fullscreen; } + set { fullscreen = value; } + } + + private Gdk.Window video_window; + public Gdk.Window VideoWindow { + get { return video_window; } + } public VideoDisplay () { @@ -77,36 +87,20 @@ namespace Banshee.NowPlaying protected override void OnRealized () { - WidgetFlags |= WidgetFlags.Realized; - - Gdk.WindowAttr attributes = new Gdk.WindowAttr (); - attributes.WindowType = Gdk.WindowType.Child; - attributes.X = Allocation.X; - attributes.Y = Allocation.Y; - attributes.Width = Allocation.Width; - attributes.Height = Allocation.Height; - attributes.Wclass = Gdk.WindowClass.InputOnly; - - Gdk.WindowAttributesType attributes_mask = - Gdk.WindowAttributesType.X | - Gdk.WindowAttributesType.Y; - - GdkWindow = new Gdk.Window (Parent.GdkWindow, attributes, attributes_mask); - GdkWindow.UserData = Handle; - + base.OnRealized (); video_window.Reparent (Parent.GdkWindow, Allocation.X, Allocation.Y); } protected override void OnUnrealized () { - video_window.Reparent (null, 0, 0); base.OnUnrealized (); + video_window.Reparent (null, 0, 0); } protected override void OnMapped () { - video_window.Show (); base.OnMapped (); + video_window.Show (); } protected override void OnUnmapped () @@ -117,19 +111,15 @@ namespace Banshee.NowPlaying protected override void OnSizeAllocated (Gdk.Rectangle allocation) { + video_window.MoveResize (allocation); base.OnSizeAllocated (allocation); - if (IsRealized && IsMapped) { - video_window.MoveResize (allocation); - GdkWindow.MoveResize (allocation); - } - QueueDraw (); } protected override bool OnConfigureEvent (Gdk.EventConfigure evnt) { - if (IsRealized && IsMapped && ServiceManager.PlayerEngine.SupportsVideo) { + if (video_window != null && ServiceManager.PlayerEngine.SupportsVideo) { ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, true); } @@ -138,7 +128,7 @@ namespace Banshee.NowPlaying protected override bool OnExposeEvent (Gdk.EventExpose evnt) { - if (!Visible || !IsMapped || video_window == null) { + if (video_window == null || !video_window.IsVisible) { return true; } @@ -179,7 +169,7 @@ namespace Banshee.NowPlaying public new void QueueDraw () { base.QueueDraw (); - if (IsRealized && video_window != null) { + if (video_window != null) { video_window.InvalidateRect (new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height), true); } } diff --git a/src/Extensions/Banshee.NowPlaying/Makefile.am b/src/Extensions/Banshee.NowPlaying/Makefile.am index bcb83d07f..ad0e7fbbd 100644 --- a/src/Extensions/Banshee.NowPlaying/Makefile.am +++ b/src/Extensions/Banshee.NowPlaying/Makefile.am @@ -4,12 +4,14 @@ LINK = $(REF_EXTENSION_NOWPLAYING) INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR) SOURCES = \ + Banshee.NowPlaying/FullscreenWindow.cs \ Banshee.NowPlaying/NowPlayingInterface.cs \ Banshee.NowPlaying/NowPlayingSource.cs \ Banshee.NowPlaying/VideoDisplay.cs RESOURCES = \ Banshee.NowPlaying.addin.xml \ + Resources/ActiveSourceUI.xml \ Resources/idle-logo.png include $(top_srcdir)/build/build.mk diff --git a/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml b/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml new file mode 100644 index 000000000..6b938ded3 --- /dev/null +++ b/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml @@ -0,0 +1,7 @@ +<ui> + <toolbar name="HeaderToolbar"> + <placeholder name="SourceActions"> + <toolitem action="FullScreenAction" /> + </placeholder> + </toolbar> +</ui> |