banshee r3906 - in trunk/banshee: . build/m4/banshee src/Core/Banshee.Services/Banshee.Preferences src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui src/Core/Banshee.ThickClient/Banshee.Preferences.Gui src/Extensions/Banshee.AudioCd/Banshee.AudioCd



Author: gburt
Date: Thu May  8 01:00:47 2008
New Revision: 3906
URL: http://svn.gnome.org/viewvc/banshee?rev=3906&view=rev

Log:
2008-05-07  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdService.cs: Add
	AutoRip and EjectAfterRipped schemas and preferences.  Fix the mnemonic
	for the profile chooser.

	* src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs: If
	AutoRip is true, start ripping when the CD is loaded (assuming it's not
	already in the library).  When a CD is done importing, eject if if
	EjectAfterRipped is true.

	* src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdRipper.cs: Add a
	Finished event.

	* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs:
	* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs:
	* src/Core/Banshee.Services/Banshee.Preferences/Root.cs: Add a
	optional MnemonicWidget property.  If not set, returns the DisplayWidget,
	otherwise can be used to override the mnemonic widget.

	* src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs:
	Always SetDescription, so even if a user doesn't yet have a preference,
	the description shows the currently selected option.

	* build/m4/banshee/dap-mtp.m4:
	* build/m4/banshee/dap-ipod.m4:
	* configure.ac: Make iPod and MTP support the default, such that if you
	don't have ipod-sharp or libmtp, you will get a configure error unless you
	pass --disable-ipod/mtp.  Should help clarify what we view a default
	Banshee install to include.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/build/m4/banshee/dap-ipod.m4
   trunk/banshee/build/m4/banshee/dap-mtp.m4
   trunk/banshee/configure.ac
   trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdRipper.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdService.cs
   trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs

Modified: trunk/banshee/build/m4/banshee/dap-ipod.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/dap-ipod.m4	(original)
+++ trunk/banshee/build/m4/banshee/dap-ipod.m4	Thu May  8 01:00:47 2008
@@ -2,8 +2,7 @@
 [
 	IPODSHARP_REQUIRED=0.8.0
 
-	AC_ARG_ENABLE(ipod, AC_HELP_STRING([--enable-ipod], 
-		[Enable iPod DAP support]), , enable_ipod="yes")
+	AC_ARG_ENABLE(ipod, AC_HELP_STRING([--disable-ipod], [Disable iPod DAP support]), , enable_ipod="yes")
 
 	enable_ipodsharp="${enable_ipod}"
 
@@ -11,6 +10,10 @@
 		ipod-sharp >= $IPODSHARP_REQUIRED \
 		ipod-sharp-ui >= $IPODSHARP_REQUIRED,
 		enable_ipodsharp="$enable_ipodsharp", enable_ipodsharp=no)
+	
+	if test "x$enable_ipod" = "xyes" -a "x$enable_ipodsharp" = "xno"; then
+		AC_MSG_ERROR([ipod-sharp was not found or is not up to date. Please install ipod-sharp of at least version $IPODSHARP_REQUIRED, or disable iPod support by passing --disable-ipod])
+	fi
 
 	if test "x$enable_ipodsharp" = "xyes"; then
 		asms="`$PKG_CONFIG --variable=Libraries ipod-sharp` `$PKG_CONFIG --variable=Libraries ipod-sharp-ui`"

Modified: trunk/banshee/build/m4/banshee/dap-mtp.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/dap-mtp.m4	(original)
+++ trunk/banshee/build/m4/banshee/dap-mtp.m4	Thu May  8 01:00:47 2008
@@ -2,27 +2,23 @@
 [
 	LIBMTP_REQUIRED=0.2.0
 
-	AC_ARG_ENABLE(mtp, AC_HELP_STRING([--disable-mtp], [Disable MTP DAP support]), , enable_mtp="if_able")
+	AC_ARG_ENABLE(mtp, AC_HELP_STRING([--disable-mtp], [Disable MTP DAP support]), , enable_mtp="yes")
 	
-	enable_mtp_dap="${enable_mtp}"
+	enable_libmtp="${enable_mtp}"
 
 	PKG_CHECK_MODULES(LIBMTP,
 		libmtp >= $LIBMTP_REQUIRED,
-		enable_mtp_dap="$enable_mtp_dap", enable_mtp_dap=no)
+		enable_libmtp="$enable_libmtp", enable_libmtp=no)
 		
