banshee r4410 - in branches/banshee/abock: . src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor



Author: abock
Date: Wed Aug 20 20:40:40 2008
New Revision: 4410
URL: http://svn.gnome.org/viewvc/banshee?rev=4410&view=rev

Log:
2008-08-20  Aaron Bockover  <abock gnome org>

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs:
    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs:
    Change the expand=false parameters to pass FieldOptions.Shrink; pass
    the dialog reference to the title entry field

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs:
    Do not add a sync button if the field has the FieldOptions.NoSync option

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs:
    Make the navigation API public

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldOptions.cs:
    Added an enum of options to reduce the AddField overloads

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs:
    Implement keyboard navigation when activating the title entry



Added:
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldOptions.cs
Modified:
   branches/banshee/abock/ChangeLog
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
   branches/banshee/abock/src/Core/Banshee.ThickClient/Makefile.am

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs	Wed Aug 20 20:40:40 2008
@@ -68,10 +68,11 @@
             
             // Left
             
-            AddField (left, new TitleEntry (), 
+            AddField (left, new TitleEntry (Dialog), 
                 delegate { return Catalog.GetString ("Track Title:"); },
                 delegate (EditorTrackInfo track, Widget widget) { ((TitleEntry)widget).Text = track.TrackTitle; },
-                delegate (EditorTrackInfo track, Widget widget) { track.TrackTitle = ((TitleEntry)widget).Text; }
+                delegate (EditorTrackInfo track, Widget widget) { track.TrackTitle = ((TitleEntry)widget).Text; },
+                FieldOptions.NoSync
             );
             
             AddField (left, new TextEntry (), 
@@ -138,14 +139,14 @@
                 delegate { return Catalog.GetString ("Year:"); },
                 delegate (EditorTrackInfo track, Widget widget) { ((SpinButtonEntry)widget).Value = track.Year; },
                 delegate (EditorTrackInfo track, Widget widget) { track.Year = (int)((SpinButtonEntry)widget).Value; },
-                false
+                FieldOptions.Shrink
             );
             
             AddField (right, new RatingEntry (), 
                 delegate { return Catalog.GetString ("Rating:"); },
                 delegate (EditorTrackInfo track, Widget widget) { ((RatingEntry)widget).Value = track.Rating; },
                 delegate (EditorTrackInfo track, Widget widget) { track.Rating = ((RatingEntry)widget).Value; },
-                false
+                FieldOptions.Shrink
             );
         }
         

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs	Wed Aug 20 20:40:40 2008
@@ -73,7 +73,7 @@
                 delegate { return Catalog.GetString ("Beats Per Minute:"); },
                 delegate (EditorTrackInfo track, Widget widget) { ((SpinButtonEntry)widget).Value = track.Bpm; },
                 delegate (EditorTrackInfo track, Widget widget) { track.Bpm = (int)((SpinButtonEntry)widget).Value; },
