banshee r4419 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Preferences src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Preferences.Gui src/Core/Banshee.ThickClient/Resources src/Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui src/Dap/Banshee.Dap/Resources



Author: gburt
Date: Fri Aug 22 22:33:39 2008
New Revision: 4419
URL: http://svn.gnome.org/viewvc/banshee?rev=4419&view=rev

Log:
2008-08-22  Gabriel Burt  <gabriel burt gmail com>

	* src/Dap/Banshee.Dap/Makefile.am:
	* src/Dap/Banshee.Dap/Banshee.Dap.mdp: Add new files.

	* src/Dap/Banshee.Dap/Banshee.Dap/RemovableSource.cs: Use the Name not the
	GenericName in the unmap and delete tracks action labels.

	* src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs:
	* src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs: Use Banshee.Preferences.

	* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Use Banshee.Preferences,
	expose DapSync object, set a Nereid.SourceContents override (and make
	activatable), and override Count to 0 so it doesn't show next to the main
	dap source.

	* src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml: Add eject and sync to
	the toolbar, and sync to the source context menu.

	* src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs: New class, completely
	unfinished, displays the preferences for syncing etc.

	* src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs: Add and handle a
	Synchronize action.

	* src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs: Add
	and check a source property for the assembly the ActiveSourceUIResource
	file is located in.

	* src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs: Make all
	actions important by default, but add protected property to use old
	behavior.  Add another override to UpdateAction.

	* src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackActions.cs: Set the
	default to not be all actions important.

	* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs:
	Listen for the preference's Changed event to update visible/sensitive.

	* src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml: Add a
	placeholder in the removable source context menu.

	* src/Core/Banshee.Services/Banshee.Preferences/Root.cs: Add a Changed
	event and fire it when sensitive/visible change.

	* src/Core/Banshee.Services/Banshee.Preferences/Section.cs: Add
	convenience Add override that takes a SchemaEntry and creates a
	SchemaPreference automatically from its Short and LongDescription.



Added:
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
   trunk/banshee/src/Dap/Banshee.Dap/Resources/
   trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackActions.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/RemovableSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Makefile.am

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	Fri Aug 22 22:33:39 2008
@@ -40,6 +40,8 @@
         private bool visible;
         private object display_widget;
         private object mnemonic_widget;
