banshee r4561 - in trunk/banshee: . src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor src/Libraries/Hyena.Gui/Hyena.Gui
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4561 - in trunk/banshee: . src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor src/Libraries/Hyena.Gui/Hyena.Gui
- Date: Wed, 17 Sep 2008 22:31:09 +0000 (UTC)
Author: abock
Date: Wed Sep 17 22:31:09 2008
New Revision: 4561
URL: http://svn.gnome.org/viewvc/banshee?rev=4561&view=rev
Log:
2008-09-17 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs:
Iterate over all ICanUndo's and disconnect/connect the adapters when
loading new tracks; factored out the ForeachSyncButton methods into
a generic ForeachWidget method taking a generic closure
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorEntryUndoAdapter.cs:
Implement a one-to-many adapter for entry undo adapters; this allows entry
undo adapters to be adapted on a per-track basis to each editor field
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ICanUndo.cs:
Interface for fields that support undo/redo
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs:
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs:
* src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs:
Implement ICanUndo by way of EditorEntryUndoAdapter
* src/Libraries/Hyena.Gui/Hyena.Gui/EntryUndoAdapter.cs: Added
Connect and Disconnect methods so multiple adapters can listen on the
same widget
Added:
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorEntryUndoAdapter.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ICanUndo.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/EntryUndoAdapter.cs
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorEntryUndoAdapter.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorEntryUndoAdapter.cs Wed Sep 17 22:31:09 2008
@@ -0,0 +1,65 @@
+//
+// EditorEntryUndoAdapter.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 System.Collections.Generic;
+
+using Gtk;
+using Hyena.Gui;
+
+namespace Banshee.Gui.TrackEditor
+{
+ public class EditorEntryUndoAdapter
+ {
+ private Dictionary<EditorTrackInfo, EntryUndoAdapter> undo_adapters
+ = new Dictionary<EditorTrackInfo, EntryUndoAdapter> ();
+ private EntryUndoAdapter current_adapter;
+
+ public void DisconnectUndo ()
+ {
+ if (current_adapter != null) {
+ current_adapter.Disconnect ();
+ current_adapter = null;
+ }
+ }
+
+ public void ConnectUndo (Entry entry, EditorTrackInfo track)
+ {
+ DisconnectUndo ();
+
+ if (undo_adapters.ContainsKey (track)) {
+ current_adapter = undo_adapters[track];
+ } else {
+ current_adapter = new EntryUndoAdapter (entry);
+ undo_adapters.Add (track, current_adapter);
+ }
+
+ current_adapter.Connect ();
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs Wed Sep 17 22:31:09 2008
@@ -29,14 +29,17 @@
using System;
using Gtk;
+using Hyena.Gui;
+
using Banshee.ServiceStack;
using Banshee.Collection.Database;
namespace Banshee.Gui.TrackEditor
{
- public class GenreEntry : ComboBoxEntry
+ public class GenreEntry : ComboBoxEntry, ICanUndo
{
private ListStore genre_model;
+ private EditorEntryUndoAdapter undo_adapter = new EditorEntryUndoAdapter ();
public GenreEntry ()
{
@@ -52,6 +55,16 @@
}
}
+ public void DisconnectUndo ()
+ {
+ undo_adapter.DisconnectUndo ();
+ }
+
+ public void ConnectUndo (EditorTrackInfo track)
+ {
+ undo_adapter.ConnectUndo (Entry, track);
+ }
+
public string Value {
get { return Entry.Text; }
set { Entry.Text = value ?? String.Empty; }
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ICanUndo.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/ICanUndo.cs Wed Sep 17 22:31:09 2008
@@ -0,0 +1,38 @@
+//
+// ICanUndo.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 interface ICanUndo
+ {
+ void DisconnectUndo ();
+ void ConnectUndo (EditorTrackInfo track);
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs Wed Sep 17 22:31:09 2008
@@ -31,8 +31,20 @@
namespace Banshee.Gui.TrackEditor
{
- public class TextEntry : Entry, IEditorField
+ public class TextEntry : Entry, IEditorField, ICanUndo
{
+ private EditorEntryUndoAdapter undo_adapter = new EditorEntryUndoAdapter ();
+
+ public void DisconnectUndo ()
+ {
+ undo_adapter.DisconnectUndo ();
+ }
+
+ public void ConnectUndo (EditorTrackInfo track)
+ {
+ undo_adapter.ConnectUndo (this, track);
+ }
+
public new string Text {
get { return base.Text; }
set { base.Text = value ?? String.Empty; }
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TitleEntry.cs Wed Sep 17 22:31:09 2008
@@ -31,7 +31,7 @@
namespace Banshee.Gui.TrackEditor
{
- public class TitleEntry : HBox, IEditorField
+ public class TitleEntry : HBox, IEditorField, ICanUndo
{
public event EventHandler Changed;
@@ -71,6 +71,16 @@
PackStart (forward_button, false, false, 0);
}
}
+
+ public void ConnectUndo (EditorTrackInfo track)
+ {
+ entry.ConnectUndo (track);
+ }
+
+ public void DisconnectUndo ()
+ {
+ entry.DisconnectUndo ();
+ }
private void OnChanged (object o, EventArgs args)
{
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs Wed Sep 17 22:31:09 2008
@@ -235,7 +235,7 @@
if (TrackCount > 1) {
sync_all_button = new PulsingButton ();
sync_all_button.FocusInEvent += delegate {
- ForeachSyncButton (delegate (SyncButton button) {
+ ForeachWidget<SyncButton> (delegate (SyncButton button) {
button.StartPulsing ();
});
};
@@ -245,7 +245,7 @@
return;
}
- ForeachSyncButton (delegate (SyncButton button) {
+ ForeachWidget<SyncButton> (delegate (SyncButton button) {
button.StopPulsing ();
});
};
@@ -255,7 +255,7 @@
return;
}
- ForeachSyncButton (delegate (SyncButton button) {
+ ForeachWidget<SyncButton> (delegate (SyncButton button) {
if (sync_all_button.State == StateType.Prelight) {
button.StartPulsing ();
} else {
@@ -294,29 +294,29 @@
button_box.ShowAll ();
}
- private delegate void SyncButtonAction (SyncButton button);
+ private delegate void WidgetAction<T> (T widget) where T : class;
- private void ForeachSyncButton (SyncButtonAction action)
+ private void ForeachWidget<T> (WidgetAction<T> action) where T : class
{
for (int i = 0; i < notebook.NPages; i++) {
- ForeachSyncButton (notebook.GetNthPage (i) as Container, action);
+ ForeachWidget (notebook.GetNthPage (i) as Container, action);
}
}
- private void ForeachSyncButton (Container container, SyncButtonAction action)
+ private void ForeachWidget<T> (Container container, WidgetAction<T> action) where T : class
{
if (container == null) {
return;
}
foreach (Widget child in container.Children) {
- SyncButton sync = child as SyncButton;
- if (sync != null) {
- action (sync);
+ T widget = child as T;
+ if (widget != null) {
+ action (widget);
} else {
Container child_container = child as Container;
if (child_container != null) {
- ForeachSyncButton (child_container, action);
+ ForeachWidget<T> (child_container, action);
}
}
}
@@ -324,7 +324,7 @@
private void InvokeFieldSync ()
{
- ForeachSyncButton (delegate (SyncButton button) {
+ ForeachWidget<SyncButton> (delegate (SyncButton button) {
button.Click ();
});
}
@@ -398,10 +398,20 @@
header_image_frame.ShadowType = ShadowType.In;
}
+ // Disconnect all the undo adapters
+ ForeachWidget<ICanUndo> (delegate (ICanUndo undoable) {
+ undoable.Disconnect ();
+ });
+
foreach (ITrackEditorPage page in pages) {
page.LoadTrack (editor_track);
}
+ // Connect all the undo adapters
+ ForeachWidget<ICanUndo> (delegate (ICanUndo undoable) {
+ undoable.ConnectUndo (editor_track);
+ });
+
// Update Navigation
if (TrackCount > 0 && nav_backward_button != null && nav_forward_button != null) {
nav_backward_button.Sensitive = CanGoBackward;
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj Wed Sep 17 22:31:09 2008
@@ -211,6 +211,8 @@
<Compile Include="Banshee.Gui.TrackEditor\SyncButton.cs" />
<Compile Include="Banshee.Preferences.Gui\DescriptionLabel.cs" />
<Compile Include="Banshee.Gui.Dialogs\DefaultApplicationHelperDialog.cs" />
+ <Compile Include="Banshee.Gui.TrackEditor\ICanUndo.cs" />
+ <Compile Include="Banshee.Gui.TrackEditor\EditorEntryUndoAdapter.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am Wed Sep 17 22:31:09 2008
@@ -50,6 +50,7 @@
Banshee.Gui.DragDrop/DragDropTarget.cs \
Banshee.Gui.DragDrop/DragDropUtilities.cs \
Banshee.Gui.TrackEditor/BasicTrackDetailsPage.cs \
+ Banshee.Gui.TrackEditor/EditorEntryUndoAdapter.cs \
Banshee.Gui.TrackEditor/EditorMode.cs \
Banshee.Gui.TrackEditor/EditorTrackInfo.cs \
Banshee.Gui.TrackEditor/EditorUtilities.cs \
@@ -58,6 +59,7 @@
Banshee.Gui.TrackEditor/FieldPage.cs \
Banshee.Gui.TrackEditor/GenreEntry.cs \
Banshee.Gui.TrackEditor/HelpPage.cs \
+ Banshee.Gui.TrackEditor/ICanUndo.cs \
Banshee.Gui.TrackEditor/IEditorField.cs \
Banshee.Gui.TrackEditor/ITrackEditorPage.cs \
Banshee.Gui.TrackEditor/LyricsPage.cs \
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/EntryUndoAdapter.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/EntryUndoAdapter.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/EntryUndoAdapter.cs Wed Sep 17 22:31:09 2008
@@ -42,12 +42,23 @@
public EntryUndoAdapter(Entry entry)
{
this.entry = entry;
-
+ }
+
+ public void Connect ()
+ {
entry.KeyPressEvent += OnKeyPressEvent;
entry.TextDeleted += OnTextDeleted;
entry.TextInserted += OnTextInserted;
entry.PopulatePopup += OnPopulatePopup;
}
+
+ public void Disconnect ()
+ {
+ entry.KeyPressEvent -= OnKeyPressEvent;
+ entry.TextDeleted -= OnTextDeleted;
+ entry.TextInserted -= OnTextInserted;
+ entry.PopulatePopup -= OnPopulatePopup;
+ }
private void OnKeyPressEvent(object o, KeyPressEventArgs args)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]