banshee r3968 - in trunk/banshee: . build src/Backends/Banshee.Gnome src/Backends/Banshee.Gnome/Banshee.GnomeBackend src/Backends/Banshee.Gnome/Resources src/Backends/Banshee.Gnome/ThemeIcons src/Backends/Banshee.Gnome/ThemeIcons/16x16 src/Backends/Banshee.Gnome/ThemeIcons/16x16/actions src/Backends/Banshee.Gnome/ThemeIcons/22x22 src/Backends/Banshee.Gnome/ThemeIcons/22x22/actions src/Backends/Banshee.Gnome/ThemeIcons/32x32 src/Backends/Banshee.Gnome/ThemeIcons/32x32/actions src/Backends/Banshee.Gnome/ThemeIcons/48x48 src/Backends/Banshee.Gnome/ThemeIcons/48x48/actions src/Core/Banshee.Core src/Core/Banshee.Core/Banshee.Base src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Resources



Author: abock
Date: Thu May 22 21:59:21 2008
New Revision: 3968
URL: http://svn.gnome.org/viewvc/banshee?rev=3968&view=rev

Log:
2008-05-22  Aaron Bockover  <abock gnome org>

    * src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs: Added a
    SelectionChanged event

    * src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml:
    Allow the placeholders in the edit menu above the add to playlist entry

    * src/Core/Banshee.Core/Banshee.Base/Paths.cs: Added FindProgramInPath

    * src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs: A quick
    hack to allow launching selected tracks in Brasero as an audio CD project

    * src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs: Load
    Brasero support if it's found on the system



Added:
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs
   trunk/banshee/src/Backends/Banshee.Gnome/Resources/
   trunk/banshee/src/Backends/Banshee.Gnome/Resources/GlobalUI.xml
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/16x16/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/16x16/actions/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/16x16/actions/media-write-cd.png   (contents, props changed)
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/22x22/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/22x22/actions/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/22x22/actions/media-write-cd.png   (contents, props changed)
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/32x32/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/32x32/actions/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/32x32/actions/media-write-cd.png   (contents, props changed)
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/48x48/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/48x48/actions/
   trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/48x48/actions/media-write-cd.png   (contents, props changed)
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/build/build.environment.mk
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp
   trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs
   trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am
   trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
   trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml

Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk	(original)
+++ trunk/banshee/build/build.environment.mk	Thu May 22 21:59:21 2008
@@ -102,7 +102,7 @@
 REF_DAP_IPOD = $(LINK_DAP_DEPS) $(LINK_IPOD)
 
 # Backends
-REF_BACKEND_GNOME = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_GCONF) $(LINK_GNOME)
+REF_BACKEND_GNOME = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_GCONF) $(LINK_GNOME)
 REF_BACKEND_GSTREAMER = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_GLIB)
 REF_BACKEND_UNIX = $(LINK_BANSHEE_CORE_DEPS) $(LINK_MONO_POSIX)
 REF_BACKEND_HAL = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_DBUS)

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.Gnome.mdp	Thu May 22 21:59:21 2008
@@ -11,6 +11,8 @@
     <File name="Banshee.GnomeBackend/GConfConfigurationClient.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.GnomeBackend/GnomeService.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gnome.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.GnomeBackend/Brasero.cs" subtype="Code" buildaction="Compile" />
+    <File name="Resources/GlobalUI.xml" subtype="Code" buildaction="EmbedAsResource" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
@@ -18,6 +20,9 @@
     <ProjectReference type="Project" localcopy="True" refto="Hyena" />
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.16.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Project" localcopy="True" refto="Hyena.Gui" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.ThickClient" />
+    <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
     <BuildFilesVar Sync="True" Name="SOURCES" />

