[banshee] [NowPlaying] Allow replacing TrackInfoDisplay



commit b709dd3376b12dfe6d581793b9d6db159a2455a1
Author: Chris Howie <cdhowie gmail com>
Date:   Fri Dec 18 14:10:44 2009 -0500

    [NowPlaying] Allow replacing TrackInfoDisplay
    
    Also add banshee-1-nowplaying.pc for external apps/extensions to
    build against.
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>

 build/pkg-config/banshee-1-nowplaying.pc.in        |   10 +++++++++
 .../Banshee.NowPlaying/NowPlayingContents.cs       |   22 +++++++++++++++++++-
 .../Banshee.NowPlaying/NowPlayingInterface.cs      |   21 ++++++++++---------
 .../Banshee.NowPlaying/NowPlayingSource.cs         |   16 ++++++++++++++
 4 files changed, 58 insertions(+), 11 deletions(-)
---
diff --git a/build/pkg-config/banshee-1-nowplaying.pc.in b/build/pkg-config/banshee-1-nowplaying.pc.in
new file mode 100644
index 0000000..826a4c5
--- /dev/null
+++ b/build/pkg-config/banshee-1-nowplaying.pc.in
@@ -0,0 +1,10 @@
+prefix= prefix@
+exec_prefix=${prefix}
+libdir= libdir@
+bansheedir=${libdir}/banshee-1
+
+Name: Banshee NowPlaying
+Description: Now Playing extension source for Banshee
+Version: @VERSION@
+Libs: -r:${bansheedir}/Extensions/Banshee.NowPlaying.dll
+
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
index 0a14b5f..f411eaf 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
@@ -37,6 +37,7 @@ namespace Banshee.NowPlaying
     {
         private Table table;
         private Widget video_display;
+        private Widget substitute_audio_display;
         private bool video_display_initial_shown = false;
 
         private TrackInfoDisplay track_info_display;
@@ -64,6 +65,23 @@ namespace Banshee.NowPlaying
                 AttachOptions.Expand | AttachOptions.Fill,
                 AttachOptions.Expand | AttachOptions.Fill, 0, 0);
         }
+        
+        internal void SetSubstituteAudioDisplay (Widget widget)
+        {
+            if (substitute_audio_display != null) {
+                table.Remove (substitute_audio_display);
+            }
+            
+            substitute_audio_display = widget;
+            
+            if (widget != null) {
+	            table.Attach (widget, 0, 1, 0, 1,
+	                AttachOptions.Expand | AttachOptions.Fill,
+	                AttachOptions.Expand | AttachOptions.Fill, 0, 0);
+            }
+            
+            CheckIdle ();
+        }
 
         public override void Dispose ()
         {
@@ -112,8 +130,10 @@ namespace Banshee.NowPlaying
             IVideoDisplay ivideo_display = video_display as IVideoDisplay;
             if (ivideo_display != null) {
                 video_display.Visible = !ivideo_display.IsIdle;
-                track_info_display.Visible = ivideo_display.IsIdle;
             }
+            
+            track_info_display.Visible = false;
+            (substitute_audio_display ?? track_info_display).Visible = ivideo_display.IsIdle;
         }
 
         private void OnVideoDisplayIdleStateChanged (object o, EventArgs args)
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
index a8e8966..83b58f3 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
@@ -46,14 +46,15 @@ namespace Banshee.NowPlaying
         private Gtk.Window video_window;
         private FullscreenAdapter fullscreen_adapter;
         private ScreensaverManager screensaver;
-        private NowPlayingContents contents;
+        
+        internal NowPlayingContents Contents { get; private set; }
 
         public NowPlayingInterface ()
         {
             GtkElementsService service = ServiceManager.Get<GtkElementsService> ();
 
-            contents = new NowPlayingContents ();
-            contents.ButtonPressEvent += (o, a) => {
+            Contents = new NowPlayingContents ();
+            Contents.ButtonPressEvent += (o, a) => {
                 if (a.Event.Type == Gdk.EventType.TwoButtonPress) {
                     var iaservice = ServiceManager.Get<InterfaceActionService> ();
                     var action = iaservice.ViewActions["FullScreenAction"] as Gtk.ToggleAction;
@@ -71,7 +72,7 @@ namespace Banshee.NowPlaying
             video_window = new FullscreenWindow (service.PrimaryWindow);
             video_window.Hidden += OnFullscreenWindowHidden;
             video_window.Realize ();
-            video_window.Add (contents);
+            video_window.Add (Contents);
 
             frame = new Hyena.Widgets.RoundedFrame ();
             frame.SetFillColor (new Cairo.Color (0, 0, 0));
@@ -92,17 +93,17 @@ namespace Banshee.NowPlaying
 
         private void MoveVideoExternal (bool hidden)
         {
-            if (contents.Parent != video_window) {
-                contents.Visible = !hidden;
-                contents.Reparent (video_window);
+            if (Contents.Parent != video_window) {
+                Contents.Visible = !hidden;
+                Contents.Reparent (video_window);
             }
         }
 
         private void MoveVideoInternal ()
         {
-            if (contents.Parent != frame) {
-                contents.Reparent (frame);
-                contents.Show ();
+            if (Contents.Parent != frame) {
+                Contents.Reparent (frame);
+                Contents.Show ();
             }
         }
 
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
index 415919f..5f68029 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingSource.cs
@@ -44,6 +44,8 @@ namespace Banshee.NowPlaying
     {
         private TrackInfo transitioned_track;
         private NowPlayingInterface now_playing_interface;
+        
+        private Widget substitute_audio_display;
 
         public NowPlayingSource () : base ("now-playing", Catalog.GetString ("Now Playing"), 10, "now-playing")
         {
@@ -98,12 +100,26 @@ namespace Banshee.NowPlaying
                 OnUserNotifyUpdated ();
             }
         }
+        
+        public void SetSubstituteAudioDisplay (Widget widget)
+        {
+            if (now_playing_interface != null) {
+                now_playing_interface.Contents.SetSubstituteAudioDisplay (widget);
+            } else {
+                substitute_audio_display = widget;
+            }
+        }
 
         public override void Activate ()
         {
             if (now_playing_interface == null) {
                 now_playing_interface = new NowPlayingInterface ();
                 Properties.Set<ISourceContents> ("Nereid.SourceContents", now_playing_interface);
+                
+                if (substitute_audio_display != null) {
+                    now_playing_interface.Contents.SetSubstituteAudioDisplay (substitute_audio_display);
+                    substitute_audio_display = null;
+                }
             }
 
             if (now_playing_interface != null) {



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