-	if test "x$enable_mtp" = "xyes" -a "x$enable_mtp_dap" = "xno"; then
-		AC_MSG_ERROR([libmtp was not found or is not up to date. Please install libmtp of at least version $LIBMTP_REQUIRED, or disable MTP support by not passing --enable-mtp])
+	if test "x$enable_mtp" = "xyes" -a "x$enable_libmtp" = "xno"; then
+		AC_MSG_ERROR([libmtp was not found or is not up to date. Please install libmtp of at least version $LIBMTP_REQUIRED, or disable MTP support by passing --disable-mtp])
 	fi
 
-	if test "x$enable_mtp_dap" = "xif_able"; then
-        enable_mtp_dap="yes"
-    fi
-
-	if test "x$enable_mtp_dap" = "xyes"; then
+	if test "x$enable_libmtp" = "xyes"; then
 		LIBMTP_SO_MAP=$(basename $(find $($PKG_CONFIG --variable=libdir libmtp) -maxdepth 1 -regex '.*libmtp\.so\.\w+$' | sort | tail -n 1))
+		AC_SUBST(LIBMTP_SO_MAP)
 	fi
 
-	AC_SUBST(LIBMTP_SO_MAP)
-	AM_CONDITIONAL(ENABLE_MTP, test "x$enable_mtp_dap" = "xyes")
+	AM_CONDITIONAL(ENABLE_MTP, test "x$enable_libmtp" = "xyes")
 ])
 

Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac	(original)
+++ trunk/banshee/configure.ac	Thu May  8 01:00:47 2008
@@ -183,7 +183,7 @@
 
     Digital Audio Player (DAP) Support:
       Mass Storage:    yes
-      MTP:             ${enable_mtp_dap}
+      MTP:             ${enable_libmtp}
       iPod:            ${enable_ipodsharp}
 
     DAAP Support:      ${enable_daap}	(unstable)

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs	Thu May  8 01:00:47 2008
@@ -39,6 +39,7 @@
         private bool sensitive;
         private bool visible;
         private object display_widget;
+        private object mnemonic_widget;
                 
         public Root ()
         {
@@ -80,5 +81,10 @@
             get { return display_widget; }
             set { display_widget = value; }
         }
+
+        public virtual object MnemonicWidget {
+            get { return mnemonic_widget ?? DisplayWidget; }
+            set { mnemonic_widget = value; }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs	Thu May  8 01:00:47 2008
@@ -67,10 +67,11 @@
             
             ProfileConfiguration config = manager.GetActiveProfileConfiguration (configurationId);
             
-            if(config != null) {
+            if (config != null) {
                 Combo.SetActiveProfile(config.Profile);
-                SetDescription();
             }
+
+            SetDescription();
             
             Combo.Changed += delegate {
                 if(Combo.ActiveProfile != null) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs	Thu May  8 01:00:47 2008
@@ -49,11 +49,11 @@
                     continue;
                 }
                 
-                AddWidget (preference, widget);
+                AddWidget (preference, widget, WidgetFactory.GetMnemonicWidget (preference));
             }
         }
         
-        private void AddWidget (PreferenceBase preference, Widget widget)
+        private void AddWidget (PreferenceBase preference, Widget widget, Widget mnemonic_widget)
         {
             uint start_row = NRows;
             uint start_col = 0;
@@ -71,7 +71,7 @@
                 AttachOptions.Expand | AttachOptions.Fill, 0, 0);
                 
             if (label != null) {
-                label.MnemonicWidget = widget;
+                label.MnemonicWidget = mnemonic_widget ?? widget;
             }
                 
             if (!String.IsNullOrEmpty (preference.Description)) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs	Thu May  8 01:00:47 2008
@@ -57,6 +57,15 @@
             
             return null;
         }
+
+        public static Widget GetMnemonicWidget (PreferenceBase preference)
+        {
+            if (preference == null) {
+                return null;
+            }
+            
+            return preference.MnemonicWidget as Widget;
+        }
         
         private class PreferenceCheckButton : CheckButton
         {

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdRipper.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdRipper.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdRipper.cs	Thu May  8 01:00:47 2008
@@ -62,6 +62,8 @@
                 return ripper_extension_node != null;
             }
         }
+
+        public event EventHandler Finished;
         
         // State that does real work
         private IAudioCdRipper ripper;
@@ -167,6 +169,7 @@
         private void RipNextTrack ()
         {
             if (queue.Count == 0) {
+                OnFinished ();
                 Dispose ();
                 return;
             }
@@ -246,6 +249,14 @@
         }
 
 #endregion
+
+        private void OnFinished ()
+        {
+            EventHandler handler = Finished;
+            if (handler != null) {
+                handler (this, EventArgs.Empty);
+            }
+        }
                                 
 #region User Job Event Handlers        
         

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdService.cs	Thu May  8 01:00:47 2008
@@ -154,9 +154,18 @@
             
             pref_section = service["general"].Add (new Section ("audio-cd", 
                 Catalog.GetString ("Audio CD Importing"), 20));