+
+        public event Action<Root> Changed;
                 
         public Root ()
         {
@@ -79,12 +81,18 @@
         
         public bool Sensitive {
             get { return sensitive; }
-            set { sensitive = value; }
+            set {
+                sensitive = value;
+                OnChanged ();
+            }
         }
         
         public bool Visible {
             get { return visible; }
-            set { visible = value; }
+            set {
+                visible = value;
+                OnChanged ();
+            }
         }
         
         public virtual object DisplayWidget {
@@ -96,5 +104,13 @@
             get { return mnemonic_widget ?? DisplayWidget; }
             set { mnemonic_widget = value; }
         }
+
+        protected void OnChanged ()
+        {
+            Action<Root> handler = Changed;
+            if (handler != null) {
+                handler (this);
+            }
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs	Fri Aug 22 22:33:39 2008
@@ -29,6 +29,8 @@
 using System;
 using System.Collections.Generic;
 
+using Banshee.Configuration;
+
 namespace Banshee.Preferences
 {
     public class Section : Collection<PreferenceBase>
@@ -49,5 +51,10 @@
             Name = name;
             Order = order;
         }
+
+        public void Add<T> (SchemaEntry<T> schema)
+        {
+            Add (new SchemaPreference<T> (schema, schema.ShortDescription, schema.LongDescription));
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs	Fri Aug 22 22:33:39 2008
@@ -43,10 +43,30 @@
         protected Dictionary<string, string> labels = new Dictionary<string, string> ();
         protected Dictionary<string, string> icons = new Dictionary<string, string> ();
 
+        private bool important_by_default = true;
+        protected bool ImportantByDefault {
+            get { return important_by_default; }
+            set { important_by_default = value; }
+        }
+
+        public BansheeActionGroup (string name)
+            : this (ServiceManager.Get<InterfaceActionService> (), name)
+        {
+        }
+        
         public BansheeActionGroup (InterfaceActionService action_service, string name) : base (name)
         {
             this.action_service = action_service;
         }
+
+        public new void Add (ActionEntry [] action_entries)
+        {
+            if (ImportantByDefault) {
+                AddImportant (action_entries);
+            } else {
+                base.Add (action_entries);
+            }
+        }
         
         public void AddImportant (params ActionEntry [] action_entries)
         {
@@ -86,6 +106,11 @@
             }
         }
 
+        public void UpdateAction (string action_name, bool visible_and_sensitive)
+        {
+            UpdateAction (action_name, visible_and_sensitive, visible_and_sensitive);
+        }
+        
         public void UpdateAction (string action_name, bool visible, bool sensitive)
         {
             UpdateAction (action_name, visible, sensitive, null);

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs	Fri Aug 22 22:33:39 2008
@@ -186,9 +186,11 @@
                 AddActionGroup (active_source_actions);
             }
                 
-            Assembly assembly = Assembly.GetAssembly (active_source.GetType ());
+            Assembly assembly = 
+                active_source.Properties.Get<Assembly> ("ActiveSourceUIResource.Assembly") ??
+                Assembly.GetAssembly (active_source.GetType ());
+
             string ui_file = active_source.Properties.Get<string> ("ActiveSourceUIResource");
-            
             if (ui_file != null) {
                 using (StreamReader reader = new StreamReader (assembly.GetManifestResourceStream (ui_file))) {
                     active_source_uiid = ui_manager.AddUiFromString (reader.ReadToEnd ());

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackActions.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackActions.cs	Fri Aug 22 22:33:39 2008
@@ -59,6 +59,8 @@
         
         public PlaybackActions (InterfaceActionService actionService) : base (actionService, "Playback")
         {
+            ImportantByDefault = false;
+
             Add (new ActionEntry [] {
                 new ActionEntry ("PlayPauseAction", null,
                     Catalog.GetString ("_Play"), "space",

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	Fri Aug 22 22:33:39 2008
@@ -43,16 +43,24 @@
             }
             
             Widget display_widget = preference.DisplayWidget as Widget;
+            OnPreferenceChanged (preference);
             
             return display_widget ?? GetWidget (preference, preference.GetType ().GetProperty ("Value").PropertyType);
         }
         
         private static Widget GetWidget (PreferenceBase preference, Type type)
         {
+            Widget widget = null;
             if (type == typeof (bool)) {
-                return new PreferenceCheckButton (preference);
+                widget = new PreferenceCheckButton (preference);
             } else if (type == typeof (string)) {
-                return new PreferenceEntry (preference);
+                widget = new PreferenceEntry (preference);
+            }
+
+            if (widget != null) {
+                preference.Changed += OnPreferenceChanged;
+                //widget.Destroyed += OnWidgetDestroyed;
+                return widget;
             }
             
             return null;
@@ -66,6 +74,19 @@
             
             return preference.MnemonicWidget as Widget;
         }
+
+        /*private static void OnWidgetDestroyed (object sender, EventArgs args)
+        {
+        }*/
+
+        private static void OnPreferenceChanged (Root preference)
+        {
+            Widget widget = preference.DisplayWidget as Widget;
+            if (widget != null) {
+                widget.Sensitive = preference.Sensitive;
+                widget.Visible = preference.Visible;
+            }
+        }
         
         private class PreferenceCheckButton : CheckButton
         {

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	Fri Aug 22 22:33:39 2008
@@ -124,6 +124,7 @@
       <menuitem name="SortChildrenSizeDesc" action="SortChildrenSizeDescAction"/>
     </menu>
     <separator/>
+    <placeholder name="AboveImportSource"/>
     <menuitem name="ImportSource" action="ImportSourceAction"/>
     <menuitem name="RenameSource" action="RenameSourceAction"/>
     <menuitem name="UnmapSource" action="UnmapSourceAction"/>

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs	Fri Aug 22 22:33:39 2008
@@ -0,0 +1,64 @@
+//
+// DapActions.cs
+//
+// Authors:
+//   Gabriel Burt <gburt 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 Mono.Unix;
+using Gtk;
+
+using Banshee.Dap;
+using Banshee.Gui;
+
+namespace Banshee.Dap.Gui
+{
+    public class DapActions : BansheeActionGroup
+    {
+        private DapSource dap;
+        public DapActions (DapSource dap) : base ("dap-actions")
+        {
+            this.dap = dap;
+            AddImportant (
+                new ActionEntry ("SyncDapAction", null,
+                    Catalog.GetString ("Synchronize"), null,
+                    String.Format (Catalog.GetString ("Synchronize {0}"), dap.Name), OnSyncDap)
+            );
+            
+            this["SyncDapAction"].IconName = Stock.Refresh;
+            UpdateActions ();
+        }
+
+        private void UpdateActions ()
+        {
+            UpdateAction ("SyncDapAction", dap.Sync.Enabled);
+        }
+
+        private void OnSyncDap (object o, EventArgs args)
+        {
+            dap.Sync.Sync ();
+        }
+    }
+}

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs	Fri Aug 22 22:33:39 2008
@@ -0,0 +1,109 @@
+//
+// DapContent.cs
+//
+// Authors:
+//   Gabriel Burt <gburt 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 Gtk;
+
+using Hyena;
+using Hyena.Widgets;
+
+using Banshee.Dap;
+using Banshee.Sources.Gui;
+using Banshee.Preferences.Gui;
+
+namespace Banshee.Dap.Gui
+{
+    public class DapContent : ISourceContents
+    {
+        private DapSource dap;
+        private DapActions actions;
+
+        private RoundedFrame frame;
+        private VBox vbox;
+        private WrapLabel dap_stats;
+
+        public DapContent (DapSource source)
+        {
+            dap = source;
+            BuildWidgets ();
+            BuildActions ();
+        }
+
+        private void BuildWidgets ()
+        {
+            frame = new RoundedFrame ();
+            vbox = new VBox ();
+            frame.Add (vbox);
+
+            Label title = new Label ();
+            title.Markup = String.Format ("<span size=\"x-large\" weight=\"bold\">{0}</span>", dap.Name);
+            title.Xalign = 0f;
+            vbox.PackStart (title, false, false, 0);
+            
+            vbox.PackStart (new Banshee.Preferences.Gui.NotebookPage (dap.Preferences), false, false, 0);
+
+            vbox.PackStart (new HSeparator (), false, false, 0);
+
+            dap_stats = new WrapLabel ();
+            dap.Sync.Updated += delegate { dap_stats.Text = dap.Sync.ToString (); };
+            dap_stats.Text = dap.Sync.ToString ();
+            vbox.PackStart (dap_stats, false, false, 0);
+            
+            frame.ShowAll ();
+        }
+
+        private void BuildActions ()
+        {
+            actions = new DapActions (dap);
+            dap.Properties.Set<Banshee.Gui.BansheeActionGroup> ("ActiveSourceActions", actions);
+        }
+
+        #region ISourceContents implementation 
+        
+        public bool SetSource (Banshee.Sources.ISource source)
+        {
+            return (source == this.dap);
+        }
+        
+        public void ResetSource ()
+        {
+        }
+        
+        public Banshee.Sources.ISource Source {
+            get { return dap; }
+        }
+        
+        public Gtk.Widget Widget {
+            get { return frame; }
+        }
+        
+        #endregion 
+        
+    }
+}

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.mdp	Fri Aug 22 22:33:39 2008
@@ -21,6 +21,9 @@
     <File name="Banshee.Dap.Gui/DapPropertiesDisplay.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Dap/DapSync.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Dap/DapLibrarySync.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Dap.Gui/DapContent.cs" subtype="Code" buildaction="Compile" />
+    <File name="Resources/ActiveSourceUI.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.Dap.Gui/DapActions.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
@@ -32,6 +35,7 @@
     <ProjectReference type="Project" localcopy="True" refto="Hyena.Gui" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Widgets" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.ThickClient" />
   </References>
   <GtkDesignInfo gtkVersion="2.12.1" />
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapLibrarySync.cs	Fri Aug 22 22:33:39 2008
@@ -29,10 +29,13 @@
 using System;
 using System.Collections.Generic;
 
+using Mono.Unix;
+
 using Hyena;
 using Hyena.Query;
 
 using Banshee.Configuration;
+using Banshee.Preferences;
 using Banshee.Sources;
 using Banshee.ServiceStack;
 using Banshee.Library;
@@ -50,6 +53,7 @@
         private SchemaEntry<bool> enabled, sync_entire_library;
         private SchemaEntry<string[]> playlist_ids;
         private SmartPlaylistSource sync_src, to_add;
+        private Section library_prefs_section;
         
         #region Public Properties
 
@@ -60,6 +64,10 @@
         public bool SyncEntireLibrary {
             get { return sync_entire_library.Get (); }
         }
+
+        public Section PrefsSection {
+            get { return library_prefs_section; }
+        }
         
         #endregion
         
@@ -93,10 +101,17 @@
         {
             this.sync = sync;
             this.library = library;
+
+            BuildPreferences ();
+            BuildSyncLists ();
+        }
+
+        private void BuildPreferences ()
+        {
             conf_ns = String.Format ("{0}.{1}", sync.ConfigurationNamespace, library.ConfigurationId);
             
             enabled = sync.Dap.CreateSchema<bool> (conf_ns, "enabled", true,
-                "Whether sync is enabled for this device and library source.", "");
+                String.Format (Catalog.GetString ("Sync {0}"), library.Name), "");
             
             sync_entire_library = sync.Dap.CreateSchema<bool> (conf_ns, "sync_entire_library", true,
                 "Whether to sync the entire library and all playlists.", "");
@@ -104,6 +119,14 @@
             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),
+                //String.Format (Catalog.GetString ("{0}"), library.Name)
+                library.Name, 0);
+            library_prefs_section.Add<bool> (enabled);
+        }
+
+        private void BuildSyncLists ()
+        {
             // This smart playlist is the list of items we want on the device - nothing more, nothing less
             sync_src = new SmartPlaylistSource ("sync_list", library.DbId);
             sync_src.IsTemporary = true;

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	Fri Aug 22 22:33:39 2008
@@ -43,6 +43,7 @@
 using Banshee.Hardware;
 using Banshee.MediaEngine;
 using Banshee.MediaProfiles;
+using Banshee.Preferences;
 
 using Banshee.Dap.Gui;
 
@@ -50,7 +51,9 @@
 {
     public abstract class DapSource : RemovableSource, IDisposable
     {
+        private DapSync sync;
         private DapInfoBar dap_info_bar;
+        private Page page;
         // private DapPropertiesDisplay dap_properties_display;
         
         private IDevice device;
@@ -82,7 +85,6 @@
         {
             this.device = device;
             type_unique_id = device.Uuid;
-            space_for_data = CreateSchema<long> ("space_for_data", 0, "How much space, in bytes, to reserve for data on the device.", "");
         }
 
         public override void Dispose ()
@@ -135,7 +137,10 @@
             });
             
             Properties.Set<bool> ("Nereid.SourceContents.HeaderVisible", false);
-            
+            Properties.Set<System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", System.Reflection.Assembly.GetExecutingAssembly ());
+            Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
+
+            sync = new DapSync (this);
             dap_info_bar = new DapInfoBar (this);
             Properties.Set<Gtk.Widget> ("Nereid.SourceContents.FooterWidget", dap_info_bar);
             
@@ -159,11 +164,26 @@
                     : new string [] { "taglib/mp3" };
             }
             
-            music_group_source = new MusicGroupSource (this);
-            video_group_source = new VideoGroupSource (this);
+            AddChildSource (music_group_source = new MusicGroupSource (this));
+            AddChildSource (video_group_source = new VideoGroupSource (this));
 
-            AddChildSource (music_group_source);
-            AddChildSource (video_group_source);
+            BuildPreferences ();
+            Properties.Set<Banshee.Sources.Gui.ISourceContents> ("Nereid.SourceContents", new DapContent (this));
+        }
+
+        private void BuildPreferences ()
+        {
+            page = new Page ();
+            Section main_section = new Section ();
+            main_section.Order = -1;
+            
+            space_for_data = CreateSchema<long> ("space_for_data", 0, "How much space, in bytes, to reserve for data on the device.", "");
+            main_section.Add (space_for_data);
+            page.Add (main_section);
+
+            foreach (Section section in sync.PreferenceSections) {
+                page.Add (section);
+            }
         }
         
         public override void AddChildSource (Source child)
@@ -174,14 +194,15 @@
             
             base.AddChildSource (child);
         }
+
+        // Force to zero so that count doesn't show up
+        public override int Count {
+            get { return 0; }
+        }
         
         public override bool HasProperties {
             get { return true; }
         }
-        
-        public override bool CanActivate {
-            get { return false; }
-        }
 
         public override void SetStatus (string message, bool can_close, bool is_spinning, string icon_name)
         {
@@ -216,10 +237,7 @@
                 LoadFromDevice ();
                 OnTracksAdded ();
                 HideStatus ();
-                
-                using (new Hyena.Timer ("calculating sync for dap..")) {
-                new DapSync (this).CalculateSync ();
-                }
+                sync.CalculateSync ();
             } catch (Exception e) {
                 Log.Exception (e);
             }
@@ -343,7 +361,15 @@
         protected virtual IDeviceMediaCapabilities MediaCapabilities {
             get { return device.MediaCapabilities; }
         }
-        
+
+        public Page Preferences {
+            get { return page; }
+        }
+
+        public DapSync Sync {
+            get { return sync; }
+        }
+
         private ProfileConfiguration preferred_config;
         private ProfileConfiguration PreferredConfiguration {
             get {

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs	Fri Aug 22 22:33:39 2008
@@ -29,6 +29,8 @@
 using System;
 using System.Collections.Generic;
 
+using Mono.Unix;
+
 using Hyena;
 using Hyena.Query;
 
@@ -39,6 +41,7 @@
 using Banshee.Playlist;
 using Banshee.SmartPlaylist;
 using Banshee.Query;
+using Banshee.Preferences;
 
 namespace Banshee.Dap
 {
@@ -47,8 +50,12 @@
         private DapSource dap;
         private string conf_ns;
         private List<DapLibrarySync> library_syncs = new List<DapLibrarySync> ();
-        private SchemaEntry<bool> enabled, auto_sync;
+        private SchemaEntry<bool> manually_manage, auto_sync;
         private SmartPlaylistSource to_remove;
+        private Section dap_prefs_section;
+        private List<Section> pref_sections = new List<Section> ();
+
+        public event Action<DapSync> Updated;
 
         internal string ConfigurationNamespace {
             get { return conf_ns; }
@@ -59,31 +66,61 @@
         public DapSource Dap {
             get { return dap; }
         }
+
+        public IEnumerable<DapLibrarySync> LibrarySyncs {
+            get { return library_syncs; }
+        }
         
         public bool Enabled {
-            get { return enabled.Get (); }
+            get { return manually_manage.Get (); }
         }
         
         public bool AutoSync {
             get { return auto_sync.Get (); }
         }
+
+        public IEnumerable<Section> PreferenceSections {
+            get { return pref_sections; }
+        }
         
         #endregion
         
         public DapSync (DapSource dapSource)
         {
             dap = dapSource;
-            conf_ns = String.Format ("{0}.{1}", dapSource.ConfigurationId, "sync");
+            BuildPreferences ();
+            BuildSyncLists ();
+        }
+
+        private void BuildPreferences ()
+        {
+            conf_ns = String.Format ("{0}.{1}", dap.ConfigurationId, "sync");
             
-            enabled = dap.CreateSchema<bool> (conf_ns, "enabled", true,  // todo change default to false
-                "Whether sync is enabled at all for this device", "");
+            manually_manage = dap.CreateSchema<bool> (conf_ns, "enabled", true,
+                Catalog.GetString ("Manually manage this device"),
+                Catalog.GetString ("Manually managing your device means you can drag and drop items onto the device, and manually remove them.")
+            );
             
             auto_sync = dap.CreateSchema<bool> (conf_ns, "auto_sync", false,
-                "If syncing is enabled, whether to sync the device as soon as its plugged in or the libraries change", "");
+                Catalog.GetString ("Automaticlly sync the device when plugged in or 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);
+            dap_prefs_section.Add (manually_manage);
+            dap_prefs_section.Add (auto_sync);
+            pref_sections.Add (dap_prefs_section);
+        }
+
+        private void BuildSyncLists ()
+        {
+            int i = 0;
             foreach (Source source in ServiceManager.SourceManager.Sources) {
                 if (source is LibrarySource) {
-                    library_syncs.Add (new DapLibrarySync (this, source as LibrarySource));
+                    DapLibrarySync library_sync = new DapLibrarySync (this, source as LibrarySource);
+                    library_syncs.Add (library_sync);
+                    pref_sections.Add (library_sync.PrefsSection);
+                    library_sync.PrefsSection.Order = ++i;
                 }
             }
 
@@ -129,6 +166,11 @@
             }
             to_remove.RefreshAndReload ();
             Log.Information (ToString ());
+
+            Action<DapSync> handler = Updated;
+            if (handler != null) {
+                handler (this);
+            }
         }
 
         public override string ToString ()
@@ -138,7 +180,6 @@
                 sb.Append (library_sync.ToString ());
                 sb.Append ("\n");
             }
-
             sb.Append (String.Format ("And {0} items to remove", to_remove.Count));
             return sb.ToString ();
         }
@@ -146,11 +187,10 @@
         
         public void Sync ()
         {
+            // TODO: remove all items in to_remove
             foreach (DapLibrarySync library_sync in library_syncs) {
                 library_sync.Sync ();
             }
-
-            // TODO: remove all items in to_remove
         }
     }
 }

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/RemovableSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/RemovableSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/RemovableSource.cs	Fri Aug 22 22:33:39 2008
@@ -63,10 +63,10 @@
             DelayDeleteJob = false;
         }
 
-        public override string GenericName {
-            get { return base.GenericName; }
+        public override string Name {
+            get { return base.Name; }
             set {
-                base.GenericName = value;
+                base.Name = value;
                 Properties.SetString ("DeleteTracksActionLabel", String.Format (Catalog.GetString ("Delete From {0}"), value));
                 Properties.SetString ("UnmapSourceActionLabel", String.Format (Catalog.GetString ("Eject {0}"), value));
             }

Modified: trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Makefile.am	Fri Aug 22 22:33:39 2008
@@ -4,6 +4,8 @@
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
+	Banshee.Dap.Gui/DapActions.cs \
+	Banshee.Dap.Gui/DapContent.cs \
 	Banshee.Dap.Gui/DapInfoBar.cs \
 	Banshee.Dap.Gui/DapPropertiesDialog.cs \
 	Banshee.Dap.Gui/DapPropertiesDisplay.cs \
@@ -17,7 +19,9 @@
 	Banshee.Dap/RemovableSource.cs \
 	Banshee.Dap/VideoGroupSource.cs
 
-RESOURCES = Banshee.Dap.addin.xml
+RESOURCES =  \
+	Banshee.Dap.addin.xml \
+	Resources/ActiveSourceUI.xml
 
 include $(top_srcdir)/build/build.mk
 

Added: trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml	Fri Aug 22 22:33:39 2008
@@ -0,0 +1,14 @@
+<ui>
+  <toolbar name="HeaderToolbar">
+    <placeholder name="SourceActions">
+      <toolitem action="UnmapSourceAction"/>
+      <toolitem action="SyncDapAction"/>
+    </placeholder>
+  </toolbar>
+
+  <popup name="RemovableSourceContextMenu" action="RemovableSourceContextMenuAction">
+    <placeholder name="AboveImportSource">
+      <menuitem action="SyncDapAction"/>
+    </placeholder>
+  </popup>
+</ui>



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