[banshee/gtk3] GSettings: add SchemaEntry properties for FilteredSourceContents children



commit 2f7f7601e110751619c36abc2f4ea436415c5aa9
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Tue Mar 5 00:20:20 2013 +0000

    GSettings: add SchemaEntry properties for FilteredSourceContents children
    
    The configuration settings for the position of the pane containers
    implemented as derived classes of the FilteredSourceContents class
    (CompositeTrackSourceContents, InternetRadioSourceContents and
    PodcastSourceContents) now receive two SchemaEntry objects for the
    position of their container, rather than treating them as the special
    case of the filter "-1" when constructing the namespace to retrieve its
    configuration.
    
    This is a bit more GSettings friendly, but there's more work left to do
    in this class afterwards (for the positive filters).

 .../Banshee.Gui/PersistentPaneController.cs        |    4 ++-
 .../CompositeTrackSourceContents.cs                |   19 +++++++++++++-
 .../FilteredListSourceContents.cs                  |   26 ++++++++++++++-----
 .../InternetRadioSourceContents.cs                 |   21 +++++++++++++++-
 .../PodcastSourceContents.cs                       |   21 +++++++++++++++-
 5 files changed, 80 insertions(+), 11 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs 
b/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs
index d49b30b..51e5bfa 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs
@@ -35,6 +35,8 @@ namespace Banshee.Gui
 {
     public class PersistentPaneController
     {
+        public const string NamespacePrefix = "interface.panes";
+
         private static Dictionary<string, PersistentPaneController> controllers = new Dictionary<string, 
PersistentPaneController> ();
 
         private string @namespace;
@@ -47,7 +49,7 @@ namespace Banshee.Gui
 
         public static void Control (Paned pane, string name)
         {
-            Control (pane, String.Format ("interface.panes.{0}", name), "position", pane.Position);
+            Control (pane, String.Format ("{0}.{1}", NamespacePrefix, name), "position", pane.Position);
         }
 
         public static void Control (Paned pane, SchemaEntry<int> entry)
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs 
b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
index 658b377..b57f62c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
@@ -61,6 +61,23 @@ namespace Banshee.Sources.Gui
 
         private InterfaceActionService action_service;
         private ActionGroup configure_browser_actions;
+        private static readonly string name = "albumartist";
+
+        public static readonly SchemaEntry<int> PaneTopPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.top", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_TOP_POSITION,
+            "Artist/Album Browser Container Top Position",
+            "The position of the Artist/Album browser pane container, when placed at the top"
+        );
+
+        public static readonly SchemaEntry<int> PaneLeftPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.left", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_LEFT_POSITION,
+            "Artist/Album Browser Container Left Position",
+            "The position of the Artist/Album browser pane container, when placed on the left"
+        );
 
         private static string menu_xml = @"
             <ui>
@@ -83,7 +100,7 @@ namespace Banshee.Sources.Gui
             </ui>
         ";
 
