[banshee] [Moblin] Worked out, integrated a bunch of UI



commit 798383981274abd341f167d5ff4ca23754fce03d
Author: Aaron Bockover <abockover novell com>
Date:   Mon Oct 12 10:42:43 2009 -0400

    [Moblin] Worked out, integrated a bunch of UI
    
    This implements some layout of various reused widgets for
    providing the Play Queue, playback controls, and track
    info display. Basically an embedded Muinshee.

 .../Banshee.Moblin/Banshee.Moblin.csproj           |    7 +-
 .../Banshee.Moblin/MediaPanelContents.cs           |   55 +++------
 .../Banshee.Moblin/Banshee.Moblin/PlayQueueBox.cs  |   92 ++++++++++++++
 .../Banshee.Moblin/Banshee.Moblin/PlaybackBox.cs   |   52 ++++++++
 .../Banshee.Moblin/Banshee.Moblin/SearchEntry.cs   |  133 ++++++++++++++++++++
 .../Banshee.Moblin/Banshee.Moblin/SearchHeader.cs  |   76 +++++++++++
 src/Extensions/Banshee.Moblin/Makefile.am          |    5 +
 src/Extensions/Makefile.am                         |    2 +-
 8 files changed, 380 insertions(+), 42 deletions(-)
---
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj b/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
index 1fda05d..16b4e90 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
@@ -92,5 +92,10 @@
     <Compile Include="Banshee.Moblin\MediaPanelContents.cs" />
     <Compile Include="Mutter\PanelClient.cs" />
     <Compile Include="Mutter\PanelGtk.cs" />