-                
-            pref_section.Add (new VoidPreference ("import-profile",  Catalog.GetString ("O_utput format")));
+
+            pref_section.Add (new VoidPreference ("import-profile",  Catalog.GetString ("_Import format")));
             pref_section.Add (new VoidPreference ("import-profile-desc"));
+
+            pref_section.Add (new SchemaPreference<bool> (AutoRip, 
+                Catalog.GetString ("_Automatically import audio CDs when inserted"),
+                Catalog.GetString ("When an audio CD is inserted, automatically begin importing it " +
+                    "if metadata can be found and it is not already in the library.")));
+
+            pref_section.Add (new SchemaPreference<bool> (EjectAfterRipped, 
+                Catalog.GetString ("_Eject after importing"),
+                Catalog.GetString ("When an audio CD has been imported, automatically eject it.")));
             
             pref_section.Add (new SchemaPreference<bool> (ErrorCorrection, 
                 Catalog.GetString ("Use error correction when importing"),
@@ -189,6 +198,7 @@
                     "cd-importing", description_box);
             
             pref_section["import-profile"].DisplayWidget = chooser;
+            pref_section["import-profile"].MnemonicWidget = chooser.Combo;
             pref_section["import-profile-desc"].DisplayWidget = description_box;
         }
         
@@ -199,6 +209,20 @@
             "When importing an audio CD, enable error correction (paranoia mode)"
         );
 
+        public static readonly SchemaEntry<bool> AutoRip = new SchemaEntry<bool> (
+            "import", "auto_rip_cds", 
+            false,
+            "Enable audio CD auto ripping",
+            "When an audio CD is inserted, automatically begin ripping it."
+        );
+
+        public static readonly SchemaEntry<bool> EjectAfterRipped = new SchemaEntry<bool> (
+            "import", "eject_after_ripped", 
+            false,
+            "Eject audio CD after ripped",
+            "After an audio CD has been ripped, automatically eject it."
+        );
+
 #endregion
 
 #region UI Actions

Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs	Thu May  8 01:00:47 2008
@@ -114,15 +114,20 @@
                 OnUpdated ();
             }
         
-            if (query_message == null) {
-                return;
-            }
-            
             if (disc_model.MetadataQuerySuccess) {
                 DestroyQueryMessage ();
                 if (DiscIsPlaying) {
                     ServiceManager.PlayerEngine.TrackInfoUpdated ();
                 }
+
+                if (AudioCdService.AutoRip.Get ()) {
+                    BeginAutoRip ();
+                }
+
+                return;
+            }
+
+            if (query_message == null) {
                 return;
             }
             
@@ -142,6 +147,29 @@
             }
         }
 
+        private void BeginAutoRip ()
+        {
+            // Make sure the album isn't already in the Library
+            TrackInfo track = disc_model[0];
+            int count = ServiceManager.DbConnection.Query<int> (
+                @"SELECT Count(*) FROM CoreTracks, CoreArtists, CoreAlbums WHERE 
+                    CoreTracks.PrimarySourceID = ? AND
+                    CoreTracks.ArtistID = CoreArtists.ArtistID AND 
+                    CoreTracks.AlbumID = CoreAlbums.AlbumID AND 
+                    CoreArtists.Name = ? AND CoreAlbums.Title = ? AND (CoreTracks.Disc = ? OR CoreTracks.Disc = 0)",
+                    ServiceManager.SourceManager.MusicLibrary.DbId,
+                    track.ArtistName, track.AlbumTitle, track.Disc
+            );
+
+            if (count > 0) {
+                SetStatus (Catalog.GetString ("Auto rip off because this album is already in the Music Library."), true, false, null);
+                return;
+            }
+
+            Log.DebugFormat ("Beginning auto rip of {0}", Name);
+            ImportDisc ();
+        }
+
         internal void ImportDisc ()
         {
             AudioCdRipper ripper = null;
@@ -149,6 +177,7 @@
             try {
                 if (AudioCdRipper.Supported) {
                     ripper = new AudioCdRipper (this);
+                    ripper.Finished += OnRipperFinished;
                     ripper.Start ();
                 }
             } catch (Exception e) {
@@ -161,6 +190,13 @@
             }
         }
 
+        private void OnRipperFinished (object o, EventArgs args)
+        {
+            if (AudioCdService.EjectAfterRipped.Get ()) {
+                Unmap ();
+            }
+        }
+
         internal void DuplicateDisc ()
         {
             Hyena.Log.Information ("This feature is not implemented yet.", true);



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