[banshee/amazon] Add gconf key and View menu item for Show Context Pane. Add expand and close buttons to the context



commit c08b5057b4ca39e3a92ccd1323fe60ffccf1be62
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Mon May 11 14:01:44 2009 -0500

    Add gconf key and View menu item for Show Context Pane.  Add expand and close buttons to the context pane
---
 src/Clients/Nereid/Nereid/ViewContainer.cs         |    7 ++-
 .../Banshee.Gui.Widgets/ContextPane.cs             |   73 ++++++++++++++++++--
 .../Banshee.ThickClient/Banshee.Gui/ViewActions.cs |    9 +++
 src/Core/Banshee.ThickClient/Makefile.am           |    2 +
 .../Resources/context-pane-close.png               |  Bin 0 -> 239 bytes
 .../Resources/context-pane-maximize.png            |  Bin 0 -> 237 bytes
 .../Resources/core-ui-actions-layout.xml           |    1 +
 .../RecommendationService.cs                       |    6 +-
 8 files changed, 87 insertions(+), 11 deletions(-)

diff --git a/src/Clients/Nereid/Nereid/ViewContainer.cs b/src/Clients/Nereid/Nereid/ViewContainer.cs
index 4b3293b..dc1c738 100644
--- a/src/Clients/Nereid/Nereid/ViewContainer.cs
+++ b/src/Clients/Nereid/Nereid/ViewContainer.cs
@@ -112,9 +112,14 @@ namespace Nereid
             
             PackStart (header, false, false, 0);
             PackEnd (footer, false, false, 0);
+
             var context_pane = new ContextPane ();
-            context_pane.Show ();
+            context_pane.ExpandHandler = b => {
+                SetChildPacking (content.Widget, !b, true, 0, PackType.Start);
+                SetChildPacking (context_pane, b, b, 0, PackType.End);
+            };
             PackEnd (context_pane, false, false, 0);
+
             PackEnd (new ConnectedMessageBar (), false, true, 0);
         }
         
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs
index c14a588..41be2b9 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs
@@ -29,6 +29,7 @@
 using System;
 using System.Collections.Generic;
 
+using Mono.Unix;
 using Mono.Addins;
 
 using Gtk;
@@ -36,6 +37,8 @@ using Gtk;
 using Hyena.Gui;
 
 using Banshee.Base;
+using Banshee.Configuration;
+using Banshee.ServiceStack;
 using Banshee.Gui;
 
 namespace Banshee.Gui.Widgets
@@ -80,11 +83,19 @@ namespace Banshee.Gui.Widgets
 
         private Gtk.Notebook notebook;
         private VBox vbox;
+        private bool large = false;
 
         private RadioButton radio_group = new RadioButton (null, "");
 
         private Dictionary<ContextPanePage, RadioButton> pane_tabs = new Dictionary<ContextPanePage, RadioButton> ();
         private Dictionary<ContextPanePage, Widget> pane_pages = new Dictionary<ContextPanePage, Widget> ();
+
+        private const int MIN_HEIGHT = 200;
+
+        private Action<bool> expand_handler;
+        public Action<bool> ExpandHandler {
+            set { expand_handler = value; }
+        }
         
         public ContextPane ()
         {
@@ -95,15 +106,57 @@ namespace Banshee.Gui.Widgets
 
             vbox = new VBox ();
 
+            HBox hbox = new HBox ();
+            var max = new Button (new Image (IconThemeUtils.LoadIcon ("context-pane-maximize", 7)));
+            max.Clicked += (o, a) => { large = !large; expand_handler (large); };
+            TooltipSetter.Set (tooltip_host, max, Catalog.GetString ("Make the context pane larger or smaller"));
+            
+            var close = new Button (new Image (IconThemeUtils.LoadIcon ("context-pane-close", 7)));
+            close.Clicked += (o, a) => ShowAction.Activate ();
+            TooltipSetter.Set (tooltip_host, close, Catalog.GetString ("Hide context pane"));
+            
+            max.Relief = close.Relief = ReliefStyle.None;
+            hbox.PackStart (max, false, false, 0);
+            hbox.PackStart (close, false, false, 0);
+            vbox.PackStart (hbox, false, false, 0);
+
             PackStart (notebook, true, true, 0);
             PackStart (vbox, false, false, 6);
-            ShowAll ();
             
-            HeightRequest = 200;
+            HeightRequest = MIN_HEIGHT;
 
             // TODO remember/restore the last page
 
             new ContextManager (this);
+
+            Enabled = ShowSchema.Get ();
+            ShowAction.Activated += OnShowContextPane;
+        }
+
+        private Gtk.ToggleAction ShowAction {
+            get { return ServiceManager.Get<InterfaceActionService> ().ViewActions["ShowContextPaneAction"] as ToggleAction; }
+        }
+
+        private void OnShowContextPane (object o, EventArgs args)
+        {
+            Enabled = ShowAction.Active;
+        }
+
+        private bool Enabled {
+            get { return Visible; }
+            set {
+                if (value) {
+                    ShowAll ();
+                } else {
+                    if (expand_handler != null) {
+                        expand_handler (false);
+                    }
+                    large = false;
+                    Hide ();
+                }
+
+                ShowSchema.Set (value);
+            }
         }
 
         public void AddPage (ContextPanePage page)
