[banshee] [Playlist Sync] First work toward a cleaner UI



commit bc02fef8f6a80f75c65c787cbbb80e7c0d666e3f
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Nov 19 18:21:22 2009 -0800

    [Playlist Sync] First work toward a cleaner UI

 src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs |   41 +++++++++++++++++++++
 src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs |   19 +++++-----
 src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs        |   38 +++++++++++---------
 3 files changed, 72 insertions(+), 26 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
index 8a5765f..bb0f277 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.Linq;
 
 using Gtk;
 
@@ -34,8 +35,12 @@ using Hyena;
 using Hyena.Data;
 using Hyena.Widgets;
 
+using Mono.Unix;
+
 using Banshee.Dap;
 using Banshee.Sources.Gui;
+using Banshee.ServiceStack;
+using Banshee.Preferences;
 using Banshee.Preferences.Gui;
 
 namespace Banshee.Dap.Gui
@@ -53,6 +58,7 @@ namespace Banshee.Dap.Gui
         public DapContent (DapSource source) : base (source)
         {
             dap = source;
+
             BuildWidgets ();
             BuildActions ();
             dap.Properties.PropertyChanged += OnPropertyChanged;
@@ -69,6 +75,41 @@ namespace Banshee.Dap.Gui
             SetTitleText (dap.Name);
             title.Xalign = 0.0f;
 
+            // Define custom preference widgetry
+            var hbox = new HBox ();
+            var table = new Table ((uint)dap.Sync.Libraries.Count (), 2, false) {
+                RowSpacing = 6,
+                ColumnSpacing = 6
+            };
+            uint i = 0;
+            foreach (var library in dap.Sync.Libraries) {
+                // Translators: {0} is the name of a library, eg 'Music' or 'Podcasts'
+                var label = new Label (String.Format (Catalog.GetString ("{0}:"), library.Name)) { Xalign = 1f };
+                table.Attach (label, 0, 1, i, i + 1);
+
+                var combo = ComboBox.NewText ();
+                combo.RowSeparatorFunc = (model, iter) => { return (string)model.GetValue (iter, 0) == "---"; };
+                combo.AppendText (Catalog.GetString ("Manage manually"));
+                combo.AppendText (Catalog.GetString ("Sync entire library"));
+
+                var playlists = library.Children.Where (c => c is Banshee.Playlist.AbstractPlaylistSource).ToList ();
+                if (playlists.Count > 0) {
+                    combo.AppendText ("---");
+
+                    foreach (var playlist in playlists) {
+                        // Translators: {0} is the name of a playlist
+                        combo.AppendText (String.Format (Catalog.GetString ("Sync from '{0}'"), playlist.Name));
+                    }
+                }
+
+                combo.Active = 0;
+                table.Attach (combo, 1, 2, i, i + 1);
+                i++;
+            }
+            hbox.PackStart (table, false, false, 0);
+            hbox.ShowAll ();
+            dap.Preferences["sync"]["library-options"].DisplayWidget = hbox;
+
             Banshee.Preferences.Gui.NotebookPage properties = new Banshee.Preferences.Gui.NotebookPage (dap.Preferences);
             properties.BorderWidth = 0;
 
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
index 9ec6b47..681cf92 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
@@ -52,9 +52,9 @@ namespace Banshee.Dap
         private string conf_ns;
         private SchemaEntry<bool> enabled, sync_entire_library;
         private SchemaEntry<string[]> playlist_ids;
-        private SchemaPreference<bool> enabled_pref;
+        //private SchemaPreference<bool> enabled_pref;
         private SmartPlaylistSource sync_src, to_add, to_remove;
-        private Section library_prefs_section;
+        //private Section library_prefs_section;
 
         #region Public Properties
 
@@ -67,7 +67,8 @@ namespace Banshee.Dap
         }
 
         public Section PrefsSection {
-            get { return library_prefs_section; }
+            //get { return library_prefs_section; }
+            get { return null; }
         }
 
         public LibrarySource Library {
@@ -129,10 +130,10 @@ namespace Banshee.Dap
             playlist_ids = sync.Dap.CreateSchema<string[]> (conf_ns, "playlist_ids", new string [0],
                 "If sync_entire_library is false, this contains a list of playlist ids specifically to sync", "");
 
-            library_prefs_section = new Section (String.Format ("{0} sync", library.Name), library.Name, 0);
-            enabled_pref = library_prefs_section.Add<bool> (enabled);
-            enabled_pref.ShowDescription = true;
-            enabled_pref.ShowLabel = false;
+            //library_prefs_section = new Section (String.Format ("{0} sync", library.Name), library.Name, 0);
+            //enabled_pref = library_prefs_section.Add<bool> (enabled);
+            //enabled_pref.ShowDescription = true;
+            //enabled_pref.ShowLabel = false;
         }
 
         private void BuildSyncLists ()
@@ -185,9 +186,9 @@ namespace Banshee.Dap
             sync_src.RefreshAndReload ();
             to_add.RefreshAndReload ();
             to_remove.RefreshAndReload ();