+    <Compile Include="Banshee.Moblin\SearchEntry.cs" />
+    <Compile Include="Banshee.Moblin\SearchHeader.cs" />
+    <Compile Include="Banshee.Moblin\PlayQueueBox.cs" />
+    <Compile Include="Banshee.Moblin\PlaybackBox.cs" />
+    <Compile Include="Banshee.Moblin\MoblinTrackInfoDisplay.cs" />
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
index 27899e9..c1524dc 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MediaPanelContents.cs
@@ -36,57 +36,32 @@ using Banshee.PlayQueue;
 
 namespace Banshee.Moblin
 {
-    public class MediaPanelContents : Table
+    public class MediaPanelContents : HBox
     {
-        private TerseTrackListView playqueue_view;
-        
-        public MediaPanelContents () : base (2, 2, false)
+        public MediaPanelContents () : base ()
         {
             BuildViews ();
-            FindPlayQueue ();
+            BorderWidth = 10;
+            Spacing = 10;
         }
         
         private void BuildViews ()
         {
-            Attach (new Hyena.Widgets.ScrolledWindow () {
-                (playqueue_view = new TerseTrackListView () {
-                    HasFocus = true
-                })
-            }, 1, 2, 1, 2, AttachOptions.Shrink,
-                AttachOptions.Expand | AttachOptions.Fill, 0, 0);
-            
-            playqueue_view.SetSizeRequest (425, -1);
-            playqueue_view.ColumnController.Insert (new Column (null, "indicator",
-                new ColumnCellStatusIndicator (null), 0.05, true, 20, 20), 0);
-            
+            var left = new VBox ();
+            left.PackStart (new SearchHeader (), false, false, 0);
+            PackStart (left, true, true, 0);
+            PackStart (new PlayQueueBox (), false, false, 0);
+
             ShowAll ();
         }
-
-#region PlayQueue
-
-        private void FindPlayQueue ()
+        
+        protected override void OnParentSet (Widget previous)
         {
-            Banshee.ServiceStack.ServiceManager.SourceManager.SourceAdded += delegate (SourceAddedArgs args) {
-                if (args.Source is Banshee.PlayQueue.PlayQueueSource) {
-                    InitPlayQueue (args.Source as Banshee.PlayQueue.PlayQueueSource);
-                }
-            };
-
-            foreach (Source src in ServiceManager.SourceManager.Sources) {
-                if (src is Banshee.PlayQueue.PlayQueueSource) {
-                    InitPlayQueue (src as Banshee.PlayQueue.PlayQueueSource);
-                }
+            base.OnParentSet (previous);
+            
+            if (Parent != null) {
+                Parent.ModifyBg (StateType.Normal, Style.White);
             }
         }
-
-        private void InitPlayQueue (PlayQueueSource play_queue)
-        {
-            ServiceManager.SourceManager.SetActiveSource (play_queue);
-            //play_queue.TrackModel.Reloaded += HandleTrackModelReloaded;
-            playqueue_view.SetModel (play_queue.TrackModel);
-        }
-
-#endregion
-
     }
 }
\ No newline at end of file
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlayQueueBox.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlayQueueBox.cs
new file mode 100644
index 0000000..aedaddd
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlayQueueBox.cs
@@ -0,0 +1,92 @@
+// 
+// PlayQueueBox.cs
+//  
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 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.Data.Gui;
+using Banshee.Collection.Gui;
+
+using Banshee.ServiceStack;
+using Banshee.Sources;
+using Banshee.PlayQueue;
+
+namespace Banshee.Moblin
+{
+    public class PlayQueueBox : VBox
+    {
+        private TerseTrackListView playqueue_view;
+        
+        public PlayQueueBox ()
+        {
+            Spacing = 5;
+            
+            FindPlayQueue ();
+            
+            PackStart (new PlaybackBox (), false, false, 0);
+            
+            PackStart (new MoblinTrackInfoDisplay () {
+                HeightRequest = 64
+            }, false, false, 10);
+            
+            PackEnd (new Hyena.Widgets.ScrolledWindow () {
+                (playqueue_view = new TerseTrackListView () {
+                    HasFocus = true
+                })
+            }, true, true, 0);
+            
+            playqueue_view.ColumnController.Insert (new Column (null, "indicator",
+                new ColumnCellStatusIndicator (null), 0.05, true, 20, 20), 0);
+            playqueue_view.ColumnController.Add (new Column ("Rating", new ColumnCellRating ("Rating", false), 0.15));
+        }
+        
+        private void FindPlayQueue ()
+        {
+            Banshee.ServiceStack.ServiceManager.SourceManager.SourceAdded += delegate (SourceAddedArgs args) {
+                if (args.Source is Banshee.PlayQueue.PlayQueueSource) {
+                    InitPlayQueue (args.Source as Banshee.PlayQueue.PlayQueueSource);
+                }
+            };
+
+            foreach (Source src in ServiceManager.SourceManager.Sources) {
+                if (src is Banshee.PlayQueue.PlayQueueSource) {
+                    InitPlayQueue (src as Banshee.PlayQueue.PlayQueueSource);
+                }
+            }
+        }
+
+        private void InitPlayQueue (PlayQueueSource play_queue)
+        {
+            ServiceManager.SourceManager.SetActiveSource (play_queue);
+            //play_queue.TrackModel.Reloaded += HandleTrackModelReloaded;
+            playqueue_view.SetModel (play_queue.TrackModel);
+            
+            var header = play_queue.CreateHeaderWidget ();
+            PackStart (header, false, false, 0);
+            header.ShowAll ();
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlaybackBox.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlaybackBox.cs
new file mode 100644
index 0000000..c41560c
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/PlaybackBox.cs
@@ -0,0 +1,52 @@
+// 
+// PlaybackBox.cs
+//  
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 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.Gui;
+using Banshee.Gui.Widgets;
+
+using Banshee.ServiceStack;
+
+namespace Banshee.Moblin
+{
+    public class PlaybackBox : HBox
+    {
+        public PlaybackBox ()
+        {
+            var action_service = ServiceManager.Get<InterfaceActionService> ();
+        
+            PackStart (action_service.PlaybackActions["PreviousAction"].CreateToolItem (), false, false, 0);
+            PackStart (action_service.PlaybackActions["PlayPauseAction"].CreateToolItem (), false, false, 0);
+            PackStart (new NextButton (action_service), false, false, 0);
+            
+            var seek_slider = new ConnectedSeekSlider ();
+            seek_slider.Show ();
+            PackStart (seek_slider, false, false, 0);
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchEntry.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchEntry.cs
new file mode 100644
index 0000000..f22d409
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchEntry.cs
@@ -0,0 +1,133 @@
+// 
+// SearchEntry.cs
+//  
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 Aaron Bockover
+// 
+// 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 Gtk;
+using Mono.Unix;
+
+using Banshee.ServiceStack;
+using Banshee.Gui;
+using Banshee.Collection;
+
+namespace Banshee.Moblin
+{
+    public class SearchEntry : Banshee.Widgets.SearchEntry
+    {
+        public SearchEntry ()
+        {
+            BuildSearchEntry ();
+            
+            InterfaceActionService uia = ServiceManager.Get<InterfaceActionService> ();
+            if (uia != null) {
+                Gtk.Action action = uia.GlobalActions["WikiSearchHelpAction"];
+                if (action != null) {
+                    MenuItem item = new SeparatorMenuItem ();
+                    item.Show ();
+                    Menu.Append (item);
+                    
+                    item = new ImageMenuItem (Stock.Help, null);
+                    item.Activated += delegate { action.Activate (); };
+                    item.Show ();
+                    Menu.Append (item);
+                }
+            }
+            
+            SearchSensitive = true;
+            Show ();
+        }
+        
+        private struct SearchFilter
+        {
+            public int Id;
+            public string Field;
+            public string Title;
+        }
+        
+        private Dictionary<int, SearchFilter> search_filters = new Dictionary<int, SearchFilter> ();
+        
+        private void AddSearchFilter (TrackFilterType id, string field, string title)
+        {
+            SearchFilter filter = new SearchFilter ();
+            filter.Id = (int)id;
+            filter.Field = field;
+            filter.Title = title;
+            search_filters.Add (filter.Id, filter);
+        }
+        
+        private void BuildSearchEntry ()
+        {
+            AddSearchFilter (TrackFilterType.None, String.Empty, Catalog.GetString ("Artist, Album, or Title"));
+            AddSearchFilter (TrackFilterType.SongName, "title", Catalog.GetString ("Track Title"));
+            AddSearchFilter (TrackFilterType.ArtistName, "artist", Catalog.GetString ("Artist Name"));
+            AddSearchFilter (TrackFilterType.AlbumTitle, "album", Catalog.GetString ("Album Title"));
+            AddSearchFilter (TrackFilterType.Genre, "genre", Catalog.GetString ("Genre"));
+            AddSearchFilter (TrackFilterType.Year, "year", Catalog.GetString ("Year"));
+
+            SetSizeRequest (300, -1);
+
+            foreach (SearchFilter filter in search_filters.Values) {
+                AddFilterOption (filter.Id, filter.Title);
+                if (filter.Id == (int)TrackFilterType.None) {
+                    AddFilterSeparator ();
+                }
+            }
+
+            FilterChanged += OnSearchEntryFilterChanged;
+            ActivateFilter ((int)TrackFilterType.None);
+
+            OnSearchEntryFilterChanged (this, EventArgs.Empty);
+        }
+
+        private void OnSearchEntryFilterChanged (object o, EventArgs args)
+        {
+            /* Translators: this is a verb (command), not a noun (things) */
+            EmptyMessage = String.Format (Catalog.GetString ("Filter Results"));
+            /*search_entry.EmptyMessage = String.Format (Catalog.GetString ("Filter on {0}"),
+                search_entry.GetLabelForFilterID (search_entry.ActiveFilterID));*/
+
+            string query = search_filters.ContainsKey (ActiveFilterID)
+                ? search_filters[ActiveFilterID].Field
+                : String.Empty;
+
+            Query = String.IsNullOrEmpty (query) ? String.Empty : query + ":";
+
+            Editable editable = InnerEntry as Editable;
+            if (editable != null) {
+                editable.Position = Query.Length;
+            }
+        }
+               
+        public bool SearchSensitive {
+            get { return Sensitive; }
+            set { Sensitive = value; }
+        }
+        
+        public Banshee.Widgets.SearchEntry Entry {
+            get { return this; }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs
new file mode 100644
index 0000000..25314da
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs
@@ -0,0 +1,76 @@
+// 
+// SearchHeader.cs
+//  
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 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 Hyena.Gui;
+
+namespace Banshee.Moblin
+{
+    public class SearchHeader : HBox
+    {
+        public SearchHeader ()
+        {
+            Spacing = 10;
+            BorderWidth = 10;
+            PackStart (new Label () { Markup = String.Format ("<big><b>{0}</b></big>",
+                Catalog.GetString ("Media")) }, false, false, 0);
+            PackStart (new SearchEntry (), true, true, 0);
+        }
+        
+        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+        {
+            if (!Visible || !IsMapped) {
+                return true;
+            }
+            
+            RenderBackground (evnt.Window, evnt.Region);
+            foreach (var child in Children) {
+                PropagateExpose (child, evnt);
+            }
+            
+            return true;
+        }
+        
+        private void RenderBackground (Gdk.Window window, Gdk.Region region)
+        {   
+            Cairo.Context cr = Gdk.CairoHelper.Create (window);
+            
+            cr.Color = new Cairo.Color (0xe7 / (double)0xff,
+                0xea / (double)0xff, 0xfd / (double)0xff);
+            
+            CairoExtensions.RoundedRectangle (cr,
+                Allocation.X, Allocation.Y,
+                Allocation.Width, Allocation.Height, 5);
+            
+            cr.Fill ();
+            
+            CairoExtensions.DisposeContext (cr);
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Makefile.am b/src/Extensions/Banshee.Moblin/Makefile.am
index c1b2cbb..d824c64 100644
--- a/src/Extensions/Banshee.Moblin/Makefile.am
+++ b/src/Extensions/Banshee.Moblin/Makefile.am
@@ -6,6 +6,11 @@ INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 SOURCES =  \
 	Banshee.Moblin/MediaPanelContents.cs \
 	Banshee.Moblin/MoblinService.cs \
+	Banshee.Moblin/MoblinTrackInfoDisplay.cs \
+	Banshee.Moblin/PlaybackBox.cs \
+	Banshee.Moblin/PlayQueueBox.cs \
+	Banshee.Moblin/SearchEntry.cs \
+	Banshee.Moblin/SearchHeader.cs \
 	Mutter/PanelClient.cs \
 	Mutter/PanelGtk.cs
 
diff --git a/src/Extensions/Makefile.am b/src/Extensions/Makefile.am
index c1792ac..d992dac 100644
--- a/src/Extensions/Makefile.am
+++ b/src/Extensions/Makefile.am
@@ -9,12 +9,12 @@ SUBDIRS = \
 	Banshee.InternetRadio \
 	Banshee.Lastfm \
 	Banshee.MiniMode \
-	Banshee.Moblin \
 	Banshee.MultimediaKeys \
 	Banshee.NotificationArea \
 	Banshee.NowPlaying \
 	Banshee.PlayerMigration \
 	Banshee.PlayQueue \
+	Banshee.Moblin \
 	Banshee.Podcasting \
 	Banshee.Sample \
 	Banshee.SqlDebugConsole \



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