banshee r3804 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Preferences src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs src/Core/Banshee.ThickClient/Banshee.Preferences.Gui
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3804 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.Services/Banshee.Preferences src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs src/Core/Banshee.ThickClient/Banshee.Preferences.Gui
- Date: Tue, 22 Apr 2008 05:10:24 +0100 (BST)
Author: abock
Date: Tue Apr 22 04:10:23 2008
New Revision: 3804
URL: http://svn.gnome.org/viewvc/banshee?rev=3804&view=rev
Log:
2008-04-22 Aaron Bockover <aaron cantank>
This commit adds very initial and incomplete support for better preference
management that makes it easy for extensions to add new preferences
* src/Core/Banshee.Services/Banshee.Preferences/Root.cs: A root object
for all things preferency
* src/Core/Banshee.Services/Banshee.Preferences/Collection.cs: A base
preference object that represents a collection of preference things
* src/Core/Banshee.Services/Banshee.Preferences/Page.cs: Non gui collection
representing pages for the preference dialog
* src/Core/Banshee.Services/Banshee.Preferences/Section.cs: A section
is a group of preferences in a page
* src/Core/Banshee.Services/Banshee.Preferences/Preference.cs: Generic
preference object that maps to as single preference item
* src/Core/Banshee.Services/Banshee.Preferences/PreferenceBase.cs: Base
single item preference object (non-generic)
* src/Core/Banshee.Services/Banshee.Preferences/PreferenceService.cs:
The core preference service
* src/Core/Banshee.Services/Banshee.Preferences/SchemaPreference.cs:
A preference item object that binds to our lovely SchemaEntry configuration
objects that makes exposing configuration as preferences really easy
* src/Core/Banshee.Services/Banshee.Library/LibraryLocationPreference.cs:
Preference object for setting the library location
* src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:
Load the preference service
* src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/BansheeDialog.cs:
A new base dialog object that makes writing new dialogs very nice
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/PreferenceDialog.cs:
The new preference dialog
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/NotebookPage.cs:
A GUI wrapper for the preference Page object
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs:
A GUI wrapper for the preference Section object
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs:
A static class that builds and binds widgets to non-GUI preferences
* src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs:
A set of default preference widget adaptors that represent more complex
UI for interacting with preferences
* src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs: Open the
new preferences dialog
Added:
trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryLocationPreference.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Collection.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Page.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Preference.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceBase.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/SchemaPreference.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/BansheeDialog.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/NotebookPage.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/PreferenceDialog.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
trunk/banshee/src/Core/Banshee.Services/Makefile.am
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryLocationPreference.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryLocationPreference.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,48 @@
+//
+// LibraryLocationPreference.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 Mono.Unix;
+
+using Banshee.Base;
+using Banshee.Preferences;
+
+namespace Banshee.Library
+{
+ public class LibraryLocationPreference : Preference<string>
+ {
+ public LibraryLocationPreference () : base ("library-location", String.Empty)
+ {
+ }
+
+ public override string Value {
+ get { return Paths.LibraryLocation; }
+ set { Paths.LibraryLocation = value; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Collection.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Collection.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,144 @@
+//
+// Collection.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.Collections;
+using System.Collections.Generic;
+
+namespace Banshee.Preferences
+{
+ public class Collection<T> : Root, IList<T> where T : Root
+ {
+ private List<T> list = new List<T> ();
+
+ public Collection ()
+ {
+ }
+
+ public T Add (T item)
+ {
+ lock (this) {
+ list.Add (item);
+ return item;
+ }
+ }
+
+ public T this[string id] {
+ get { return FindById (id); }
+ }
+
+ public T FindById (string id)
+ {
+ lock (this) {
+ foreach (T item in this) {
+ if (item.Id == id) {
+ return item;
+ }
+ }
+
+ return null;
+ }
+ }
+
+#region IList
+
+ void IList<T>.Insert (int index, T item)
+ {
+ list.Insert (index, item);
+ }
+
+ void IList<T>.RemoveAt (int index)
+ {
+ list.RemoveAt (index);
+ }
+
+ int IList<T>.IndexOf (T item)
+ {
+ return list.IndexOf (item);
+ }
+
+ T IList<T>.this[int index] {
+ get { return list[index]; }
+ set { list[index] = value; }
+ }
+
+#endregion
+
+#region ICollection
+
+ void ICollection<T>.Add (T item)
+ {
+ list.Add (item);
+ }
+
+ bool ICollection<T>.Remove (T item)
+ {
+ return list.Remove (item);
+ }
+
+ void ICollection<T>.Clear ()
+ {
+ list.Clear ();
+ }
+
+ bool ICollection<T>.Contains (T item)
+ {
+ return list.Contains (item);
+ }
+
+ void ICollection<T>.CopyTo (T [] array, int arrayIndex)
+ {
+ list.CopyTo (array, arrayIndex);
+ }
+
+ public int Count {
+ get { lock (this) { return list.Count; } }
+ }
+
+ bool ICollection<T>.IsReadOnly {
+ get { return ((ICollection<T>)list).IsReadOnly; }
+ }
+
+#endregion
+
+#region IEnumerable
+
+ public IEnumerator<T> GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+#endregion
+
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Page.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Page.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,59 @@
+//
+// Page.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 Mono.Unix;
+
+using Banshee.Library;
+using Banshee.Configuration.Schema;
+
+namespace Banshee.Preferences
+{
+ public class Page : Collection<Section>
+ {
+ public Page ()
+ {
+ }
+
+ public Page (string id, string name, int order)
+ {
+ Id = id;
+ Name = name;
+ Order = order;
+ }
+
+ internal static void SetupDefaults (PreferenceService service)
+ {
+ Page general = service.Add (new Page ("general", Catalog.GetString ("General"), 0));
+ Section music_library = general.Add (new Section ("music-library", Catalog.GetString ("Music _Library"), 0));
+ music_library.Add (new LibraryLocationPreference ());
+ music_library.Add (new SchemaPreference<bool> (LibrarySchema.CopyOnImport, Catalog.GetString ("Co_py files to media folders when importing")));
+ music_library.Add (new SchemaPreference<bool> (LibrarySchema.WriteMetadata, Catalog.GetString ("Write _metadata to files")));
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Preference.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Preference.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,58 @@
+//
+// Preference.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;
+
+namespace Banshee.Preferences
+{
+ public class Preference<T> : PreferenceBase
+ {
+ private T value;
+
+ public Preference (string id, string name) : this (id, name, default (T))
+ {
+ }
+
+ public Preference (string id, string name, T value)
+ {
+ Id = id;
+ Name = name;
+ this.value = value;
+ }
+
+ public virtual T Value {
+ get { return this.value; }
+ set { this.value = value; }
+ }
+
+ public override object BoxedValue {
+ get { return (object)Value; }
+ set { Value = (T)value; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceBase.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceBase.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,47 @@
+//
+// PreferenceBase.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;
+
+namespace Banshee.Preferences
+{
+ public abstract class PreferenceBase : Root
+ {
+ public PreferenceBase ()
+ {
+ }
+
+ public abstract object BoxedValue { get; set; }
+
+ private object display_widget;
+ public virtual object DisplayWidget {
+ get { return display_widget; }
+ set { display_widget = value; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceService.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/PreferenceService.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,46 @@
+//
+// PreferenceService.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 Banshee.ServiceStack;
+
+namespace Banshee.Preferences
+{
+ public class PreferenceService : Collection<Page>, IRequiredService
+ {
+ public PreferenceService ()
+ {
+ Page.SetupDefaults (this);
+ }
+
+ string IService.ServiceName {
+ get { return "PreferenceService"; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Root.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,72 @@
+//
+// PreferenceBase.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;
+
+namespace Banshee.Preferences
+{
+ public abstract class Root
+ {
+ private string id;
+ private string name;
+ private int order;
+ private bool sensitive;
+ private bool visible;
+
+ public Root ()
+ {
+ sensitive = true;
+ visible = true;
+ }
+
+ public string Id {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public int Order {
+ get { return order; }
+ set { order = value; }
+ }
+
+ public bool Sensitive {
+ get { return sensitive; }
+ set { sensitive = value; }
+ }
+
+ public bool Visible {
+ get { return visible; }
+ set { visible = value; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/SchemaPreference.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/SchemaPreference.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,49 @@
+//
+// SchemaPreference.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 Banshee.Configuration;
+
+namespace Banshee.Preferences
+{
+ public class SchemaPreference<T> : Preference<T>
+ {
+ private SchemaEntry<T> schema;
+
+ public SchemaPreference (SchemaEntry<T> schema, string name) : base (schema.Key, name)
+ {
+ this.schema = schema;
+ }
+
+ public override T Value {
+ get { return schema.Get (); }
+ set { schema.Set (value); }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Preferences/Section.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,53 @@
+//
+// Section.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.Collections.Generic;
+
+namespace Banshee.Preferences
+{
+ public class Section : Collection<PreferenceBase>
+ {
+ private bool show_label = true;
+ public bool ShowLabel {
+ get { return show_label; }
+ set { show_label = value; }
+ }
+
+ public Section ()
+ {
+ }
+
+ public Section (string id, string name, int order)
+ {
+ Id = id;
+ Name = name;
+ Order = order;
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs Tue Apr 22 04:10:23 2008
@@ -62,6 +62,7 @@
{
RegisterService<DBusServiceManager> ();
RegisterService<BansheeDbConnection> ();
+ RegisterService<Banshee.Preferences.PreferenceService> ();
RegisterService<SourceManager> ();
RegisterService<MediaProfileManager> ();
RegisterService<PlayerEngineService> ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp Tue Apr 22 04:10:23 2008
@@ -148,6 +148,15 @@
<File name="Banshee.Collection.Database/CachedList.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.ServiceStack/BatchUserJob.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Sources/IDiskUsageReporter.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/Root.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/Preference.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/Section.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/PreferenceBase.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/Collection.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/PreferenceService.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/Page.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences/SchemaPreference.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Library/LibraryLocationPreference.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am Tue Apr 22 04:10:23 2008
@@ -46,6 +46,7 @@
Banshee.Library/IImportSource.cs \
Banshee.Library/ImportSourceManager.cs \
Banshee.Library/LibraryImportManager.cs \
+ Banshee.Library/LibraryLocationPreference.cs \
Banshee.Library/LibrarySource.cs \
Banshee.Library/MusicLibrarySource.cs \
Banshee.Library/ThreadPoolImportSource.cs \
@@ -97,6 +98,14 @@
Banshee.Playlists.Formats/PlaylistFormatDescription.cs \
Banshee.Playlists.Formats/PlaylistParser.cs \
Banshee.Playlists.Formats/PlsPlaylistFormat.cs \
+ Banshee.Preferences/Collection.cs \
+ Banshee.Preferences/Page.cs \
+ Banshee.Preferences/Preference.cs \
+ Banshee.Preferences/PreferenceBase.cs \
+ Banshee.Preferences/PreferenceService.cs \
+ Banshee.Preferences/Root.cs \
+ Banshee.Preferences/SchemaPreference.cs \
+ Banshee.Preferences/Section.cs \
Banshee.Query/AbstractPlaylistQueryValue.cs \
Banshee.Query/BansheeQuery.cs \
Banshee.Query/NaturalIntegerQueryValue.cs \
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/BansheeDialog.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/BansheeDialog.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,103 @@
+//
+// BansheeDialog.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 Gtk;
+
+using Banshee.ServiceStack;
+using Banshee.Gui;
+
+namespace Banshee.Gui.Dialogs
+{
+ public class BansheeDialog : Gtk.Dialog
+ {
+ private AccelGroup accel_group;
+ protected AccelGroup AccelGroup {
+ get { return accel_group; }
+ }
+
+ public BansheeDialog (string title) : base ()
+ {
+ Title = title;
+ BorderWidth = 5;
+ Visible = false;
+ HasSeparator = false;
+
+ GtkElementsService service = ServiceManager.Get<GtkElementsService> ();
+ if (service != null) {
+ TransientFor = service.PrimaryWindow;
+ }
+
+ WindowPosition = WindowPosition.CenterOnParent;
+ DestroyWithParent = true;
+
+ accel_group = new AccelGroup ();
+ AddAccelGroup (accel_group);
+ }
+
+ public void AddDefaultCloseButton ()
+ {
+ AddStockButton (Stock.Close, ResponseType.Close);
+ }
+
+ public new void AddButton (string message, ResponseType response)
+ {
+ AddButton (message, response, false);
+ }
+
+ public new void AddStockButton (string stock, ResponseType response)
+ {
+ AddStockButton (stock, response, false);
+ }
+
+ public new void AddButton (string message, ResponseType response, bool isDefault)
+ {
+ AddButton (message, response, isDefault, false);
+ }
+
+ public void AddStockButton (string stock, ResponseType response, bool isDefault)
+ {
+ AddButton (stock, response, isDefault, true);
+ }
+
+ public new void AddButton (string message, ResponseType response, bool isDefault, bool isStock)
+ {
+ Button button = new Button (message);
+ button.CanDefault = true;
+ button.UseStock = isStock;
+ button.Show ();
+
+ AddActionWidget (button, response);
+
+ if (isDefault) {
+ DefaultResponse = response;
+ button.AddAccelerator ("activate", accel_group, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs Tue Apr 22 04:10:23 2008
@@ -239,9 +239,12 @@
private void OnPreferences (object o, EventArgs args)
{
- Dialogs.PreferencesDialog dialog = new Dialogs.PreferencesDialog ();
- dialog.Run ();
- dialog.Destroy ();
+ try {
+ Banshee.Preferences.Gui.PreferenceDialog dialog = new Banshee.Preferences.Gui.PreferenceDialog ();
+ dialog.Run ();
+ dialog.Destroy ();
+ } catch (ApplicationException) {
+ }
}
private void OnExtensions (object o, EventArgs args)
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,90 @@
+//
+// DefaultPreferenceWidgets.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 Mono.Unix;
+using Gtk;
+
+using Banshee.Base;
+using Banshee.Library;
+using Banshee.Preferences;
+
+namespace Banshee.Preferences.Gui
+{
+ public static class DefaultPreferenceWidgets
+ {
+ public static void Load (PreferenceService service)
+ {
+ PreferenceBase library_location = service["general"]["music-library"]["library-location"];
+ library_location.DisplayWidget = new LibraryLocationButton (library_location);
+ }
+
+ private class LibraryLocationButton : HBox
+ {
+ private FileChooserButton chooser;
+ private Button reset;
+ private LibraryLocationPreference preference;
+
+ public LibraryLocationButton (PreferenceBase pref)
+ {
+ preference = (LibraryLocationPreference)pref;
+
+ Spacing = 5;
+
+ chooser = new FileChooserButton (Catalog.GetString ("Select library location"),
+ FileChooserAction.SelectFolder);
+ chooser.SetCurrentFolder (preference.Value);
+ chooser.SelectionChanged += OnChooserChanged;
+
+ HBox box = new HBox ();
+ box.Spacing = 2;
+ box.PackStart (new Image (Stock.Undo, IconSize.Button), false, false, 0);
+ box.PackStart (new Label (Catalog.GetString ("Reset")), false, false, 0);
+ reset = new Button ();
+ reset.Clicked += OnReset;
+ reset.Add (box);
+
+ PackStart (chooser, true, true, 0);
+ PackStart (reset, false, false, 0);
+
+ chooser.Show ();
+ reset.ShowAll ();
+ }
+
+ private void OnReset (object o, EventArgs args)
+ {
+ chooser.SetFilename (Paths.DefaultLibraryPath);
+ }
+
+ private void OnChooserChanged (object o, EventArgs args)
+ {
+ preference.Value = chooser.Filename;
+ }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/NotebookPage.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/NotebookPage.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,98 @@
+//
+// PreferencePage.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 Gtk;
+
+using Banshee.Preferences;
+
+namespace Banshee.Preferences.Gui
+{
+ public class NotebookPage : VBox
+ {
+ private Page page;
+ public Page Page {
+ get { return page; }
+ }
+
+ private Label tab_widget;
+ public Widget TabWidget {
+ get { return tab_widget; }
+ }
+
+ public NotebookPage (Page page)
+ {
+ this.page = page;
+
+ BorderWidth = 5;
+ Spacing = 10;
+
+ tab_widget = new Label (page.Name);
+ tab_widget.Show ();
+
+ foreach (Section section in page) {
+ AddSection (section);
+ }
+ }
+
+ private void AddSection (Section section)
+ {
+ Frame frame = null;
+
+ if (section.ShowLabel) {
+ frame = new Frame ();
+ Label label = new Label ();
+ label.Markup = String.Format ("<b>{0}</b>", GLib.Markup.EscapeText (section.Name));
+ label.UseUnderline = true;
+ label.Show ();
+ frame.LabelWidget = label;
+ frame.LabelXalign = 0.0f;
+ frame.LabelYalign = 0.5f;
+ frame.Shadow = ShadowType.None;
+ frame.Show ();
+ PackStart (frame, false, false, 0);
+ }
+
+ Alignment alignment = new Alignment (0.0f, 0.0f, 1.0f, 1.0f);
+ alignment.TopPadding = (uint)(frame == null ? 0 : 5);
+ alignment.LeftPadding = 12;
+ alignment.Show ();
+
+ if (frame != null) {
+ frame.Add (alignment);
+ } else {
+ PackStart (alignment, false, false, 0);
+ }
+
+ SectionBox box = new SectionBox (section);
+ box.Show ();
+
+ alignment.Add (box);
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/PreferenceDialog.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/PreferenceDialog.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,105 @@
+//
+// PreferencesDialog.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.Collections.Generic;
+using Mono.Unix;
+using Gtk;
+
+using Hyena;
+using Banshee.ServiceStack;
+using Banshee.Preferences;
+
+using Banshee.Gui;
+using Banshee.Gui.Dialogs;
+
+namespace Banshee.Preferences.Gui
+{
+ public class PreferenceDialog : BansheeDialog
+ {
+ private PreferenceService service;
+
+ private Dictionary<string, NotebookPage> pages = new Dictionary<string, NotebookPage> ();
+ private Notebook notebook;
+
+ public PreferenceDialog () : base (Catalog.GetString ("Preferences"))
+ {
+ service = ServiceManager.Get<PreferenceService> ();
+
+ if (service == null) {
+ Log.Error (Catalog.GetString ("Could not show preferences"),
+ Catalog.GetString ("The preferences service could not be found."), true);
+
+ throw new ApplicationException ();
+ }
+
+ DefaultPreferenceWidgets.Load (service);
+
+ BuildDialog ();
+ LoadPages ();
+ }
+
+ private void BuildDialog ()
+ {
+ AddDefaultCloseButton ();
+
+ if (service.Count > 1) {
+ notebook = new Notebook ();
+ notebook.Show ();
+
+ VBox.PackStart (notebook, true, true, 0);
+ }
+ }
+
+ private void LoadPages ()
+ {
+ foreach (Page page in service) {
+ LoadPage (page);
+ }
+ }
+
+ private void LoadPage (Page page)
+ {
+ if (pages.ContainsKey (page.Id)) {
+ Log.Warning (String.Format ("Preferences notebook already contains a page with the id `{0}'",
+ page.Id), false);
+ return;
+ }
+
+ NotebookPage page_ui = new NotebookPage (page);
+ page_ui.Show ();
+ pages.Add (page.Id, page_ui);
+
+ if (service.Count == 1) {
+ VBox.PackStart (page_ui, false, false, 0);
+ } else {
+ notebook.AppendPage (page_ui, page_ui.TabWidget);
+ }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/SectionBox.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,53 @@
+//
+// SectionBox.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 Gtk;
+
+using Banshee.Preferences;
+
+namespace Banshee.Preferences.Gui
+{
+ public class SectionBox : VBox
+ {
+ public SectionBox (Section section)
+ {
+ Spacing = 3;
+
+ foreach (PreferenceBase preference in section) {
+ Widget widget = WidgetFactory.GetWidget (preference);
+ if (widget == null) {
+ continue;
+ }
+
+ PackStart (widget, false, false, 0);
+ widget.Show ();
+ }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/WidgetFactory.cs Tue Apr 22 04:10:23 2008
@@ -0,0 +1,109 @@
+//
+// WidgetFactory.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.Reflection;
+using Gtk;
+
+using Banshee.Preferences;
+
+namespace Banshee.Preferences.Gui
+{
+ public static class WidgetFactory
+ {
+ public static Widget GetWidget (PreferenceBase preference)
+ {
+ if (preference == null) {
+ return null;
+ }
+
+ Widget display_widget = preference.DisplayWidget as Widget;
+
+ return display_widget ?? GetWidget (preference, preference.GetType ().GetProperty ("Value").PropertyType);
+ }
+
+ private static Widget GetWidget (PreferenceBase preference, Type type)
+ {
+ if (type == typeof (bool)) {
+ return new PreferenceCheckButton (preference);
+ } else if (type == typeof (string)) {
+ return new PreferenceEntry (preference);
+ }
+
+ return null;
+ }
+
+ private class PreferenceCheckButton : CheckButton
+ {
+ private bool sync;
+ private PreferenceBase preference;
+
+ public PreferenceCheckButton (PreferenceBase preference)
+ {
+ this.preference = preference;
+ Label = preference.Name;
+ UseUnderline = true;
+ Active = (bool)preference.BoxedValue;
+ sync = true;
+ }
+
+ protected override void OnToggled ()
+ {
+ base.OnToggled ();
+
+ if (sync) {
+ preference.BoxedValue = Active;
+ }
+ }
+ }
+
+ private class PreferenceEntry : Entry
+ {
+ private bool sync;
+ private PreferenceBase preference;
+
+ public PreferenceEntry (PreferenceBase preference)
+ {
+ this.preference = preference;
+ string value = (string)preference.BoxedValue;
+ Text = value == null ? String.Empty : value;
+ sync = true;
+ }
+
+ protected override void OnChanged ()
+ {
+ base.OnChanged ();
+
+ if (sync) {
+ Console.WriteLine (Text);
+ preference.BoxedValue = Text;
+ }
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp Tue Apr 22 04:10:23 2008
@@ -99,6 +99,12 @@
<File name="Banshee.Collection.Gui/ColumnCellPositiveInt.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Gui.Widgets/MainMenu.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Gui.Widgets/NextButton.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences.Gui/PreferenceDialog.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Gui.Dialogs/BansheeDialog.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences.Gui/NotebookPage.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences.Gui/SectionBox.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences.Gui/WidgetFactory.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="False" refto="Hyena.Gui" />
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am Tue Apr 22 04:10:23 2008
@@ -24,6 +24,7 @@
Banshee.Equalizer.Gui/EqualizerView.cs \
Banshee.Equalizer.Gui/EqualizerWindow.cs \
Banshee.Gui.Dialogs/AboutDialog.cs \
+ Banshee.Gui.Dialogs/BansheeDialog.cs \
Banshee.Gui.Dialogs/ConfirmShutdownDialog.cs \
Banshee.Gui.Dialogs/ErrorListDialog.cs \
Banshee.Gui.Dialogs/ExtensionManagerDialog.cs \
@@ -76,6 +77,11 @@
Banshee.MediaProfiles.Gui/ProfileConfigureButton.cs \
Banshee.MediaProfiles.Gui/TextViewLabel.cs \
Banshee.Playlist.Gui/PlaylistExportDialog.cs \
+ Banshee.Preferences.Gui/DefaultPreferenceWidgets.cs \
+ Banshee.Preferences.Gui/NotebookPage.cs \
+ Banshee.Preferences.Gui/PreferenceDialog.cs \
+ Banshee.Preferences.Gui/SectionBox.cs \
+ Banshee.Preferences.Gui/WidgetFactory.cs \
Banshee.Query.Gui/BansheeQueryBox.cs \
Banshee.Query.Gui/PlaylistQueryValueEntry.cs \
Banshee.Query.Gui/RatingQueryValueEntry.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]