[Banshee-List] Deriving from PlaylistModel
- From: LCID Fire <lcid-fire gmx net>
- To: banshee-list gnome org
- Subject: [Banshee-List] Deriving from PlaylistModel
- Date: Sat, 01 Sep 2007 19:50:14 +0200
Hi.
Today I hit rock bottom on my plugin. I need to modify PlaylistModel -
which currently is not possible. So I wrote the following patch so
people can change the PlaylistModel behaviour.
Would be nice if someone could apply it.
Regards
Andreas
--- /tmp/tmp-PlaylistModel.cs-BASE-u9QlvU.cs 2007-09-01
19:41:06.000000000 +0200
+++ /home/andreas/Projects/banshee/src/Core/Banshee/PlaylistModel.cs
2007-09-01 19:33:07.000000000 +0200
@@ -67,25 +67,30 @@
public PlaylistModel() : base(typeof(TrackInfo))
{
- SourceManager.ActiveSourceChanged +=
delegate(SourceEventArgs args) {
- ReloadSource();
- };
-
- PlayerEngineCore.EventChanged += delegate(object o,
PlayerEngineEventArgs args) {
- switch(args.Event) {
- case PlayerEngineEvent.StartOfStream:
- playingIter = TreeIter.Zero;
- return;
- }
- };
+ RegisterEvents();
}
- public void AddTrack(TrackInfo ti)
+ protected virtual RegisterEvents()
+ {
+ SourceManager.ActiveSourceChanged += delegate(SourceEventArgs args) {
+ ReloadSource();
+ };
+
+ PlayerEngineCore.EventChanged += delegate(object o,
PlayerEngineEventArgs args) {
+ switch(args.Event) {
+ case PlayerEngineEvent.StartOfStream:
+ playingIter = TreeIter.Zero;
+ return;
+ }
+ };
+ }
+
+ public virtual void AddTrack(TrackInfo ti)
{
AddTrack(ti, true);
}
- public void AddTrack(TrackInfo ti, bool raiseUpdate)
+ public virtual void AddTrack(TrackInfo ti, bool raiseUpdate)
{
if(ti == null)
return;
@@ -98,7 +103,7 @@
}
}
- public void ReloadSource()
+ public virtual void ReloadSource()
{
ClearModel();
@@ -117,7 +122,7 @@
// --- Helper Methods ---
- public TrackInfo IterTrackInfo(TreeIter iter)
+ public virtual TrackInfo IterTrackInfo(TreeIter iter)
{
object o = GetValue(iter, 0);
if(o != null) {
@@ -127,7 +132,7 @@
return null;
}
- public TrackInfo PathTrackInfo(TreePath path)
+ public virtual TrackInfo PathTrackInfo(TreePath path)
{
TreeIter iter;
@@ -139,14 +144,14 @@
private bool can_save_sort_id = true;
- public void ClearSortOrder()
+ public virtual void ClearSortOrder()
{
can_save_sort_id = false;
SetSortColumnId(-1, SortType.Ascending);
can_save_sort_id = true;
}
- public void RestoreSortOrder()
+ public virtual void RestoreSortOrder()
{
SetSortColumnId(SourceManager.ActiveSource.SortColumn,
SourceManager.ActiveSource.SortType);
}
@@ -168,7 +173,7 @@
// --- Playback Methods ---
- public void PlayPath(TreePath path)
+ public virtual void PlayPath(TreePath path)
{
TrackInfo ti = PathTrackInfo(path);
if(ti == null)
@@ -178,7 +183,7 @@
GetIter(out playingIter, path);
}
- public void PlayIter(TreeIter iter)
+ public virtual void PlayIter(TreeIter iter)
{
TrackInfo ti = IterTrackInfo(iter);
if(ti == null)
@@ -195,22 +200,22 @@
// --- IPlaybackModel
- public void PlayPause()
+ public virtual void PlayPause()
{
}
- public void Advance()
+ public virtual void Advance()
{
ChangeDirection(true);
}
- public void Regress()
+ public virtual void Regress()
{
ChangeDirection(false);
}
- public void Continue()
+ public virtual void Continue()
{
Advance();
}
@@ -324,7 +329,7 @@
}
}
- public int Count()
+ public virtual int Count()
{
return IterNChildren();
}
@@ -382,7 +387,7 @@
return IterNthChild(out iter, randIndex);
}
- public void ClearModel()
+ public virtual void ClearModel()
{
totalDuration = new TimeSpan(0);
playingIter = TreeIter.Zero;
@@ -393,7 +398,7 @@
}
}
- public void RemoveTrack(ref TreeIter iter, TrackInfo track)
+ public virtual void RemoveTrack(ref TreeIter iter, TrackInfo track)
{
TrackInfo ti = track;
if(ti == null) {
@@ -411,7 +416,7 @@
RaiseUpdated(this, new EventArgs());
}
- public void RemoveTrack(TrackInfo track)
+ public virtual void RemoveTrack(TrackInfo track)
{
TreeIter iter = track.TreeIter;
@@ -422,7 +427,7 @@
}
}
- public int GetIterIndex(TreeIter iter)
+ public virtual int GetIterIndex(TreeIter iter)
{
TreePath path = GetPath(iter);
return path == null ? - 1 : path.Indices[0];
@@ -437,14 +442,14 @@
handler(o, args);
}
- public TimeSpan TotalDuration
+ public virtual TimeSpan TotalDuration
{
get {
return totalDuration;
}
}
- public TreePath PlayingPath
+ public virtual TreePath PlayingPath
{
get {
try {
@@ -456,7 +461,7 @@
}
}
- public TreeIter PlayingIter {
+ public virtual TreeIter PlayingIter {
set {
playingIter = value;
}
@@ -466,7 +471,7 @@
}
}
- public RepeatMode Repeat {
+ public virtual RepeatMode Repeat {
set {
repeat = value;
}
@@ -476,7 +481,7 @@
}
}
- public bool Shuffle {
+ public virtual bool Shuffle {
set {
shuffle = value;
}
@@ -486,7 +491,7 @@
}
}
- public TrackInfo FirstTrack {
+ public virtual TrackInfo FirstTrack {
get {
TreeIter iter = TreeIter.Zero;
if(GetIterFirst(out iter) && !iter.Equals(TreeIter.Zero))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]