-            enabled_pref.Name = String.Format ("{0} ({1})",
+            /*enabled_pref.Name = String.Format ("{0} ({1})",
                 enabled.ShortDescription,
-                String.Format (Catalog.GetString ("{0} to add, {1} to remove"), to_add.Count, to_remove.Count));
+                String.Format (Catalog.GetString ("{0} to add, {1} to remove"), to_add.Count, to_remove.Count));*/
         }
 
         public override string ToString ()
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
index 64e7322..7430cec 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
@@ -61,8 +61,8 @@ namespace Banshee.Dap
         private string conf_ns;
         private List<DapLibrarySync> library_syncs = new List<DapLibrarySync> ();
         private SchemaEntry<bool> manually_manage, auto_sync;
-        private Section dap_prefs_section;
-        private PreferenceBase manually_manage_pref;//, auto_sync_pref;
+        private Section sync_prefs;
+        //private PreferenceBase manually_manage_pref;//, auto_sync_pref;
         private SchemaPreference<bool> auto_sync_pref;
         private List<Section> pref_sections = new List<Section> ();
         private RateLimiter sync_limiter;
@@ -127,22 +127,27 @@ namespace Banshee.Dap
             );
 
             auto_sync = dap.CreateSchema<bool> (conf_ns, "auto_sync", false,
-                Catalog.GetString ("Automatically sync the device when plugged in or when the libraries change"),
+                Catalog.GetString ("Sync when first plugged in and when the libraries change"),
                 Catalog.GetString ("Begin synchronizing the device as soon as the device is plugged in or the libraries change.")
             );
 
-            dap_prefs_section = new Section ("dap", Catalog.GetString ("Sync Preferences"), 0);
-            pref_sections.Add (dap_prefs_section);
+            sync_prefs = new Section ("sync", Catalog.GetString ("Sync Preferences"), 0);// { ShowLabel = false };
+            pref_sections.Add (sync_prefs);
 
-            manually_manage_pref = dap_prefs_section.Add (manually_manage);
+            /*manually_manage_pref = sync_prefs.Add (manually_manage);
+            manually_manage_pref.Visible = false;
             manually_manage_pref.ShowDescription = true;
             manually_manage_pref.ShowLabel = false;
-            manually_manage_pref.ValueChanged += OnManuallyManageChanged;
+            manually_manage_pref.ValueChanged += OnManuallyManageChanged;*/
 
-            auto_sync_pref = dap_prefs_section.Add (auto_sync);
+            sync_prefs.Add (new VoidPreference ("library-options"));
+
+            auto_sync_pref = sync_prefs.Add (auto_sync);
             auto_sync_pref.ValueChanged += OnAutoSyncChanged;
 
-            //manually_manage_pref.Changed += OnEnabledChanged;
+            //var library_prefs = new Section ("library-sync", Catalog.GetString ("Library Sync"), 1);
+            //pref_sections.Add (library_prefs);
+
             //auto_sync_pref.Changed += delegate { OnUpdated (); };
             //OnEnabledChanged (null);
         }
@@ -155,12 +160,11 @@ namespace Banshee.Dap
 
         private void BuildSyncLists ()
         {
-            int i = 0;
             foreach (LibrarySource source in Libraries) {
                 DapLibrarySync library_sync = new DapLibrarySync (this, source);
                 library_syncs.Add (library_sync);
-                pref_sections.Add (library_sync.PrefsSection);
-                library_sync.PrefsSection.Order = ++i;
+                //pref_sections.Add (library_sync.PrefsSection);
+                //library_sync.PrefsSection.Order = ++i;
 
                 source.TracksAdded += OnLibraryChanged;
                 source.TracksDeleted += OnLibraryChanged;
@@ -170,19 +174,19 @@ namespace Banshee.Dap
             dap.TracksDeleted += OnDapChanged;
         }
 
-        private void OnManuallyManageChanged (Root preference)
+        /*private void OnManuallyManageChanged (Root preference)
         {
             UpdateSensitivities ();
             OnUpdated ();
-        }
+        }*/
 
         private void UpdateSensitivities ()
         {
             bool sync_enabled = Enabled;
             auto_sync_pref.Sensitive = sync_enabled;
-            foreach (DapLibrarySync lib_sync in library_syncs) {
+            /*foreach (DapLibrarySync lib_sync in library_syncs) {
                 lib_sync.PrefsSection.Sensitive = sync_enabled;
-            }
+            }*/
         }
 
         private void OnAutoSyncChanged (Root preference)
@@ -221,7 +225,7 @@ namespace Banshee.Dap
             }
          }
 
-        private IEnumerable<LibrarySource> Libraries {
+        internal IEnumerable<LibrarySource> Libraries {
             get {
                 List<Source> sources = new List<Source> (ServiceManager.SourceManager.Sources);
                 sources.Sort (delegate (Source a, Source b) {



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