banshee r4628 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.MediaProfiles src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui



Author: abock
Date: Mon Sep 29 20:26:18 2008
New Revision: 4628
URL: http://svn.gnome.org/viewvc/banshee?rev=4628&view=rev

Log:
2008-09-29  Aaron Bockover  <abock gnome org>

    * src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBox.cs:
    Ensure that if there's a mimetype restriction filter and no profiles
    exist to match that filter that the combo box becomes insensitive and
    displays 'no profiles'

    * src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs:
    Do not show the profile description box if the combo is insensitive

    * src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs:
    When loading profile configurations, re-run the mimetype check to ensure
    that the profile is actually valid for the request



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBox.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBoxConfigurable.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaProfiles/MediaProfileManager.cs	Mon Sep 29 20:26:18 2008
@@ -198,8 +198,15 @@
         public ProfileConfiguration GetActiveProfileConfiguration(string id, string [] mimetypes)
         {
             ProfileConfiguration config = GetActiveProfileConfiguration (id);
-            if(config != null) {
-                return config;
+            if (config != null) {
+                // Ensure the profile configuration is valid for the mimetype restriction
+                foreach (string profile_mimetype in config.Profile.MimeTypes) {
+                    foreach (string mimetype in mimetypes) {
+                        if (mimetype == profile_mimetype) {
+                            return config;
+                        }
+                    }
+                }
             }
             
             foreach(string mimetype in mimetypes) {

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBox.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBox.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.MediaProfiles.Gui/ProfileComboBox.cs	Mon Sep 29 20:26:18 2008
@@ -69,9 +69,10 @@
             TreeIter active_iter;
             store.Clear();
             
-            List<Profile> mimetype_profiles = new List<Profile>();
+            List<Profile> mimetype_profiles = null;
                 
             if(mimetype_filter != null && mimetype_filter.Length > 0) {
+                mimetype_profiles = new List<Profile>();
                 foreach(string mimetype in mimetype_filter) {
                     Profile profile = manager.GetProfileForMimeType(mimetype);
                     if(profile != null && !mimetype_profiles.Contains(profile)) {
@@ -80,14 +81,15 @@
                 }
             }
             
-            if(manager.AvailableProfileCount == 0 || (mimetype_profiles.Count == 0 && mimetype_filter != null)) {
+            if(manager.AvailableProfileCount == 0 || (mimetype_profiles != null && 
+                mimetype_profiles.Count == 0 && mimetype_filter != null)) {
                 store.AppendValues(Catalog.GetString("No available profiles"), null);
                 Sensitive = false;
             } else {
                 Sensitive = true;
             }
             
-            if(mimetype_profiles.Count > 0) {
+            if(mimetype_profiles != null) {
                 foreach(Profile profile in mimetype_profiles) {
                     store.AppendValues(String.Format("{0}", profile.Name), profile);
                 }

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	Mon Sep 29 20:26:18 2008
@@ -68,18 +68,28 @@
             if (config != null) {
                 Combo.SetActiveProfile(config.Profile);
             }
-
+            
             description = new DescriptionLabel (delegate { return Combo.ActiveProfile.Description; });
             
             Combo.Changed += delegate {
                 if(Combo.ActiveProfile != null) {
-                    ProfileConfiguration.SaveActiveProfile(Combo.ActiveProfile, configurationId);
+                    Hyena.Log.DebugFormat ("Setting active encoding profile: {0} (saved to {1})",
+                        Combo.ActiveProfile.Name, configurationId);
+                    ProfileConfiguration.SaveActiveProfile (Combo.ActiveProfile, configurationId);
                     description.Update ();
                 }
             };
             
+            Combo.StateChanged += delegate {
+                if (Combo.State == StateType.Insensitive) {
+                    ((Container)parent ?? this).Remove (description);
+                } else {
+                    description.PackInto (parent ?? this, parent != null);
+                }
+            };
+            
             Spacing = 5;
-            PackStart(editor, true, true, 0);
+            PackStart (editor, true, true, 0);
             description.PackInto (parent ?? this, parent != null);
         }
         



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