-                false
+                FieldOptions.Shrink
             );
             
             AddField (this, new TextEntry (), 

Added: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldOptions.cs
==============================================================================
--- (empty file)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldOptions.cs	Wed Aug 20 20:40:40 2008
@@ -0,0 +1,40 @@
+//
+// FieldOptions.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.Gui.TrackEditor
+{
+    [Flags]
+    public enum FieldOptions
+    {
+        None = (0 << 0),
+        Shrink = (1 << 0),
+        NoSync = (1 << 1)
+    }
+}

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs	Wed Aug 20 20:40:40 2008
@@ -89,24 +89,24 @@
             FieldValueClosure readClosure, FieldValueClosure writeClosure)
         {
             AddField (parent, EditorUtilities.CreateLabel (String.Empty), field, 
-                labelClosure, readClosure, writeClosure, true);
+                labelClosure, readClosure, writeClosure, FieldOptions.None);
         }
         
         public void AddField (Box parent, Widget field, FieldLabelClosure labelClosure, 
-            FieldValueClosure readClosure, FieldValueClosure writeClosure, bool expand)
+            FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldOptions options)
         {
             AddField (parent, EditorUtilities.CreateLabel (String.Empty), field, 
-                labelClosure, readClosure, writeClosure, expand);
+                labelClosure, readClosure, writeClosure, options);
         }
         
         public void AddField (Box parent, Widget label, Widget field, FieldLabelClosure labelClosure, 
             FieldValueClosure readClosure, FieldValueClosure writeClosure)
         {
-            AddField (parent, label, field, labelClosure, readClosure, writeClosure, true);
+            AddField (parent, label, field, labelClosure, readClosure, writeClosure, FieldOptions.None);
         }
         
         public void AddField (Box parent, Widget label, Widget field, FieldLabelClosure labelClosure, 
-            FieldValueClosure readClosure, FieldValueClosure writeClosure, bool expand)
+            FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldOptions options)
         {
             FieldSlot slot = new FieldSlot ();
             
@@ -115,7 +115,7 @@
             slot.LabelClosure = labelClosure;
             slot.ReadClosure = readClosure;
             slot.WriteClosure = writeClosure;
-            if (MultipleTracks) {
+            if (MultipleTracks && (options & FieldOptions.NoSync) == 0) {
                 slot.SyncButton = EditorUtilities.CreateSyncButton ();
             }
             
@@ -137,7 +137,7 @@
                 };
             }
             