@@ -116,16 +169,15 @@ namespace Banshee.Gui.Widgets
             notebook.AppendPage (frame, null);
             pane_pages[page] = frame;
 
+            // Setup the tab-like button that switches the notebook to this page
             var tab_image = new Image (IconThemeUtils.LoadIcon (22, page.IconNames));
             var toggle_button = new RadioButton (radio_group) {
                 Child = tab_image,
-                DrawIndicator = false
+                DrawIndicator = false,
+                Relief = ReliefStyle.None
             };
-            toggle_button.Relief = ReliefStyle.None;
-            toggle_button.Clicked += (s, e) => notebook.CurrentPage = notebook.PageNum (pane_pages[page]);
-            
             TooltipSetter.Set (tooltip_host, toggle_button, page.Name);
-
+            toggle_button.Clicked += (s, e) => notebook.CurrentPage = notebook.PageNum (pane_pages[page]);
             toggle_button.ShowAll ();
             vbox.PackStart (toggle_button, false, false, 0);
             pane_tabs[page] = toggle_button;
@@ -142,5 +194,12 @@ namespace Banshee.Gui.Widgets
             pane_tabs.Remove (page);
             pane_pages.Remove (page);
         }
+
+        internal static readonly SchemaEntry<bool> ShowSchema = new SchemaEntry<bool>(
+            "interface", "show_context_pane",
+            true,
+            "Show context pane",
+            "Show context pane for the currently playing track"
+        );
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
index c66eb86..ec35fc9 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/ViewActions.cs
@@ -66,6 +66,15 @@ namespace Banshee.Gui
                    Catalog.GetString ("View the graphical equalizer"), OnShowEqualizer)
             });
 
+            Add (new ToggleActionEntry [] {
+                new ToggleActionEntry (
+                   "ShowContextPaneAction", null,
+                   Catalog.GetString ("_Context Pane"), "",
+                   Catalog.GetString ("Show the context pane beneath the track list"), null,
+                   Banshee.Gui.Widgets.ContextPane.ShowSchema.Get ()
+                )
+            });
+
             AddImportant (new ToggleActionEntry [] {
                 new ToggleActionEntry ("FullScreenAction", "gtk-fullscreen",
                     Catalog.GetString ("_Fullscreen"), "F",
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 8afe5f0..e4f9ad5 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -155,6 +155,8 @@ RESOURCES =  \
 	Resources/banshee-dialogs.glade \
 	Resources/banshee-logo.png \
 	Resources/browser-album-cover.png \
+	Resources/context-pane-close.png \
+	Resources/context-pane-maximize.png \
 	Resources/core-ui-actions-layout.xml \
 	Resources/jcastro.png
 
diff --git a/src/Core/Banshee.ThickClient/Resources/context-pane-close.png b/src/Core/Banshee.ThickClient/Resources/context-pane-close.png
new file mode 100644
index 0000000..71016e2
Binary files /dev/null and b/src/Core/Banshee.ThickClient/Resources/context-pane-close.png differ
diff --git a/src/Core/Banshee.ThickClient/Resources/context-pane-maximize.png b/src/Core/Banshee.ThickClient/Resources/context-pane-maximize.png
new file mode 100644
index 0000000..225c2ab
Binary files /dev/null and b/src/Core/Banshee.ThickClient/Resources/context-pane-maximize.png differ
diff --git a/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml b/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
index 2fce039..e4ea280 100644
--- a/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
+++ b/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
@@ -60,6 +60,7 @@
         <!--<menuitem name="ShowCoverArt" action="ShowCoverArtAction"/>-->
       <placeholder name="BrowserViews"/>
       <placeholder name="ViewMenuAdditions"/>
+      <menuitem name="ShowContextPane" action="ShowContextPaneAction"/>
       <menuitem name="FullScreen" action="FullScreenAction"/>
       <separator/>
       <menuitem name="ShowEqualizer" action="ShowEqualizerAction"/>
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
index d71c323..d42910e 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
@@ -57,11 +57,11 @@ namespace Banshee.Lastfm.Recommendations
 {
     public class RecommendationService : IExtensionService
     {
-        private RecommendationActions actions;
+        //private RecommendationActions actions;
 
         void IExtensionService.Initialize ()
         {
-            actions = new RecommendationActions (this);
+            //actions = new RecommendationActions (this);
 
             ServiceManager.PlaybackController.SourceChanged += OnSourceChanged;
             ServiceManager.SourceManager.ActiveSourceChanged += OnActiveSourceChanged;
@@ -72,7 +72,7 @@ namespace Banshee.Lastfm.Recommendations
             ServiceManager.PlaybackController.SourceChanged -= OnSourceChanged;
             ServiceManager.SourceManager.ActiveSourceChanged -= OnActiveSourceChanged;
 
-            actions.Dispose ();
+            //actions.Dispose ();
         }
 
         private void OnActiveSourceChanged (EventArgs args)



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