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



Author: abock
Date: Sat Aug 23 01:20:06 2008
New Revision: 4423
URL: http://svn.gnome.org/viewvc/banshee?rev=4423&view=rev

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

    This commit enables view and edit modes for the dialog and allows pages
    to be displayed or hidden based on their type and the mode of the editor;
    help is also moved into its own extension page

    * src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml: Add help page

    * src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs: Use wrapper
    API for running the editor dialog

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs:
    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorMode.cs:
    Added enum for page types and editor mode

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs:
    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs:
    Updated to implement new ITrackEditor page API

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ITrackEditorPage.cs:
    Added TabWidget and PageType properties

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs:
    Support edit modes (view and edit) and only show pages as appropriate to
    the mode based on their type

    * src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/HelpPage.cs: Moved
    the Help into an actual extension page



Added:
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorMode.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/HelpPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs
Modified:
   branches/banshee/abock/ChangeLog
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ITrackEditorPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
   branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
   branches/banshee/abock/src/Core/Banshee.ThickClient/Makefile.am

Added: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorMode.cs
==============================================================================
--- (empty file)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorMode.cs	Sat Aug 23 01:20:06 2008
@@ -0,0 +1,38 @@
+//
+// EditorMode.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
+{
+    public enum EditorMode 
+    {
+        Edit,
+        View
+    }
+}

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	Sat Aug 23 01:20:06 2008
@@ -84,6 +84,14 @@
         public virtual Widget Widget {
             get { return this; }
         }
+        
+        public Gtk.Widget TabWidget {
+            get { return null; }
+        }
+        
+        public virtual PageType PageType { 
+            get { return PageType.Edit; }
+        }
     
         public void AddField (Box parent, Widget field, FieldLabelClosure labelClosure, 
             FieldValueClosure readClosure, FieldValueClosure writeClosure)

Added: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/HelpPage.cs
==============================================================================
--- (empty file)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/HelpPage.cs	Sat Aug 23 01:20:06 2008
@@ -0,0 +1,84 @@
+//
+// HelpPage.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;
+
+namespace Banshee.Gui.TrackEditor
+{
+    public class HelpPage : Alignment, ITrackEditorPage
+    {
+        private Box tab_widget;
+        private TrackEditorDialog dialog;
+        
+        public HelpPage () : base (0.5f, 0.5f, 0.0f, 0.0f)
+        {
+            Image help = new Image ();
+            help.Pixbuf = Gdk.Pixbuf.LoadFromResource ("jcastro.png");
+            help.Show ();
+            Add (help);
+            
+            tab_widget = new HBox ();
+            tab_widget.Spacing = 2;
+            tab_widget.PackStart (new Image (Stock.Help, IconSize.Menu), false, false, 0);
+            tab_widget.PackStart (new Label (Title), true, true, 0);
+            tab_widget.ShowAll ();
+        }
+        
+        public void Initialize (TrackEditorDialog dialog)
+        {
+            this.dialog = dialog;
+        }
+        
+        public void LoadTrack (EditorTrackInfo track)
+        {
+            dialog.Notebook.SetTabLabelPacking (this, false, false, PackType.End);
+        }
+        
+        public int Order {
+            get { return 10000; }
+        }
+        
+        public string Title {
+            get { return Catalog.GetString ("Help"); }
+        }
+        
+        public Widget TabWidget {
+            get { return tab_widget; }
+        }
+        
+        public PageType PageType { 
+            get { return PageType.Edit; }
+        }
+        
+        public Gtk.Widget Widget {
+            get { return this; }
+        }
+    }
+}

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ITrackEditorPage.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ITrackEditorPage.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ITrackEditorPage.cs	Sat Aug 23 01:20:06 2008
@@ -39,6 +39,8 @@
         
         int Order { get; }
         string Title { get; }
+        PageType PageType { get; }
+        Gtk.Widget TabWidget { get; }
         Gtk.Widget Widget { get; }
     }
 }

Added: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs
==============================================================================
--- (empty file)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs	Sat Aug 23 01:20:06 2008
@@ -0,0 +1,39 @@
+//
+// PageType.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
+{
+    public enum PageType
+    {
+        Edit,
+        View,
+        ViewOnly
+    }
+}

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs	Sat Aug 23 01:20:06 2008
@@ -169,6 +169,14 @@
             get { return Catalog.GetString ("Properties"); }
         }
         