-        public CompositeTrackSourceContents () : base ("albumartist")
+        public CompositeTrackSourceContents () : base (name, PaneTopPosition, PaneLeftPosition)
         {
             if (ServiceManager.Contains ("InterfaceActionService")) {
                 action_service = ServiceManager.Get<InterfaceActionService> ();
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs 
b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
index 20daec3..81f8a6f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
@@ -60,6 +60,9 @@ namespace Banshee.Sources.Gui
         private List<object> filter_views = new List<object> ();
         protected List<ScrolledWindow> filter_scrolled_windows = new List<ScrolledWindow> ();
 
+        protected static readonly int DEFAULT_PANE_TOP_POSITION = 375;
+        protected static readonly int DEFAULT_PANE_LEFT_POSITION = 275;
+
         private Dictionary<object, double> model_positions = new Dictionary<object, double> ();
 
         private Paned container;
@@ -67,6 +70,9 @@ namespace Banshee.Sources.Gui
         private InterfaceActionService action_service;
         private ActionGroup browser_view_actions;
 
+        private readonly SchemaEntry<int> pane_top_position;
+        private readonly SchemaEntry<int> pane_left_position;
+
         private static string menu_xml = @"
             <ui>
               <menubar name=""MainMenu"">
@@ -83,9 +89,14 @@ namespace Banshee.Sources.Gui
             </ui>
         ";
 
-        public FilteredListSourceContents (string name)
+        public FilteredListSourceContents (string name,
+                                           SchemaEntry<int> pane_top_position,
+                                           SchemaEntry<int> pane_left_position)
         {
             this.name = name;
+            this.pane_top_position = pane_top_position;
+            this.pane_left_position = pane_top_position;
+
             InitializeViews ();
 
             string position = Layout ();
@@ -247,17 +258,18 @@ namespace Banshee.Sources.Gui
             container.Pack2 (main_scrolled_window, true, false);
             browser_container = filter_box;
 
-            container.Position = top ? 375 : 275;
-            PersistentPaneController.Control (container, ControllerName (top, -1));
+            container.Position = top ? pane_top_position.DefaultValue : pane_left_position.DefaultValue;
+            PersistentPaneController.Control (container, top ? pane_top_position : pane_left_position);
             ShowPack ();
         }
 
         private string ControllerName (bool top, int filter)
         {
-            if (filter == -1)
-                return String.Format ("{0}.browser.{1}", name, top ? "top" : "left");
-            else
-                return String.Format ("{0}.browser.{1}.{2}", name, top ? "top" : "left", filter);
+            if (filter < 0) {
+                throw new ArgumentException ("filter should be positive", "filter");
+            }
+
+            return String.Format ("{0}.browser.{1}.{2}", name, top ? "top" : "left", filter);
         }
 
         private Paned GetPane (bool hpane)
diff --git a/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSourceContents.cs 
b/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSourceContents.cs
index d25c6b5..c590ed4 100644
--- a/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSourceContents.cs
+++ b/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSourceContents.cs
@@ -44,6 +44,7 @@ using Banshee.ServiceStack;
 using Banshee.Collection;
 using Banshee.Collection.Database;
 using Banshee.Collection.Gui;
+using Banshee.Gui;
 
 namespace Banshee.InternetRadio
 {
@@ -52,7 +53,25 @@ namespace Banshee.InternetRadio
         private TrackListView track_view;
         private QueryFilterView<string> genre_view;
 
-        public InternetRadioSourceContents () : base ("iradio")
+        private static readonly string name = "iradio";
+
+        public static readonly SchemaEntry<int> PaneTopPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.top", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_TOP_POSITION,
+            "Internet Radio Browser Pane Container Top Position",
+            "The position of the internet radio browser pane container, when placed at the top"
+        );
+
+        public static readonly SchemaEntry<int> PaneLeftPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.left", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_LEFT_POSITION,
+            "Internet Radio Browser Pane Container Left Position",
+            "The position of the internet radio browser pane container, when placed on the left"
+        );
+
+        public InternetRadioSourceContents () : base (name, PaneTopPosition, PaneLeftPosition)
         {
         }
 
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs 
b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs
index d0dd457..27e7d39 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs
@@ -47,6 +47,7 @@ using Banshee.Collection.Database;
 using Banshee.Collection.Gui;
 
 using Banshee.Podcasting.Data;
+using Banshee.Gui;
 
 
 namespace Banshee.Podcasting.Gui
@@ -56,8 +57,26 @@ namespace Banshee.Podcasting.Gui
         private Grid track_view;
         private PodcastFeedView feed_view;
         private PodcastUnheardFilterView unheard_view;
+        private static readonly string name = "podcast";
+
+        public static readonly SchemaEntry<int> PaneTopPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.top", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_TOP_POSITION,
+            "Podcast Browser Pane Container Top Position",
+            "The position of the podcast browser pane container, when placed at the top"
+        );
+
+        public static readonly SchemaEntry<int> PaneLeftPosition = new SchemaEntry<int> (
+            String.Format ("{0}.{1}.browser.left", PersistentPaneController.NamespacePrefix, name),
+            "position",
+            DEFAULT_PANE_LEFT_POSITION,
+            "Podcast Browser Pane Container Left Position",
+            "The position of the podcast browser pane container, when placed on the left"
+        );
+
 
-        public PodcastSourceContents () : base ("podcast")
+        public PodcastSourceContents () : base (name, PaneTopPosition, PaneLeftPosition)
         {
         }
 


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