banshee r3789 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.NowPlaying src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying src/Extensions/Banshee.NowPlaying/Resources



Author: abock
Date: Thu Apr 17 01:14:12 2008
New Revision: 3789
URL: http://svn.gnome.org/viewvc/banshee?rev=3789&view=rev

Log:
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



Added:
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/Makefile.am
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am

Modified: trunk/banshee/Makefile.am
==============================================================================
--- trunk/banshee/Makefile.am	(original)
+++ trunk/banshee/Makefile.am	Thu Apr 17 01:14:12 2008
@@ -64,6 +64,11 @@
 	$(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 \

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	Thu Apr 17 01:14:12 2008
@@ -55,6 +55,15 @@
             }
         }
 
+        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);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs	Thu Apr 17 01:14:12 2008
@@ -36,8 +36,6 @@
 {
     public abstract class BaseClientWindow : Window
     {
-        private ToggleAction fullscreen_action;
-        
         private GtkElementsService elements_service;
         protected GtkElementsService ElementsService {
             get { return elements_service; }
@@ -101,15 +99,6 @@
         
         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 @@
         
         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) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs	Thu Apr 17 01:14:12 2008
@@ -39,7 +39,23 @@
 {
     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 @@
                    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 @@
             
             ServiceManager.PlayerEngine.StateChanged += OnPlayerEngineStateChanged;
             action_service = actionService;
+
+            OnFullScreen (null, EventArgs.Empty);
         }
         
         private void OnPlayerEngineStateChanged (object o, PlayerEngineStateArgs args)
@@ -78,5 +98,33 @@
             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 ();
+            }
+        }
     }
 }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp	Thu Apr 17 01:14:12 2008
@@ -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" />

Added: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	Thu Apr 17 01:14:12 2008
@@ -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);
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs	Thu Apr 17 01:14:12 2008
@@ -42,6 +42,10 @@
         private NowPlayingSource source;
         private VideoDisplay video_display;
         private Hyena.Widgets.RoundedFrame frame;
+
+        public VideoDisplay VideoDisplay {
+            get { return video_display; }
+        }
         
         public NowPlayingInterface ()
         {

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs	Thu Apr 17 01:14:12 2008
@@ -35,6 +35,7 @@
 using Banshee.MediaEngine;
 using Banshee.Collection;
 
+using Banshee.Gui;
 using Banshee.Sources.Gui;
 
 namespace Banshee.NowPlaying
@@ -52,6 +53,7 @@
             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 @@
         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
+
     }
 }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	Thu Apr 17 01:14:12 2008
@@ -37,11 +37,21 @@
 
 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 @@
         
         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 @@
         
         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 @@
 
         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 @@
         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);
             }
         }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am	Thu Apr 17 01:14:12 2008
@@ -4,12 +4,14 @@
 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

Added: trunk/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Resources/ActiveSourceUI.xml	Thu Apr 17 01:14:12 2008
@@ -0,0 +1,7 @@
+<ui>
+    <toolbar name="HeaderToolbar">
+        <placeholder name="SourceActions">
+            <toolitem action="FullScreenAction" />
+        </placeholder>
+    </toolbar>
+</ui>



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