Added: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/Brasero.cs	Thu May 22 21:59:21 2008
@@ -0,0 +1,132 @@
+//
+// Brasero.cs
+//
+// Author:
+//   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 System.IO;
+using System.Text;
+using System.Diagnostics;
+using Mono.Unix;
+
+using Gtk;
+
+using Hyena;
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+using Banshee.Library;
+using Banshee.Gui;
+
+namespace Banshee.GnomeBackend
+{
+    public class Brasero : IDisposable
+    {
+        private string brasero_exec;
+        
+        public Brasero ()
+        {
+            brasero_exec = Paths.FindProgramInPath ("brasero");
+            if (brasero_exec == null) {
+                throw new FileNotFoundException ("brasero");
+            }
+        }
+        
+        public void Initialize ()
+        {
+            InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
+            uia_service.TrackActions.Add (new ActionEntry [] {
+                new ActionEntry ("BurnDiscAction", null,
+                    Catalog.GetString ("Write CD"), null,
+                    Catalog.GetString ("Write selected tracks to an audio CD"),
+                    OnBurnDisc)
+            });
+            
+            Gtk.Action action = uia_service.TrackActions["BurnDiscAction"];
+            action.IconName = "media-write-cd";
+            
+            uia_service.UIManager.AddUiFromResource ("GlobalUI.xml");
+            
+            UpdateActions ();
+            uia_service.TrackActions.SelectionChanged += delegate { UpdateActions (); };
+            ServiceManager.SourceManager.ActiveSourceChanged += delegate { UpdateActions (); };
+        }
+        
+        public void Dispose ()
+        {
+        }
+        
+        private void OnBurnDisc (object o, EventArgs args)
+        {
+            DatabaseSource source = ServiceManager.SourceManager.ActiveSource as DatabaseSource;
+            if (source == null) {
+                return;
+            }
+            
+            StringBuilder file_args = new StringBuilder ();
+            file_args.Append ("-a");
+            
+            foreach (TrackInfo track in source.TrackModel.SelectedItems) {
+                if (track.Uri.IsLocalPath) {
+                    file_args.AppendFormat (" \"{0}\"", track.Uri.AbsolutePath.Replace ("\"", "\\\""));
+                }
+            }
+            
+            try {
+                ProcessStartInfo psi = new ProcessStartInfo (brasero_exec, file_args.ToString ());
+                psi.UseShellExecute = false;
+                Process.Start (psi);
+            } catch (Exception e) {
+                Log.Exception ("Problem starting Brasero", e);
+                Log.Error (Catalog.GetString ("Could not write CD"), 
+                    Catalog.GetString ("Brasero could not be started"), true);
+            }
+        }
+        
+        private void UpdateActions ()
+        {
+            InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
+            Gtk.Action action = uia_service.TrackActions["BurnDiscAction"];
+            
+            bool visible = false;
+            bool sensitive = false;
+            
+            DatabaseSource source = ServiceManager.SourceManager.ActiveSource as DatabaseSource;
+            // FIXME: Figure out how to handle non-music-library sources
+            if (source != null) {
+                if (source is MusicLibrarySource || source.Parent is MusicLibrarySource) {
+                    visible = true;
+                }
+                
+                sensitive = source.TrackModel.Selection.Count > 0;
+            }
+            
+            action.Sensitive = sensitive;
+            action.Visible = visible;
+        }
+    }
+}

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeService.cs	Thu May 22 21:59:21 2008
@@ -35,12 +35,21 @@
 {
     public class GnomeService : IExtensionService, IDisposable 
     {
+        private Brasero brasero;
+        
         public GnomeService ()
         {
         }
         
         public void Initialize ()
         {
+            try {
+                brasero = new Brasero ();
+                brasero.Initialize ();
+            } catch {
+                brasero = null;
+            }
+        
             if (Browser.OpenHandler == null) {
                 Browser.OpenHandler = OpenUrl;
             }
@@ -48,6 +57,11 @@
         
         public void Dispose ()
         {
+            if (brasero != null) {
+                brasero.Dispose ();
+                brasero = null;
+            }
+        
             if (Browser.OpenHandler == (Banshee.Web.Browser.OpenUrlHandler) OpenUrl) {
                 Browser.OpenHandler = null;
             }

Modified: trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am	(original)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Makefile.am	Thu May 22 21:59:21 2008
@@ -4,10 +4,13 @@
 INSTALL_DIR = $(BACKENDS_INSTALL_DIR)
 
 SOURCES =  \
+	Banshee.GnomeBackend/Brasero.cs \
 	Banshee.GnomeBackend/GConfConfigurationClient.cs \
 	Banshee.GnomeBackend/GnomeService.cs
 
-RESOURCES = Banshee.Gnome.addin.xml
+RESOURCES =  \
+	Banshee.Gnome.addin.xml \
+	Resources/GlobalUI.xml
 
 include $(top_srcdir)/build/build.mk
 

Added: trunk/banshee/src/Backends/Banshee.Gnome/Resources/GlobalUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Backends/Banshee.Gnome/Resources/GlobalUI.xml	Thu May 22 21:59:21 2008
@@ -0,0 +1,14 @@
+<ui>
+    <menubar name="MainMenu" action="MainMenuAction">
+        <menu name="EditMenu" action="EditMenuAction">
+            <placeholder name="BelowAddToPlaylist">
+                <menuitem name="BurnDisc" action="BurnDiscAction"></menuitem>
+            </placeholder>
+        </menu>
+    </menubar>
+    <popup name="TrackContextMenu" action="TrackContextMenuAction">
+        <placeholder name="BelowAddToPlaylist">
+            <menuitem name="BurnDisc" action="BurnDiscAction"></menuitem>
+        </placeholder>
+    </popup>
+</ui>

Added: trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/16x16/actions/media-write-cd.png
==============================================================================
Binary file. No diff available.

Added: trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/22x22/actions/media-write-cd.png
==============================================================================
Binary file. No diff available.

Added: trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/32x32/actions/media-write-cd.png
==============================================================================
Binary file. No diff available.

Added: trunk/banshee/src/Backends/Banshee.Gnome/ThemeIcons/48x48/actions/media-write-cd.png
==============================================================================
Binary file. No diff available.

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/Paths.cs	Thu May 22 21:59:21 2008
@@ -79,6 +79,34 @@
             
             return result;
         }
+
+        public static string FindProgramInPath (string command)
+        {
+            foreach (string path in GetExecPaths ()) {
+                string full_path = Path.Combine (path, command);
+                try {
+                    FileInfo info = new FileInfo (full_path);
+                    // FIXME: System.IO is super lame, should check for 0755
+                    if (info.Exists) {
+                        return full_path;
+                    }
+                } catch {
+                }
+            }
+
+            return null;
+        }
+
+        private static string [] GetExecPaths ()
+        {
+            string path = Environment.GetEnvironmentVariable ("PATH");
+            if (String.IsNullOrEmpty (path)) {
+                return new string [] { "/bin", "/usr/bin", "/usr/local/bin" };
+            }
+
+            // this is super lame, should handle quoting/escaping
+            return path.Split (':');
+        }
         
         public static string MakePathRelative (string path, string to)
         {

Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Core.mdp	Thu May 22 21:59:21 2008
@@ -1,4 +1,4 @@
-<Project name="Banshee.Core" fileversion="2.0" UseParentDirectoryAsNamespace="True" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+<Project name="Banshee.Core" fileversion="2.0" language="C#" clr-version="Net_2_0" UseParentDirectoryAsNamespace="True" ctype="DotNetProject">
   <Configurations active="Debug">
     <Configuration name="Debug" ctype="DotNetProjectConfiguration">
       <Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.Core" />

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	Thu May 22 21:59:21 2008
@@ -54,6 +54,8 @@
             "RemoveTracksAction", "RemoveTracksFromLibraryAction", "DeleteTracksFromDriveAction",
             "RateTracksAction", "SelectNoneAction"
         };
+        
+        public event EventHandler SelectionChanged;
 
         public TrackActions (InterfaceActionService actionService) : base (actionService, "Track")
         {
@@ -154,6 +156,7 @@
 
         private void HandleSelectionChanged (object sender, EventArgs args)
         {
+            OnSelectionChanged ();
             UpdateActions ();
         }
 
@@ -161,6 +164,14 @@
         {
             ResetRating ();
         }
+        
+        private void OnSelectionChanged ()
+        {
+            EventHandler handler = SelectionChanged;
+            if (handler != null) {
+                handler (this, EventArgs.Empty);
+            }
+        }
 
 #endregion
 

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 May 22 21:59:21 2008
@@ -15,7 +15,7 @@
     <placeholder name="RepeatButton"/>
   </toolbar>
 
-  <menubar name="MainMenu">
+  <menubar name="MainMenu" action="MainMenuAction">
     <menu name="MediaMenu" action="MediaMenuAction">
       <menuitem name="NewPlaylist" action="NewPlaylistAction"/>
       <menuitem name="NewSmartPlaylist" action="NewSmartPlaylistAction"/>
@@ -30,7 +30,9 @@
     </menu>
 
     <menu name="EditMenu" action="EditMenuAction">
+      <placeholder name="AboveAddToPlaylist"/>
       <menu name="AddToPlaylist" action="AddToPlaylistAction"></menu>
+      <placeholder name="BelowAddToPlaylist"/>
       <menuitem name="TrackProperties" action="TrackPropertiesAction"/>
       <separator/>
       <menuitem name="SelectAll" action="SelectAllAction"/>



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