banshee r4444 - in trunk/banshee: . src/Core/Banshee.ThickClient/Resources src/Core/Banshee.Widgets/Banshee.Widgets src/Extensions/Banshee.RemoteAudio src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio src/Extensions/Banshee.RemoteAudio/Resources



Author: btaylor
Date: Thu Aug 28 22:26:32 2008
New Revision: 4444
URL: http://svn.gnome.org/viewvc/banshee?rev=4444&view=rev

Log:
2008-08-28  Brad Taylor  <brad getcoded net>

	* src/Extensions/Banshee.RemoteAudio/Resources:
	* src/Extensions/Banshee.RemoteAudio/Resources/GlobalUI.xml:
	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio.addin.xml:
	* src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml:
	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioActions.cs:
	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersComboBox.cs:
	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersWidget.cs:
	Add UI to select a remote speaker.

	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioService.cs:
	Thread safety and add debugging information.

	* src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeaker.cs:
	Add a Name property that will hold the fuzzy name of the device.

	* src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs: Add a
	  clear method, and handle setting ActiveValue to null to deselect.



Added:
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioActions.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersComboBox.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersWidget.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Resources/
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Resources/GlobalUI.xml
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio.addin.xml
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioService.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeaker.cs
   trunk/banshee/src/Extensions/Banshee.RemoteAudio/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml	Thu Aug 28 22:26:32 2008
@@ -12,6 +12,7 @@
   </toolbar>
   <toolbar name="FooterToolbar">
     <placeholder name="StatusBar"/>
+    <placeholder name="Extensions"/>
     <placeholder name="RepeatButton"/>
   </toolbar>
 

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs	Thu Aug 28 22:26:32 2008
@@ -50,6 +50,11 @@
             return store.AppendValues(key, value);
         }
         