-            if (MultipleTracks) {
+            if (slot.SyncButton != null) {
                 table.Attach (slot.SyncButton, 1, 2, 1, 2, 
                     AttachOptions.Fill, 
                     AttachOptions.Fill, 0, 0);
@@ -149,7 +149,7 @@
                 
             table.ShowAll ();
             
-            if (expand) {
+            if ((options & FieldOptions.Shrink) == 0) {
                 parent.PackStart (table, false, false, 0);
             } else {
                 HBox shrink = new HBox ();

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs	Wed Aug 20 20:40:40 2008
@@ -38,18 +38,38 @@
         private TextEntry entry;
         private Button forward_button;
         
-        public TitleEntry ()
+        public TitleEntry (TrackEditorDialog dialog)
         {
             entry = new TextEntry ();
             entry.Changed += OnChanged;
+            entry.Activated += delegate { 
+                if (dialog.CanGoForward) {
+                    dialog.NavigateForward ();
+                }
+            };
+            entry.KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
+                if ((args.Event.Key == Gdk.Key.Return || args.Event.Key == Gdk.Key.KP_Enter) && 
+                    (args.Event.State & Gdk.ModifierType.ControlMask) != 0 && dialog.CanGoBackward) {
+                    dialog.NavigateBackward ();
+                }
+            };
             entry.Show ();
             
-            forward_button = EditorUtilities.CreateSmallStockButton (Stock.GoForward);
-            forward_button.Show ();
-            
             Spacing = 1;
             PackStart (entry, true, true, 0);
-            PackStart (forward_button, false, false, 0);
+            
+            if (dialog.TrackCount > 1) {
+                dialog.Navigated += delegate { 
+                    forward_button.Sensitive = dialog.CanGoForward; 
+                    entry.HasFocus = true;
+                    entry.SelectRegion (0, entry.Text.Length);
+                };
+                forward_button = EditorUtilities.CreateSmallStockButton (Stock.GoForward);
+                forward_button.Sensitive = dialog.CanGoForward;
+                forward_button.Show ();
+                forward_button.Clicked += delegate { dialog.NavigateForward (); };
+                PackStart (forward_button, false, false, 0);
+            }
         }
                 
         private void OnChanged (object o, EventArgs args)

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs	Wed Aug 20 20:40:40 2008
@@ -35,8 +35,10 @@
 
 using Banshee.Collection;
 using Banshee.Collection.Database;
+using Banshee.ServiceStack;
 
 using Banshee.Gui.Dialogs;
+using Banshee.Collection.Gui;
 
 namespace Banshee.Gui.TrackEditor
 {
@@ -44,6 +46,7 @@
     {
         private VBox main_vbox;
     
+        private Frame header_image_frame;
         private Image header_image;
         private Label header_title_label;
         private Label header_artist_label;
@@ -56,6 +59,8 @@
         
         private List<ITrackEditorPage> pages = new List<ITrackEditorPage> ();
         
+        public event EventHandler Navigated;
+        
         public TrackEditorDialog (TrackListModel model) : base (Catalog.GetString ("Track Editor"))
         {
             LoadTrackModel (model);
@@ -108,10 +113,14 @@
             Table header = new Table (3, 3, false);
             header.ColumnSpacing = 5;
             
+            header_image_frame = new Frame ();
+            
             header_image = new Image ();
             header_image.IconName = "media-optical";
             header_image.PixelSize = 64;
-            header.Attach (header_image, 0, 1, 0, 3,
+            header_image_frame.Add (header_image);
+            
+            header.Attach (header_image_frame, 0, 1, 0, 3,
                 AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
             
             AddHeaderRow (header, 0, Catalog.GetString ("Title:"), out header_title_label);
@@ -228,6 +237,17 @@
             header_artist_label.Text = current_track.DisplayArtistName;
             header_album_label.Text = current_track.DisplayAlbumTitle;
             
+            ArtworkManager artwork = ServiceManager.Get<ArtworkManager> ();
+            Gdk.Pixbuf cover_art = artwork.LookupScale (current_track.ArtworkId, 64);
+            header_image.Pixbuf = cover_art;
+            if (cover_art == null) {
+                header_image.IconName = "media-optical";
+                header_image.PixelSize = 64;
+                header_image_frame.ShadowType = ShadowType.None;
+            } else {
+                header_image_frame.ShadowType = ShadowType.In;
+            }
+            
             foreach (ITrackEditorPage page in pages) {
                 page.LoadTrack (editor_track);
             }
@@ -244,37 +264,45 @@
             return db_selection != null ? db_selection[index] : memory_selection[index];
         }
         
-        protected void NavigateForward ()
+        protected virtual void OnNavigated ()
+        {
+            EventHandler handler = Navigated;
+            if (handler != null) {
+                handler (this, EventArgs.Empty);
+            }
+        }
+        
+        public void NavigateForward ()
         {
             if (current_track_index < TrackCount - 1) {
                 current_track_index++;
+                LoadTrackToEditor ();
+                OnNavigated ();
             }
-            
-            LoadTrackToEditor ();
         }
         
-        protected void NavigateBackward ()
+        public void NavigateBackward ()
         {
             if (current_track_index > 0) {
                 current_track_index--;
+                LoadTrackToEditor ();
+                OnNavigated ();
             }
-            
-            LoadTrackToEditor ();
         }
         
         public int TrackCount {
             get { return db_selection != null ? db_selection.Count : memory_selection.Count; }
         }
         
-        protected int CurrentTrackIndex {
+        public int CurrentTrackIndex {
             get { return current_track_index; }
         }
         
-        protected bool CanGoBackward {
+        public bool CanGoBackward {
             get { return current_track_index > 0; }
         }
         
-        protected bool CanGoForward {
+        public bool CanGoForward {
             get { return current_track_index >= 0 && current_track_index < TrackCount - 1; }
         }
 

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp	Wed Aug 20 20:40:40 2008
@@ -135,6 +135,7 @@
     <File name="Banshee.Gui.TrackEditor/LyricsPage.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gui.TrackEditor/EditorTrackInfo.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gui.TrackEditor/IEditorField.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Gui.TrackEditor/FieldOptions.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="False" refto="Hyena.Gui" />

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Makefile.am	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Makefile.am	Wed Aug 20 20:40:40 2008
@@ -51,6 +51,7 @@
 	Banshee.Gui.TrackEditor/EditorTrackInfo.cs \
 	Banshee.Gui.TrackEditor/EditorUtilities.cs \
 	Banshee.Gui.TrackEditor/ExtraTrackDetailsPage.cs \
+	Banshee.Gui.TrackEditor/FieldOptions.cs \
 	Banshee.Gui.TrackEditor/FieldPage.cs \
 	Banshee.Gui.TrackEditor/IEditorField.cs \
 	Banshee.Gui.TrackEditor/ITrackEditorPage.cs \



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