[banshee] Generic EventArgs<T> (bgo#585721)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee] Generic EventArgs<T> (bgo#585721)
- Date: Tue, 17 Nov 2009 07:11:21 +0000 (UTC)
commit 0ec1cc8d057561ffdbf7228114bd9fe6f87662a0
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Tue Nov 17 18:10:33 2009 +1100
Generic EventArgs<T> (bgo#585721)
.../Banshee.Equalizer/EqualizerManager.cs | 8 +++--
.../PlaybackControllerService.cs | 12 +++---
.../PlaybackRepeatMode.cs | 13 -------
.../PlaybackShuffleMode.cs | 13 -------
src/Core/Banshee.Services/Banshee.Services.csproj | 3 +-
src/Core/Banshee.Services/Makefile.am | 1 -
.../EqualizerPresetComboBox.cs | 9 +++--
.../Banshee.Equalizer.Gui/EqualizerView.cs | 19 ++--------
.../Banshee.Gui/PlaybackRepeatActions.cs | 6 ++--
.../Banshee.Gui/PlaybackShuffleActions.cs | 6 ++--
.../Banshee.PlayQueue/HeaderWidget.cs | 37 +++-----------------
.../Banshee.PlayQueue/PlayQueueSource.cs | 5 ++-
src/Libraries/Hyena/Hyena.csproj | 2 +
.../Hyena/Hyena/EventArgs.cs} | 24 +++++-------
src/Libraries/Hyena/Makefile.am | 1 +
15 files changed, 48 insertions(+), 111 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerManager.cs b/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerManager.cs
index e9037d9..d7fd5f7 100644
--- a/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerManager.cs
+++ b/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerManager.cs
@@ -33,6 +33,7 @@ using System.Xml;
using System.Collections;
using System.Collections.Generic;
+using Hyena;
using Banshee.Base;
using Banshee.MediaEngine;
using Banshee.ServiceStack;
@@ -44,6 +45,7 @@ namespace Banshee.Equalizer
private List<EqualizerSetting> equalizers = new List<EqualizerSetting> ();
private string path;
+ public delegate void EqualizerSettingEventHandler (object o, Hyena.EventArgs<EqualizerSetting> args);
public event EqualizerSettingEventHandler EqualizerAdded;
public event EqualizerSettingEventHandler EqualizerRemoved;
public event EqualizerSettingEventHandler EqualizerChanged;
@@ -235,7 +237,7 @@ namespace Banshee.Equalizer
{
EqualizerSettingEventHandler handler = EqualizerAdded;
if (handler != null) {
- handler (this, new EqualizerSettingEventArgs (eq));
+ handler (this, new EventArgs<EqualizerSetting> (eq));
}
}
@@ -243,7 +245,7 @@ namespace Banshee.Equalizer
{
EqualizerSettingEventHandler handler = EqualizerRemoved;
if (handler != null) {
- handler (this, new EqualizerSettingEventArgs (eq));
+ handler (this, new EventArgs<EqualizerSetting> (eq));
}
}
@@ -251,7 +253,7 @@ namespace Banshee.Equalizer
{
EqualizerSettingEventHandler handler = EqualizerChanged;
if (handler != null) {
- handler (this, new EqualizerSettingEventArgs (eq));
+ handler (this, new EventArgs<EqualizerSetting> (eq));
}
}
diff --git a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
index 577c6f8..6625cde 100644
--- a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
+++ b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
@@ -80,8 +80,8 @@ namespace Banshee.PlaybackController
public event EventHandler NextSourceChanged;
public event EventHandler TrackStarted;
public event EventHandler Transition;
- public event EventHandler<ShuffleModeChangedEventArgs> ShuffleModeChanged;
- public event EventHandler<RepeatModeChangedEventArgs> RepeatModeChanged;
+ public event EventHandler<EventArgs<PlaybackShuffleMode>> ShuffleModeChanged;
+ public event EventHandler<EventArgs<PlaybackRepeatMode>> RepeatModeChanged;
public PlaybackControllerService ()
{
@@ -460,9 +460,9 @@ namespace Banshee.PlaybackController
get { return shuffle_mode; }
set {
shuffle_mode = value;
- EventHandler<ShuffleModeChangedEventArgs> handler = ShuffleModeChanged;
+ EventHandler<EventArgs<PlaybackShuffleMode>> handler = ShuffleModeChanged;
if (handler != null) {
- handler (this, new ShuffleModeChangedEventArgs (shuffle_mode));
+ handler (this, new EventArgs<PlaybackShuffleMode> (shuffle_mode));
}
}
}
@@ -471,9 +471,9 @@ namespace Banshee.PlaybackController
get { return repeat_mode; }
set {
repeat_mode = value;
- EventHandler<RepeatModeChangedEventArgs> handler = RepeatModeChanged;
+ EventHandler<EventArgs<PlaybackRepeatMode>> handler = RepeatModeChanged;
if (handler != null) {
- handler (this, new RepeatModeChangedEventArgs (repeat_mode));
+ handler (this, new EventArgs<PlaybackRepeatMode> (repeat_mode));
}
}
}
diff --git a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackRepeatMode.cs b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackRepeatMode.cs
index a512522..b48913f 100644
--- a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackRepeatMode.cs
+++ b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackRepeatMode.cs
@@ -36,17 +36,4 @@ namespace Banshee.PlaybackController
RepeatAll,
RepeatSingle
}
-
- public class RepeatModeChangedEventArgs : EventArgs
- {
- private PlaybackRepeatMode repeat_mode;
- public PlaybackRepeatMode RepeatMode {
- get { return repeat_mode; }
- }
-
- public RepeatModeChangedEventArgs (PlaybackRepeatMode repeat_mode)
- {
- this.repeat_mode = repeat_mode;
- }
- }
}
diff --git a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackShuffleMode.cs b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackShuffleMode.cs
index 8903ce4..ad965df 100644
--- a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackShuffleMode.cs
+++ b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackShuffleMode.cs
@@ -39,17 +39,4 @@ namespace Banshee.PlaybackController
Rating,
Score
}
-
- public class ShuffleModeChangedEventArgs : EventArgs
- {
- private PlaybackShuffleMode shuffle_mode;
- public PlaybackShuffleMode ShuffleMode {
- get { return shuffle_mode; }
- }
-
- public ShuffleModeChangedEventArgs (PlaybackShuffleMode shuffle_mode)
- {
- this.shuffle_mode = shuffle_mode;
- }
- }
}
diff --git a/src/Core/Banshee.Services/Banshee.Services.csproj b/src/Core/Banshee.Services/Banshee.Services.csproj
index 4179155..295a061 100644
--- a/src/Core/Banshee.Services/Banshee.Services.csproj
+++ b/src/Core/Banshee.Services/Banshee.Services.csproj
@@ -145,7 +145,6 @@
<Compile Include="Banshee.Web\Browser.cs" />
<Compile Include="Banshee.Streaming\RadioTrackInfo.cs" />
<Compile Include="Banshee.Equalizer\EqualizerSetting.cs" />
- <Compile Include="Banshee.Equalizer\EqualizerSettingEvent.cs" />
<Compile Include="Banshee.Equalizer\EqualizerManager.cs" />
<Compile Include="Banshee.MediaEngine\IEqualizer.cs" />
<Compile Include="Banshee.Sources\ErrorSource.cs" />
@@ -300,6 +299,8 @@
<Compile Include="Banshee.Collection.Database\RandomByScore.cs" />
<Compile Include="Banshee.Collection.Database\RandomBySlot.cs" />
<Compile Include="Banshee.Query\PlaybackErrorQueryValue.cs" />
+ <Compile Include="Banshee.Collection.Database\Shuffler.cs" />
+ <Compile Include="Banshee.Web\BaseHttpServer.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Banshee.Services.addin.xml" />
diff --git a/src/Core/Banshee.Services/Makefile.am b/src/Core/Banshee.Services/Makefile.am
index b58ef80..1a325f2 100644
--- a/src/Core/Banshee.Services/Makefile.am
+++ b/src/Core/Banshee.Services/Makefile.am
@@ -60,7 +60,6 @@ SOURCES = \
Banshee.Database/SortKeyUpdater.cs \
Banshee.Equalizer/EqualizerManager.cs \
Banshee.Equalizer/EqualizerSetting.cs \
- Banshee.Equalizer/EqualizerSettingEvent.cs \
Banshee.Hardware/DeviceCommand.cs \
Banshee.Hardware/HardwareManager.cs \
Banshee.Hardware/IBlockDevice.cs \
diff --git a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
index 5b19f8e..2daf799 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
@@ -28,6 +28,7 @@
using System;
using Gtk;
+using Hyena;
namespace Banshee.Equalizer.Gui
{
@@ -61,12 +62,12 @@ namespace Banshee.Equalizer.Gui
AddEqualizerSetting(eq);
}
- manager.EqualizerAdded += delegate (object o, EqualizerSettingEventArgs args) {
- AddEqualizerSetting (args.EqualizerSetting);
+ manager.EqualizerAdded += delegate (object o, EventArgs<EqualizerSetting> args) {
+ AddEqualizerSetting (args.Value);
};
- manager.EqualizerRemoved += delegate (object o, EqualizerSettingEventArgs args) {
- RemoveEqualizerSetting (args.EqualizerSetting);
+ manager.EqualizerRemoved += delegate (object o, EventArgs<EqualizerSetting> args) {
+ RemoveEqualizerSetting (args.Value);
};
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerView.cs b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerView.cs
index 0177b3f..6e7dc94 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerView.cs
@@ -34,6 +34,7 @@ using System.Collections;
using Gtk;
using Gdk;
+using Hyena;
using Banshee.ServiceStack;
using Banshee.MediaEngine;
@@ -146,7 +147,7 @@ namespace Banshee.Equalizer.Gui
}
if (AmplifierChanged != null) {
- AmplifierChanged (this, new AmplifierChangedEventArgs (scale.Value));
+ AmplifierChanged (this, new EventArgs<int> (scale.Value));
}
}
@@ -206,7 +207,7 @@ namespace Banshee.Equalizer.Gui
}
public delegate void EqualizerChangedEventHandler (object o, EqualizerChangedEventArgs args);
- public delegate void AmplifierChangedEventHandler (object o, AmplifierChangedEventArgs args);
+ public delegate void AmplifierChangedEventHandler (object o, EventArgs<int> args);
public sealed class EqualizerChangedEventArgs : EventArgs
{
@@ -227,18 +228,4 @@ namespace Banshee.Equalizer.Gui
get { return this.value; }
}
}
-
- public sealed class AmplifierChangedEventArgs : EventArgs
- {
- private int value;
-
- public AmplifierChangedEventArgs (int value)
- {
- this.value = value;
- }
-
- public int Value {
- get { return this.value; }
- }
- }
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackRepeatActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackRepeatActions.cs
index 0824425..fe3267d 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackRepeatActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackRepeatActions.cs
@@ -107,13 +107,13 @@ namespace Banshee.Gui
Active.Activate ();
}
- private void OnRepeatModeChanged (object o, RepeatModeChangedEventArgs args)
+ private void OnRepeatModeChanged (object o, EventArgs<PlaybackRepeatMode> args)
{
- if (active_action.Value != (int)args.RepeatMode) {
+ if (active_action.Value != (int)args.Value) {
// This happens only when changing the mode using DBus.
// In this case we need to locate the action by its value.
foreach (RadioAction action in this) {
- if (action.Value == (int)args.RepeatMode) {
+ if (action.Value == (int)args.Value) {
active_action = action;
break;
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackShuffleActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackShuffleActions.cs
index a36140f..7d0ddd4 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackShuffleActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/PlaybackShuffleActions.cs
@@ -128,13 +128,13 @@ namespace Banshee.Gui
Active.Activate ();
}
- private void OnShuffleModeChanged (object o, ShuffleModeChangedEventArgs args)
+ private void OnShuffleModeChanged (object o, EventArgs<PlaybackShuffleMode> args)
{
- if (active_action.Value != (int)args.ShuffleMode) {
+ if (active_action.Value != (int)args.Value) {
// This happens only when changing the mode using DBus.
// In this case we need to locate the action by its value.
foreach (RadioAction action in this) {
- if (action.Value == (int)args.ShuffleMode) {
+ if (action.Value == (int)args.Value) {
active_action = action;
break;
}
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
index 1f0982c..65db812 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
@@ -32,6 +32,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
+using Hyena;
using Banshee.PlaybackController;
using Banshee.Sources;
@@ -39,8 +40,8 @@ namespace Banshee.PlayQueue
{
public class HeaderWidget : HBox
{
- public event EventHandler<ModeChangedEventArgs> ModeChanged;
- public event EventHandler<SourceChangedEventArgs> SourceChanged;
+ public event EventHandler<EventArgs<PlaybackShuffleMode>> ModeChanged;
+ public event EventHandler<EventArgs<DatabaseSource>> SourceChanged;
private readonly List<Widget> sensitive_widgets = new List<Widget> ();
private readonly Dictionary<string, PlaybackShuffleMode> modes = new Dictionary<string, PlaybackShuffleMode> {
@@ -66,7 +67,7 @@ namespace Banshee.PlayQueue
}
var handler = ModeChanged;
if (handler != null) {
- handler (this, new ModeChangedEventArgs (value));
+ handler (this, new EventArgs<PlaybackShuffleMode> (value));
}
};
@@ -78,7 +79,7 @@ namespace Banshee.PlayQueue
source_combo_box.Changed += delegate {
var handler = SourceChanged;
if (handler != null) {
- handler (this, new SourceChangedEventArgs (source_combo_box.Source));
+ handler (this, new EventArgs<DatabaseSource> (source_combo_box.Source));
}
};
@@ -97,32 +98,4 @@ namespace Banshee.PlayQueue
});
}
}
-
- public sealed class ModeChangedEventArgs : EventArgs
- {
- private PlaybackShuffleMode value;
-
- public ModeChangedEventArgs (PlaybackShuffleMode value)
- {
- this.value = value;
- }
-
- public PlaybackShuffleMode Value {
- get { return this.value; }
- }
- }
-
- public sealed class SourceChangedEventArgs : EventArgs
- {
- private DatabaseSource value;
-
- public SourceChangedEventArgs (DatabaseSource value)
- {
- this.value = value;
- }
-
- public DatabaseSource Value {
- get { return this.value; }
- }
- }
}
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
index 25b1687..85013fe 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
@@ -34,6 +34,7 @@ using System.Linq;
using Mono.Unix;
+using Hyena;
using Hyena.Collections;
using Hyena.Data.Sqlite;
@@ -139,14 +140,14 @@ namespace Banshee.PlayQueue
public HeaderWidget CreateHeaderWidget ()
{
var header_widget = new HeaderWidget (populate_mode, populate_from_name);
- header_widget.ModeChanged += delegate (object sender, ModeChangedEventArgs e) {
+ header_widget.ModeChanged += delegate (object sender, EventArgs<PlaybackShuffleMode> e) {
populate_mode = e.Value;
PopulateModeSchema.Set ((int) e.Value);
UpdatePlayQueue ();
OnUpdated ();
};
- header_widget.SourceChanged += delegate (object sender, SourceChangedEventArgs e) {
+ header_widget.SourceChanged += delegate (object sender, EventArgs<DatabaseSource> e) {
populate_from = e.Value;
if (populate_from == null) {
populate_from_name = String.Empty;
diff --git a/src/Libraries/Hyena/Hyena.csproj b/src/Libraries/Hyena/Hyena.csproj
index 675a713..254954e 100644
--- a/src/Libraries/Hyena/Hyena.csproj
+++ b/src/Libraries/Hyena/Hyena.csproj
@@ -154,6 +154,8 @@
<Compile Include="Hyena.Jobs\SimpleAsyncJob.cs" />
<Compile Include="Hyena.Jobs\Tests\SchedulerTests.cs" />
<Compile Include="Hyena.Query\EnumQueryValue.cs" />
+ <Compile Include="Hyena.Data\MemoryListModel.cs" />
+ <Compile Include="Hyena\EventArgs.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Posix">
diff --git a/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerSettingEvent.cs b/src/Libraries/Hyena/Hyena/EventArgs.cs
similarity index 69%
rename from src/Core/Banshee.Services/Banshee.Equalizer/EqualizerSettingEvent.cs
rename to src/Libraries/Hyena/Hyena/EventArgs.cs
index b33ec61..7603a9c 100644
--- a/src/Core/Banshee.Services/Banshee.Equalizer/EqualizerSettingEvent.cs
+++ b/src/Libraries/Hyena/Hyena/EventArgs.cs
@@ -1,10 +1,10 @@
//
-// EqualizerSettingEvent.cs
+// EventArgs.cs
//
// Author:
-// Aaron Bockover <abockover novell com>
+// Alexander Kojevnikov <alexander kojevnikov com>
//
-// Copyright (C) 2006-2007 Novell, Inc.
+// Copyright (C) 2009 Alexander Kojevnikov
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,23 +26,19 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-
-namespace Banshee.Equalizer
+namespace Hyena
{
- public delegate void EqualizerSettingEventHandler (object o, EqualizerSettingEventArgs args);
-
- public class EqualizerSettingEventArgs : EventArgs
+ public class EventArgs<T> : System.EventArgs
{
- private EqualizerSetting eq;
+ private readonly T value;
- public EqualizerSettingEventArgs (EqualizerSetting eq)
+ public EventArgs (T value)
{
- this.eq = eq;
+ this.value = value;
}
- public EqualizerSetting EqualizerSetting {
- get { return eq; }
+ public T Value {
+ get { return value; }
}
}
}
diff --git a/src/Libraries/Hyena/Makefile.am b/src/Libraries/Hyena/Makefile.am
index 061f239..466642d 100644
--- a/src/Libraries/Hyena/Makefile.am
+++ b/src/Libraries/Hyena/Makefile.am
@@ -111,6 +111,7 @@ SOURCES = \
Hyena/CryptoUtil.cs \
Hyena/DateTimeUtil.cs \
Hyena/Delegates.cs \
+ Hyena/EventArgs.cs \
Hyena/IUndoAction.cs \
Hyena/Log.cs \
Hyena/PlatformUtil.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]