+        public PageType PageType { 
+            get { return PageType.View; }
+        }
+        
+        public Gtk.Widget TabWidget { 
+            get { return null; }
+        }
+        
         public Gtk.Widget Widget {
             get { return this; }
         }

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	Sat Aug 23 01:20:06 2008
@@ -44,6 +44,26 @@
 {
     public class TrackEditorDialog : BansheeDialog
     {
+        public static void RunEdit (TrackListModel model)
+        {
+            Run (model, EditorMode.Edit);
+        }
+        
+        public static void RunView (TrackListModel model)
+        {
+            Run (model, EditorMode.View);
+        }
+        
+        public static void Run (TrackListModel model, EditorMode mode)
+        {
+            TrackEditorDialog track_editor = new TrackEditorDialog (model, mode);
+            try {
+                track_editor.Run ();
+            } finally {
+                track_editor.Destroy ();
+            }
+        }
+    
         public delegate void EditorTrackOperationClosure (EditorTrackInfo track);
     
         private VBox main_vbox;
@@ -56,25 +76,38 @@
         private Label edit_notif_label;
         
         private Notebook notebook;
+        public Notebook Notebook {
+            get { return notebook; }
+        }
     
         private Button nav_backward_button;
         private Button nav_forward_button;
         private Button sync_all_button;
         
+        private EditorMode mode;
+        
         private List<ITrackEditorPage> pages = new List<ITrackEditorPage> ();
         
         public event EventHandler Navigated;
         
-        public TrackEditorDialog (TrackListModel model) : base (Catalog.GetString ("Track Editor"))
+        public TrackEditorDialog (TrackListModel model, EditorMode mode) : base (Catalog.GetString ("Track Editor"))
         {
+            this.mode = mode;
+            
             LoadTrackModel (model);
         
-            AddStockButton (Stock.Cancel, ResponseType.Cancel);
-            AddStockButton (Stock.Save, ResponseType.Ok);
-            AddNavigationButtons ();
-            
             BorderWidth = 6;
-            WidthRequest = 525;
+            
+            if (mode == EditorMode.Edit) {
+                WidthRequest = 525;
+                AddStockButton (Stock.Cancel, ResponseType.Cancel);
+                AddStockButton (Stock.Save, ResponseType.Ok);
+            } else {
+                AddStockButton (Stock.Close, ResponseType.Close, true);
+                SetSizeRequest (400, 500);
+            }
+            
+            AddNavigationButtons ();
             
             main_vbox = new VBox ();
             main_vbox.Spacing = 10;
@@ -158,9 +191,12 @@
             foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes ("/Banshee/Gui/TrackEditor/NotebookPage")) {
                 try {
                     ITrackEditorPage page = (ITrackEditorPage)node.CreateInstance ();
-                    pages.Add (page);
-                    page.Initialize (this);
-                    page.Widget.Show ();
+                    if ((mode == EditorMode.Edit && (page.PageType == PageType.Edit || page.PageType == PageType.View)) ||
+                        (mode == EditorMode.View && (page.PageType == PageType.View || page.PageType == PageType.ViewOnly))) {
+                        pages.Add (page);
+                        page.Initialize (this);
+                        page.Widget.Show ();
+                    }
                 } catch (Exception e) {
                     Hyena.Log.Exception ("Invalid NotebookPage extension node. Should implement ITrackEditorPage.", e);
                 }
@@ -175,31 +211,18 @@
                     container = box;
                 }
                 container.BorderWidth = 12;
-                notebook.AppendPage (container, new Label (page.Title));
+                notebook.AppendPage (container, page.TabWidget == null ? new Label (page.Title) : page.TabWidget);
             }
             
-            BuildHelp ();
             main_vbox.PackStart (notebook, true, true, 0);
         }
         
-        private void BuildHelp ()
-        {
-            HBox box = new HBox ();
-            box.Spacing = 2;
-            box.PackStart (new Image (Stock.Help, IconSize.Menu), false, false, 0);
-            box.PackStart (new Label (Catalog.GetString ("Help")), true, true, 0);
-            box.ShowAll ();
-            
-            Image help = new Image ();
-            help.Pixbuf = Gdk.Pixbuf.LoadFromResource ("jcastro.png");
-            help.Show ();
-            notebook.AppendPage (help, box);
-            
-            notebook.SetTabLabelPacking (help, false, false, PackType.End);
-        }
-        
         private void BuildFooter ()
         {
+            if (mode == EditorMode.View) {
+                return;
+            }
+        
             HBox button_box = new HBox ();
             button_box.Spacing = 6;
                        

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs	Sat Aug 23 01:20:06 2008
@@ -279,14 +279,8 @@
                 
                 if (handler != null) {
                     handler ();
-                } else {
-                    Banshee.Gui.TrackEditor.TrackEditorDialog track_editor =    
-                        new Banshee.Gui.TrackEditor.TrackEditorDialog (current_source.TrackModel);
-                    try {
-                        track_editor.Run ();
-                    } finally {
-                        track_editor.Destroy ();
-                    }
+                } else {  
+                    Banshee.Gui.TrackEditor.TrackEditorDialog.RunEdit (current_source.TrackModel);
                 }
             }
         }

Modified: branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
==============================================================================
--- branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml	(original)
+++ branches/banshee/abock/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml	Sat Aug 23 01:20:06 2008
@@ -25,6 +25,7 @@
     <TrackEditorPage class="Banshee.Gui.TrackEditor.ExtraTrackDetailsPage"/>
     <!--<TrackEditorPage class="Banshee.Gui.TrackEditor.LyricsPage"/>-->
     <TrackEditorPage class="Banshee.Gui.TrackEditor.StatisticsPage"/>
+    <TrackEditorPage class="Banshee.Gui.TrackEditor.HelpPage"/>
   </Extension>
   
   <!-- Exported Extension Points -->

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	Sat Aug 23 01:20:06 2008
@@ -138,6 +138,9 @@
     <File name="Banshee.Gui.TrackEditor/FieldOptions.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gui.TrackEditor/GenreEntry.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gui.TrackEditor/StatisticsPage.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Gui.TrackEditor/EditorMode.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Gui.TrackEditor/PageType.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Gui.TrackEditor/HelpPage.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	Sat Aug 23 01:20:06 2008
@@ -48,15 +48,18 @@
 	Banshee.Gui.DragDrop/DragDropTarget.cs \
 	Banshee.Gui.DragDrop/DragDropUtilities.cs \
 	Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs \
+	Banshee.Gui.TrackEditor/EditorMode.cs \
 	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/GenreEntry.cs \
+	Banshee.Gui.TrackEditor/HelpPage.cs \
 	Banshee.Gui.TrackEditor/IEditorField.cs \
 	Banshee.Gui.TrackEditor/ITrackEditorPage.cs \
 	Banshee.Gui.TrackEditor/LyricsPage.cs \
+	Banshee.Gui.TrackEditor/PageType.cs \
 	Banshee.Gui.TrackEditor/RangeEntry.cs \
 	Banshee.Gui.TrackEditor/RatingEntry.cs \
 	Banshee.Gui.TrackEditor/SpinButtonEntry.cs \



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