+        public new void Clear ()
+        {
+            store.Clear ();
+        }
+        
         public T ActiveValue {
             get { 
                 TreeIter iter;
@@ -61,6 +66,11 @@
             }
             
             set {
+                if(value == null) {
+                    SetActiveIter(TreeIter.Zero);
+                    return;
+                }
+
                 for(int i = 0, n = store.IterNChildren(); i < n; i++) {
                     TreeIter iter;
                     if(store.IterNthChild(out iter, i)) {

Modified: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio.addin.xml
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio.addin.xml	(original)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio.addin.xml	Thu Aug 28 22:26:32 2008
@@ -13,6 +13,7 @@
 
   <Dependencies>
     <Addin id="Banshee.Services" version="1.0"/>
+    <Addin id="Banshee.ThickClient" version="1.0"/>
   </Dependencies>
   
   <Extension path="/Banshee/ServiceManager/Service">

Added: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioActions.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioActions.cs	Thu Aug 28 22:26:32 2008
@@ -0,0 +1,53 @@
+//
+// RemoteAudioActions.cs
+//
+// Author:
+//   Brad Taylor <brad getcoded net>
+//
+// 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 System.Collections.Generic;
+
+using Gtk;
+
+using Hyena.Widgets;
+using Banshee.Gui;
+using Banshee.Base;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+
+namespace Banshee.RemoteAudio
+{
+    public class RemoteAudioActions : BansheeActionGroup
+    {
+        public RemoteAudioActions () : base ("RemoteAudio")
+        {
+            AddUiFromFile ("GlobalUI.xml");
+
+            Actions.PopulateToolbarPlaceholder (
+                (Toolbar)Actions.UIManager.GetWidget ("/FooterToolbar"),
+                "/FooterToolbar/Extensions/RemoteAudio", new RemoteSpeakersWidget ());
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteAudioService.cs	Thu Aug 28 22:26:32 2008
@@ -54,7 +54,7 @@
         }
 
         public ReadOnlyCollection<RemoteSpeaker> Speakers {
-            get { return speakers.AsReadOnly (); }
+            get { lock (speakers) { return speakers.AsReadOnly (); } }
         }
         
         void IExtensionService.Initialize ()
@@ -65,6 +65,10 @@
             if (network.Connected) {
                 Browse ();
             }
+
+            // TODO: move this to another service
+            RemoteAudioActions a = new RemoteAudioActions ();
+            a.Register ();
         }
   
         public void Dispose ()
@@ -97,6 +101,7 @@
 
         private void OnServiceAdded (object o, ServiceBrowseEventArgs args)
         {
+            Log.Debug ("Found RAOP service...");
             args.Service.Resolved += OnServiceResolved;
             args.Service.Resolve ();
         }
@@ -113,7 +118,7 @@
                 return;
             }
     
-            Log.DebugFormat ("Resolved a service! ip = {0}", service.HostEntry.AddressList[0]);
+            Log.DebugFormat ("Resolved RAOP service at {0}", service.HostEntry.AddressList[0]);
 
             ITxtRecord record = service.TxtRecord;
 
@@ -138,8 +143,12 @@
                 }
             }
 
-            speakers.Add (new RemoteSpeaker (service.HostEntry.AddressList[0], service.Port,
-                version, sample_rate, sample_size, channels));
+            lock (speakers) {
+                // TODO: better Name
+                speakers.Add (new RemoteSpeaker (service.HostEntry.HostName,
+                    service.HostEntry.AddressList[0], service.Port,
+                    version, sample_rate, sample_size, channels));
+            }
 
             EventHandler handler = SpeakersChanged;
             if (handler != null) {

Modified: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeaker.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeaker.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeaker.cs	Thu Aug 28 22:26:32 2008
@@ -33,33 +33,49 @@
 {
     public class RemoteSpeaker
     {
+        private string name;
+        public string Name {
+            get { return name; }
+        }
+        
+        private IPAddress host;
         public IPAddress Host {
             get { return host; }
         }
 
+        private short port;
         public short Port {
             get { return port; }
         }
 
+        private string version;
         public string Version {
             get { return version; }
         }
 
+        private int sample_rate;
         public int SampleRate {
             get { return sample_rate; }
         }
 
+        private int sample_size;
         public int SampleSize {
             get { return sample_size; }
         }
 
+        private int channels;
         public int Channels {
             get { return channels; }
         }
 
-        internal RemoteSpeaker (IPAddress host, short port, string version,
-                                int sample_rate, int sample_size, int channels)
+        public static RemoteSpeaker None
+            = new RemoteSpeaker ("None", IPAddress.None, 0, String.Empty,
+                                 0, 0, 0);
+
+        internal RemoteSpeaker (string name, IPAddress host, short port, string version,
+            int sample_rate, int sample_size, int channels)
         {
+            this.name = name;
             this.host = host;
             this.port = port;
             this.version = version;
@@ -67,12 +83,5 @@
             this.sample_size = sample_size;
             this.channels = channels;
         }
-
-        private IPAddress host;
-        private short port;
-        private string version;
-        private int sample_rate;
-        private int sample_size;
-        private int channels;
     }
 }

Added: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersComboBox.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersComboBox.cs	Thu Aug 28 22:26:32 2008
@@ -0,0 +1,94 @@
+//
+// RemoteSpeakersComboBox.cs
+//
+// Author:
+//   Brad Taylor <brad getcoded net>
+//
+// 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 System.Collections.Generic;
+
+using Gtk;
+
+using Banshee.Gui;
+using Banshee.Base;
+using Banshee.Widgets;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+
+namespace Banshee.RemoteAudio
+{
+    public class RemoteSpeakersComboBox : DictionaryComboBox<RemoteSpeaker>
+    {
+        private RemoteAudioService audio_svc;
+
+        public RemoteSpeakersComboBox () : base ()
+        {
+            ServiceManager.ServiceStarted += OnServiceStarted;
+        }
+
+        private void OnServiceStarted (ServiceStartedArgs args)
+        {
+            audio_svc = args.Service as RemoteAudioService;
+            if (audio_svc == null) {
+                return;
+            }
+
+            audio_svc.SpeakersChanged += OnSpeakersChanged;
+            ServiceManager.ServiceStarted -= OnServiceStarted;
+
+            ThreadAssist.ProxyToMain(Refresh);
+        }
+
+        private void Refresh ()
+        {
+            // preserve the previous selection, if it exists
+            RemoteSpeaker selected_speaker = ActiveValue;
+
+            Clear ();
+
+            Add ("None", RemoteSpeaker.None);
+
+            foreach (RemoteSpeaker speaker in audio_svc.Speakers) {
+                // TODO: speaker.Name may not be unique
+                try {
+                    Add (speaker.Name, speaker);
+                } catch (Exception e) {
+                    Hyena.Log.Exception (e);
+                }
+            }
+
+            if (selected_speaker != null) {
+                ActiveValue = selected_speaker;
+            } else {
+                ActiveValue = RemoteSpeaker.None;
+            }
+        }
+
+        private void OnSpeakersChanged (object o, EventArgs args)
+        {
+            ThreadAssist.ProxyToMain (Refresh);
+        }
+    }
+}

Added: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersWidget.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Banshee.RemoteAudio/RemoteSpeakersWidget.cs	Thu Aug 28 22:26:32 2008
@@ -0,0 +1,58 @@
+//
+// RemoteSpeakersWidget.cs
+//
+// Author:
+//   Brad Taylor <brad getcoded net>
+//
+// 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 System.Collections.Generic;
+
+using Gtk;
+
+using Hyena.Widgets;
+using Banshee.Gui;
+using Banshee.Base;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+
+namespace Banshee.RemoteAudio
+{
+    public class RemoteSpeakersWidget : HBox
+    {
+        public RemoteSpeakersWidget () : base ()
+        {
+            Spacing = 3;
+
+            Label label = new Label (Catalog.GetString ("_Speaker:"));
+            PackStart (label, false, false, 0);
+
+            RemoteSpeakersComboBox combo = new RemoteSpeakersComboBox ();
+            label.MnemonicWidget = combo;
+            PackStart (combo, false, false, 0);
+
+            ShowAll ();
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.RemoteAudio/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Makefile.am	Thu Aug 28 22:26:32 2008
@@ -5,9 +5,19 @@
 
 SOURCES = \
 	Banshee.RemoteAudio/RemoteAudioService.cs \
+	Banshee.RemoteAudio/RemoteAudioActions.cs \
+	Banshee.RemoteAudio/RemoteSpeakersComboBox.cs \
+	Banshee.RemoteAudio/RemoteSpeakersWidget.cs \
 	Banshee.RemoteAudio/RemoteSpeaker.cs
 
-RESOURCES = Banshee.RemoteAudio.addin.xml
+RESOURCES = \
+    Banshee.RemoteAudio.addin.xml \
+    Resources/GlobalUI.xml
+
+run:
+	pushd $(top_builddir); \
+	make run; \
+	popd;
 
 if REMOTE_AUDIO_ENABLED
 include $(top_srcdir)/build/build.mk

Added: trunk/banshee/src/Extensions/Banshee.RemoteAudio/Resources/GlobalUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.RemoteAudio/Resources/GlobalUI.xml	Thu Aug 28 22:26:32 2008
@@ -0,0 +1,7 @@
+<ui>
+  <toolbar name="FooterToolbar">
+    <placeholder name="Extensions">
+        <placeholder name="RemoteAudio" />
+    </placeholder>
+  </toolbar>
+</ui>



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