summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Oesterholt <hans@oesterholt.net>2013-01-13 10:06:36 +0100
committerHans Oesterholt <hans@oesterholt.net>2013-01-13 10:06:36 +0100
commitf0a346e9f2ebb3587b64e11cb7e88997b6d2c6fd (patch)
tree036c9c076791149703fb3ca6d2f6d6f1e433dc66
parent7f19b3743c8785bf3434e720c1343dfc394b55b4 (diff)
Initial import of CueSheets.
-rw-r--r--src/CueSheets/Banshee.CueSheets/CS_AlbumInfo.cs54
-rw-r--r--src/CueSheets/Banshee.CueSheets/CS_AlbumModel.cs117
-rw-r--r--src/CueSheets/Banshee.CueSheets/CS_ArtistInfo.cs52
-rw-r--r--src/CueSheets/Banshee.CueSheets/CS_ArtistModel.cs105
-rw-r--r--src/CueSheets/Banshee.CueSheets/CS_GenreModel.cs94
-rw-r--r--src/CueSheets/Banshee.CueSheets/CueSheet.cs126
-rw-r--r--src/CueSheets/Banshee.CueSheets/CueSheetEntry.cs8
-rw-r--r--src/CueSheets/Banshee.CueSheets/CueSheetsPrefs.cs99
-rw-r--r--src/CueSheets/Banshee.CueSheets/CueSheetsSource.cs560
-rw-r--r--src/CueSheets/Banshee.CueSheets/GenreInfo.cs50
-rw-r--r--src/CueSheets/Banshee.CueSheets/GenreListView.cs44
-rw-r--r--src/CueSheets/Banshee.CueSheets/Loosely.cs57
-rw-r--r--src/CueSheets/Makefile.am11
13 files changed, 1106 insertions, 271 deletions
diff --git a/src/CueSheets/Banshee.CueSheets/CS_AlbumInfo.cs b/src/CueSheets/Banshee.CueSheets/CS_AlbumInfo.cs
new file mode 100644
index 0000000..add1393
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CS_AlbumInfo.cs
@@ -0,0 +1,54 @@
+//
+// CS_AlbumInfo.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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 Banshee.Collection;
+
+namespace Banshee.CueSheets
+{
+ public class CS_AlbumInfo : AlbumInfo
+ {
+ private CueSheet _sheet;
+
+ public CS_AlbumInfo (CueSheet s) {
+ _sheet=s;
+ if (s==null) {
+ base.ArtistName="none";
+ base.Title="none";
+ } else {
+ base.ArtistName=s.performer ();
+ base.Title=s.title ();
+ base.ArtworkId=s.getArtId ();
+ }
+ }
+
+ public CueSheet getSheet() {
+ return _sheet;
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CS_AlbumModel.cs b/src/CueSheets/Banshee.CueSheets/CS_AlbumModel.cs
new file mode 100644
index 0000000..effb556
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CS_AlbumModel.cs
@@ -0,0 +1,117 @@
+//
+// CS_AlbumModel.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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 Banshee.Collection;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+
+namespace Banshee.CueSheets
+{
+ public class CS_AlbumModel : BansheeListModel<AlbumInfo>
+ {
+ private CueSheetsSource MySource;
+ private List<CS_AlbumInfo> _filteredList;
+ private GenreInfo _genre;
+ private ArtistInfo _artist;
+
+ public CS_AlbumModel (CueSheetsSource s) {
+ MySource=s;
+ _filteredList=new List<CS_AlbumInfo>();
+ Selection=new Hyena.Collections.Selection();
+ _genre=null;
+ Reload ();
+ }
+
+ public override void Clear () {
+ Console.WriteLine ("clear");
+ }
+
+ public override void Reload () {
+ _filteredList.Clear ();
+ List<CueSheet> s=MySource.getSheets ();
+ int i,N;
+ string artist="";
+ if (_artist!=null) {
+ artist=Loosely.prepare(_artist.Name);
+ }
+ for(i=0,N=s.Count;i<N;i++) {
+ bool do_add=true;
+ if (_genre!=null) {
+ if (s[i].genre ()!=_genre.Genre) { do_add=false; }
+ }
+ if (_artist!=null) {
+ if (!Loosely.eqp (artist,s[i].performer ())) { do_add=false; }
+ }
+ if (do_add) {
+ _filteredList.Add (new CS_AlbumInfo(s[i]));
+ }
+
+ }
+ base.RaiseReloaded ();
+ }
+
+ public void filterGenre(GenreInfo g) {
+ if (g==null) {
+ _genre=null;
+ Reload ();
+ } else if (_genre==null) {
+ _genre=g;
+ _artist=null;
+ Reload ();
+ } else {
+ if (_genre.Genre==g.Genre) {
+ // do nothing
+ } else {
+ _genre=g;
+ _artist=null;
+ Reload ();
+ }
+ }
+ }
+
+ public void filterArtist(ArtistInfo a) {
+ _artist=a;
+ Reload();
+ }
+
+ public override int Count {
+ get {
+ //Console.WriteLine ("albumcount="+_filteredList.Count);
+ return _filteredList.Count;
+ }
+ }
+
+ public override AlbumInfo this[int index] {
+ get {
+ if (index>=Count) { return new CS_AlbumInfo(null); }
+ return _filteredList[index];
+ }
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CS_ArtistInfo.cs b/src/CueSheets/Banshee.CueSheets/CS_ArtistInfo.cs
new file mode 100644
index 0000000..5621e54
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CS_ArtistInfo.cs
@@ -0,0 +1,52 @@
+//
+// CS_ArtistInfo.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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 Banshee.Collection;
+
+namespace Banshee.CueSheets
+{
+ public class CS_ArtistInfo : ArtistInfo
+ {
+
+ private CueSheet _sheet;
+
+ public CS_ArtistInfo (CueSheet s) {
+ _sheet=s;
+ if (s!=null) {
+ base.Name=s.performer ();
+ } else {
+ base.Name="All Artists";
+ }
+ }
+
+ public CueSheet getCueSheet() {
+ return _sheet;
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CS_ArtistModel.cs b/src/CueSheets/Banshee.CueSheets/CS_ArtistModel.cs
new file mode 100644
index 0000000..51639fa
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CS_ArtistModel.cs
@@ -0,0 +1,105 @@
+//
+// CS_ArtistModelcs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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 Banshee.Collection;
+using System.Collections.Generic;
+
+namespace Banshee.CueSheets
+{
+ public class CS_ArtistModel : BansheeListModel<ArtistInfo>
+ {
+ private CueSheetsSource MySource;
+ private List<ArtistInfo> _artists;
+ private ArtistInfo _nullArtist;
+ private GenreInfo _genre;
+
+ public CS_ArtistModel (CueSheetsSource s) {
+ MySource=s;
+ _nullArtist=new CS_ArtistInfo (null);
+ _artists=new List<ArtistInfo>();
+ Selection=new Hyena.Collections.Selection();
+ }
+
+ public override void Clear () {
+ Console.WriteLine ("clear");
+ }
+
+ private bool exists(string artist) {
+ int i,N;
+ for(i=0,N=_artists.Count;i<N && !Loosely.eq (_artists[i].Name,artist);i++);
+ return i<N;
+ }
+
+ public override void Reload () {
+ HashSet<string> added=new HashSet<String>();
+ _artists.Clear ();
+ List<CueSheet> s=MySource.getSheets ();
+ _artists.Add(_nullArtist);
+ for(int i=0;i<s.Count;i++) {
+ string perf=Loosely.prepare (s[i].performer ());
+ if (!added.Contains (perf)) {
+ bool do_add=true;
+ if (_genre!=null) {
+ if (s[i].genre ()!=_genre.Genre) { do_add=false; }
+ }
+ if (do_add) {
+ ArtistInfo a=new CS_ArtistInfo (s[i]);
+ _artists.Add (a);
+ added.Add (perf);
+ }
+ }
+ }
+ base.RaiseReloaded ();
+ }
+
+ public bool isNullArtist(ArtistInfo a) {
+ CS_ArtistInfo aa=(CS_ArtistInfo) a;
+ return aa.getCueSheet ()==null;
+ }
+
+ public override int Count {
+ get {
+ return _artists.Count;
+ }
+ }
+
+ public void filterGenre(GenreInfo g) {
+ _genre=g;
+ Reload ();
+ }
+
+ public override ArtistInfo this[int index] {
+ get {
+ return _artists[index];
+ }
+ }
+
+
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CS_GenreModel.cs b/src/CueSheets/Banshee.CueSheets/CS_GenreModel.cs
new file mode 100644
index 0000000..4b48c8a
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CS_GenreModel.cs
@@ -0,0 +1,94 @@
+//
+// CS_GenreModel.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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 Banshee.Collection;
+using System.Collections.Generic;
+using Banshee.Collection.Database;
+
+namespace Banshee.CueSheets
+{
+ public class CS_GenreModel : BansheeListModel<GenreInfo>
+ {
+ private CueSheetsSource MySource;
+ private List<GenreInfo> _genres;
+ private GenreInfo _nullGenre;
+
+ public CS_GenreModel (CueSheetsSource s) {
+ MySource=s;
+ _nullGenre=new GenreInfo("All Genres");
+ _genres=new List<GenreInfo>();
+ Selection=new Hyena.Collections.Selection();
+ }
+
+ public override void Clear () {
+ Console.WriteLine ("clear");
+ }
+
+ private bool exists(string s) {
+ int i,N;
+ for(i=0,N=_genres.Count;i<N && !Loosely.eq (_genres[i].Genre,s);i++);
+ return i<N;
+ }
+
+ public override void Reload () {
+ HashSet<string> added=new HashSet<string>();
+ List<CueSheet> s=MySource.getSheets ();
+ //Console.WriteLine ("count="+s.Count);
+ _genres.Clear ();
+ _genres.Add (_nullGenre);
+ for(int i=0;i<s.Count;i++) {
+ //Console.Write(" "+i);
+ string gen=Loosely.prepare (s[i].genre ());
+ if (!added.Contains (gen)) {
+ //Console.WriteLine ("genre:"+s[i].genre ());
+ _genres.Add (new GenreInfo(s[i].genre ()));
+ added.Add (gen);
+ }
+ }
+ //Console.WriteLine ();
+ base.RaiseReloaded ();
+ }
+
+ public bool isNullGenre(GenreInfo g) {
+ return g==_nullGenre;
+ }
+
+ public override int Count {
+ get {
+ return _genres.Count;
+ }
+ }
+
+ public override GenreInfo this[int index] {
+ get {
+ return _genres[index];
+ }
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CueSheet.cs b/src/CueSheets/Banshee.CueSheets/CueSheet.cs
index 990c5a9..b8fd62f 100644
--- a/src/CueSheets/Banshee.CueSheets/CueSheet.cs
+++ b/src/CueSheets/Banshee.CueSheets/CueSheet.cs
@@ -2,7 +2,7 @@
// CueSheet.cs
//
// Authors:
-// Cool Extension Author <hans@oesterholt.net>
+// Hans Oesterholt <hans@oesterholt.net>
//
// Copyright (C) 2013 Hans Oesterholt
//
@@ -43,6 +43,17 @@ namespace Banshee.CueSheets
private string _performer;
private CueSheetEntry [] _tracks;
private string _cuefile;
+ private string _directory;
+ private string _basedir;
+
+ public string genre() {
+ int n=_basedir.Length;
+ string d=_directory.Substring (n);
+ d=Regex.Replace (d,"^[/]","");
+ String r=Regex.Replace (d,"[/].*$","");
+ //Console.WriteLine ("n="+n+", d="+d+", r="+r);
+ return r;
+ }
private void append(CueSheetEntry e) {
if (_tracks==null) {
@@ -97,36 +108,48 @@ namespace Banshee.CueSheets
return k-1;
}
- private string getArtId() {
+ public string getArtId() {
string aaid=CoverArtSpec.CreateArtistAlbumId (_performer,_title);
if (!CoverArtSpec.CoverExists (aaid)) {
if (File.Exists (_img_full_path)) {
string path=CoverArtSpec.GetPathForNewFile (aaid,_img_full_path);
- File.Copy (_img_full_path,path);
- Console.WriteLine ("coverartpath="+path);
+ if (!File.Exists (path)) {
+ File.Copy (_img_full_path,path);
+ }
+ //Console.WriteLine ("coverartpath="+path);
}
}
- string path1=CoverArtSpec.GetPath (aaid);
- Console.WriteLine ("coverartpath1="+path1);
+ //string path1=CoverArtSpec.GetPath (aaid);
+ //Console.WriteLine ("coverartpath1="+path1);
return aaid;
}
- public CueSheet (string filename,string directory) {
- _cuefile=filename;
+ public bool eq(string s,string begin) {
+ if (begin.Length>s.Length) { return false; }
+ else {
+ if (s.Substring(0,begin.Length).ToLower ()==begin.ToLower ()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public override string ToString() {
+ return "Performer: "+this.performer ()+", Title: "+this.title ()+"\ncuefile: "+this.cueFile()+"\nwave: "+this.musicFileName();
+ }
+
+ public void iLoad() {
Boolean _in_tracks=false;
- _image_file_name="";
- _img_full_path="";
- _music_file_name="";
- _title="";
- _performer="";
- _tracks=null;
-
string e_perf="";
string e_title="";
double e_offset=-1.0;
string aaid="";
int nr=0;
+ string filename=_cuefile;
+ string directory=_directory;
+
using (System.IO.StreamReader sr = System.IO.File.OpenText(filename)) {
string line = "";
while ((line = sr.ReadLine()) != null) {
@@ -134,26 +157,26 @@ namespace Banshee.CueSheets
if (line!="") {
//Console.WriteLine ("it="+_in_tracks+", "+line);
if (!_in_tracks) {
- if (line.Substring (0,9).ToLower()=="performer") {
+ if (eq(line,"performer")) {
string p=line.Substring (9).Trim ();
p=Regex.Replace (p,"[\"]","");
_performer=p;
- } else if (line.Substring (0,5).ToLower ()=="title") {
+ } else if (eq(line,"title")) {
_title=Regex.Replace (line.Substring (5).Trim (),"[\"]","");
- } else if (line.Substring (0,4).ToLower ()=="file") {
+ } else if (eq(line,"file")) {
_music_file_name=line.Substring (4).Trim ();
Match m=Regex.Match (_music_file_name,"([\"][^\"]+[\"])");
- Console.WriteLine ("match="+m);
+ //Console.WriteLine ("match="+m);
_music_file_name=m.ToString ();
- Console.WriteLine ("result="+_music_file_name);
+ //Console.WriteLine ("result="+_music_file_name);
_music_file_name=Regex.Replace (_music_file_name,"[\"]","").Trim ();
_music_file_name=directory+"/"+_music_file_name;
- Console.WriteLine ("music file="+_music_file_name);
+ //Console.WriteLine ("music file="+_music_file_name);
} else if (line.Substring(0,5).ToLower ()=="track") {
_in_tracks=true;
- } else if (line.Substring (0,3).ToLower ()=="rem") {
+ } else if (eq(line,"rem")) {
line=line.Substring (3).Trim ();
- if (line.Substring (0,5).ToLower ()=="image") {
+ if (eq(line,"image")) {
_image_file_name=line.Substring (5).Trim ();
_image_file_name=Regex.Replace (_image_file_name,"[\"]","").Trim ();
_img_full_path=directory+"/"+_image_file_name;
@@ -165,8 +188,8 @@ namespace Banshee.CueSheets
if (_in_tracks) {
if (aaid=="") { aaid=getArtId (); }
- Console.WriteLine ("line="+line);
- if (line.Substring (0,5).ToLower ()=="track") {
+ //Console.WriteLine ("line="+line);
+ if (eq(line,"track")) {
if (e_offset>=0) {
nr+=1;
CueSheetEntry e=new CueSheetEntry(_music_file_name,aaid,nr,-1,e_title,e_perf,_title,e_offset);
@@ -180,24 +203,24 @@ namespace Banshee.CueSheets
e_perf=_performer;
e_title="";
e_offset=-1.0;
- } else if (line.Substring (0,5).ToLower ()=="title") {
+ } else if (eq(line,"title")) {
e_title=Regex.Replace (line.Substring (5).Trim (),"[\"]","");
- } else if (line.Substring (0,9).ToLower ()=="performer") {
+ } else if (eq(line,"performer")) {
e_perf=Regex.Replace (line.Substring (9).Trim (),"[\"]","");
- } else if (line.Substring (0,5).ToLower ()=="index") {
+ } else if (eq(line,"index")) {
string s=line.Substring (5).Trim ();
s=Regex.Replace (s,"^\\s*[0-9]+\\s*","");
string []parts=Regex.Split(s,"[:]");
- Console.WriteLine ("parts="+parts[0]+","+parts[1]+","+parts[2]);
+ //Console.WriteLine ("parts="+parts[0]+","+parts[1]+","+parts[2]);
int min=Convert.ToInt32(parts[0]);
int secs=Convert.ToInt32(parts[1]);
int hsecs=Convert.ToInt32(parts[2]);
e_offset=min*60+secs+(hsecs/100.0);
-
}
}
}
}
+ //Console.WriteLine ("Last entry adding");
if (e_offset>=0) {
nr+=1;
CueSheetEntry e=new CueSheetEntry(_music_file_name,aaid,nr,-1,e_title,e_perf,_title,e_offset);
@@ -208,14 +231,55 @@ namespace Banshee.CueSheets
ePrev.setLength(e.offset ()-ePrev.offset());
}
}
+ //Console.WriteLine ("Last entry added");
{
int i;
for(i=0;i<nEntries();i++) {
entry (i).setNrOfTracks(nr);
}
+ //Console.WriteLine ("Ready");
}
- }
+ }
+ }
+
+ public void load(CueSheet s) {
+ load (s._cuefile,s._directory,s._basedir);
+ }
+
+ public void load(string filename,string directory,string basedir) {
+ Clear ();
+ _cuefile=filename;
+ _basedir=basedir;
+ _directory=directory;
+ try {
+ iLoad();
+ } catch(System.Exception e) {
+ Console.WriteLine ("CueSheet: Cannot load "+filename);
+ Console.WriteLine (e.ToString ());
+ }
+ }
+
+ public override void Clear() {
+ base.Clear ();
+ _cuefile="";
+ _image_file_name="";
+ _img_full_path="";
+ _music_file_name="";
+ _title="";
+ _performer="";
+ _tracks=null;
+ _basedir="";
+ _directory="";
+ }
+
+ public CueSheet() {
+ Clear ();
+ }
+
+ public CueSheet (string filename,string directory,string basedir) {
+ Clear ();
+ load (filename,directory,basedir);
}
}
}
diff --git a/src/CueSheets/Banshee.CueSheets/CueSheetEntry.cs b/src/CueSheets/Banshee.CueSheets/CueSheetEntry.cs
index cf4f308..129f386 100644
--- a/src/CueSheets/Banshee.CueSheets/CueSheetEntry.cs
+++ b/src/CueSheets/Banshee.CueSheets/CueSheetEntry.cs
@@ -2,7 +2,7 @@
// CueSheetEntry.cs
//
// Authors:
-// Cool Extension Author <hans@oesterholt.net>
+// Hans Oesterholt <hans@oesterholt.net>
//
// Copyright (C) 2013 Hans Oesterholt
//
@@ -75,6 +75,10 @@ namespace Banshee.CueSheets
this.Duration=new TimeSpan(ticks_100nanosecs);
}
+ public override string ToString() {
+ return "nr: "+this.TrackNumber+", title: "+this.title ()+", file: "+this.file ();
+ }
+
public CueSheetEntry (string file,String artId,int nr,int cnt,string title,string performer,string album,double offset) {
_file=file;
_title=title;
@@ -93,7 +97,7 @@ namespace Banshee.CueSheets
this.CanPlay=true;
this.CanSaveToDatabase=false;
this.Duration=new System.TimeSpan(0,0,10,0);
- Console.WriteLine ("file="+_file);
+ //Console.WriteLine ("file="+_file);
this.Uri=new Hyena.SafeUri(_file,false);
}
}
diff --git a/src/CueSheets/Banshee.CueSheets/CueSheetsPrefs.cs b/src/CueSheets/Banshee.CueSheets/CueSheetsPrefs.cs
new file mode 100644
index 0000000..3b6a14f
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/CueSheetsPrefs.cs
@@ -0,0 +1,99 @@
+using System;
+using Banshee.Configuration;
+using Banshee.Collection;
+using Banshee.Gui;
+using Banshee.Base;
+using Banshee.MediaEngine;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+using Banshee.Sources.Gui;
+using Banshee.Preferences;
+using Gdk;
+
+namespace Banshee.CueSheets
+{
+ public class CueSheetsPrefs : IDisposable
+ {
+ private SourcePage source_page;
+ private Section basedir_section;
+ private CueSheetsSource _source;
+ private Gtk.FileChooserButton _btn;
+
+ public CueSheetsPrefs (CueSheetsSource source) {
+ var service = ServiceManager.Get<PreferenceService>();
+
+ if (service==null) {
+ return;
+ }
+
+ _source=source;
+ source_page = new SourcePage(source);
+ basedir_section=new Section("cuesheets-basedir","CueSheet Music Directory:",20);
+ source_page.Add (basedir_section);
+
+ string dir=source.getCueSheetDir();
+ Gtk.Label lbl=new Gtk.Label("CueSheet Music Directory:");
+ Gtk.FileChooserButton btn=new Gtk.FileChooserButton("CueSheet Music Directory:",Gtk.FileChooserAction.SelectFolder);
+ btn.SelectFilename (dir);
+ Gtk.HBox box=new Gtk.HBox();
+ box.Add (lbl);
+ box.Add (btn);
+ box.ShowAll ();
+ btn.FileSet+=new EventHandler(EvtDirSet);
+ _btn=btn;
+
+ Console.WriteLine (_source);
+
+ Gtk.VBox vb=new Gtk.VBox();
+ vb.PackStart (box,false,false,0);
+
+ Gtk.Image icn_about=new Gtk.Image(Gtk.Stock.About,Gtk.IconSize.Button);
+ Gtk.Button about=new Gtk.Button(icn_about);
+ about.Clicked+=new EventHandler(handleAbout);
+ Gtk.HBox hb=new Gtk.HBox();
+ Gtk.Label _about=new Gtk.Label("About the CueSheet extension");
+ hb.PackEnd (about,false,false,0);
+ hb.PackEnd (_about,false,false,5);
+ vb.PackStart (hb,false,false,0);
+
+ Gtk.HBox hb1=new Gtk.HBox();
+ vb.PackEnd (hb1,true,true,0);
+
+ vb.ShowAll ();
+
+ source_page.DisplayWidget = vb;
+
+ }
+
+ public void EvtDirSet(object sender,EventArgs a) {
+ string dir=_btn.Filename;
+ _source.setCueSheetDir(dir);
+ }
+
+ public string PageId {
+ get { return source_page.Id; }
+ }
+
+ #region IDisposable implementation
+ public void Dispose ()
+ {
+ //throw new NotImplementedException ();
+ }
+ #endregion
+
+ public void handleAbout(object sender,EventArgs a) {
+ Gtk.AboutDialog ab=new Gtk.AboutDialog();
+ //ab.Title="About the CueSheets extension";
+ ab.Authors=new string[] {"Hans Oesterholt"};
+ ab.Authors[0]="Hans Oesterholt";
+ ab.Version="0.0.5 (2013-01-12)";
+ ab.Comments="CueSheets is an extension that allows you to play music from cuesheets in banshee";
+ ab.Website="http://oesterholt.net?env=data&page=banshee-cuesheets";
+ ab.Run ();
+ ab.Destroy ();
+ }
+
+
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/CueSheetsSource.cs b/src/CueSheets/Banshee.CueSheets/CueSheetsSource.cs
index c4cb87b..13ae1cd 100644
--- a/src/CueSheets/Banshee.CueSheets/CueSheetsSource.cs
+++ b/src/CueSheets/Banshee.CueSheets/CueSheetsSource.cs
@@ -2,7 +2,7 @@
// CueSheetsSource.cs
//
// Authors:
-// Cool Extension Author <hans@oesterholt.net>
+// Hans Oesterholt <hans@oesterholt.net>
//
// Copyright (C) 2013 Hans Oesterholt
//
@@ -25,7 +25,6 @@
// 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.Addins;
@@ -45,6 +44,12 @@ using Banshee.CueSheets;
using System.Text.RegularExpressions;
using Banshee.Collection;
using Banshee.Library;
+using Banshee.Collection.Gui;
+using Hyena.Data;
+using Hyena.Collections;
+using System.Collections.Generic;
+using Banshee.Collection.Database;
+using Hyena.Data.Gui;
namespace Banshee.CueSheets
{
@@ -58,34 +63,50 @@ namespace Banshee.CueSheets
// In the sources TreeView, sets the order value for this source, small on top
const int sort_order = 50;
CustomView _view;
- TrackListModel _nullModel;
- double pbsize=-1.0;
+ //TrackListModel _nullModel;
+ //double pbsize=-1.0;
+ List<CueSheet> _sheets=new List<CueSheet>();
+ CueSheet _sheet=null;
+ private CueSheetsPrefs preferences;
+
public CueSheetsSource () : base (AddinManager.CurrentLocalizer.GetString ("CueSheets"),
- AddinManager.CurrentLocalizer.GetString ("CueSheets"),
- sort_order,
- "hod-cuesheets-2013-01-06")
+ AddinManager.CurrentLocalizer.GetString ("CueSheets"),
+ sort_order,
+ "hod-cuesheets-2013-01-06")
{
+ Console.WriteLine ("CueSheetsSouce init");
+ _sheet=new CueSheet();
_view=new CustomView(this);
- _nullModel=new MemoryTrackListModel();
Properties.Set<ISourceContents> ("Nereid.SourceContents", _view);
Properties.SetString ("Icon.Name", "cueplay");
-
Hyena.Log.Information ("CueSheets source has been instantiated.");
}
+
+
+ public override string PreferencesPageId {
+ get {
+ preferences=new CueSheetsPrefs(this);
+ return preferences.PageId;
+ }
+ }
// A count of 0 will be hidden in the source TreeView
public override int Count {
get {
- CueSheet s=_view.getSheet ();
+ CueSheet s=getSheet ();
if (s==null) { return 0; }
else { return s.nEntries (); }
}
}
public CueSheet getSheet() {
- return _view.getSheet();
+ return _sheet;
+ }
+
+ public List<CueSheet> getSheets() {
+ return _sheets;
}
#region IBasicPlaybackController implementation
@@ -116,12 +137,7 @@ namespace Banshee.CueSheets
public TrackListModel TrackModel {
get {
- CueSheet s=_view.getSheet ();
- if (s==null) {
- return _nullModel;
- } else {
- return s;
- }
+ return _sheet;
}
}
@@ -139,7 +155,7 @@ namespace Banshee.CueSheets
public bool CanShuffle { get { return true; } }
- public bool ShowBrowser { get { return false; } }
+ public bool ShowBrowser { get { return true; } }
public bool Indexable { get { return true; } }
@@ -149,22 +165,49 @@ namespace Banshee.CueSheets
public void DeleteTracks (Hyena.Collections.Selection selection) {
}
#endregion
+
+ private CS_AlbumModel _model=null;
+ private CS_ArtistModel _artistModel=null;
+ private CS_GenreModel _genreModel=null;
- public void OnConfigure (object o, EventArgs ea) {
- new CueSheetsConfigDialog (this);
- return;
- }
+ public CS_AlbumModel getAlbumModel() {
+ if (_model==null) {
+ Console.WriteLine ("AlbumModel init");
+ _model=new CS_AlbumModel(this);
+ }
+ return _model;
+ }
+
+ public TrackListModel getTrackModel() {
+ return this.TrackModel;
+ }
+
+ public CS_GenreModel getGenreModel() {
+ if (_genreModel==null) {
+ Console.WriteLine ("GenreModel init");
+ _genreModel=new CS_GenreModel(this);
+ }
+ return _genreModel;
+ }
- public double getPbSize() {
- if (pbsize<0.0) {
- pbsize=Banshee.Configuration.ConfigurationClient.Get<double>("cuesheets_zoom",1.0);
+ public CS_ArtistModel getArtistModel() {
+ if (_artistModel==null) {
+ Console.WriteLine ("ArtistModel init");
+ _artistModel=new CS_ArtistModel(this);
}
- return pbsize;
+ return _artistModel;
}
- public void setPbSize(double s) {
- pbsize=s;
- Banshee.Configuration.ConfigurationClient.Set<double>("cuesheets_zoom",s);
+ public void setPositions(int hb,int hb1,int vp) {
+ Banshee.Configuration.ConfigurationClient.Set<int>("cuesheets_hb",hb);
+ Banshee.Configuration.ConfigurationClient.Set<int>("cuesheets_hb1",hb1);
+ Banshee.Configuration.ConfigurationClient.Set<int>("cuesheets_vp",vp);
+ }
+
+ public void getPositions(out int hb,out int hb1, out int vp) {
+ hb=Banshee.Configuration.ConfigurationClient.Get<int>("cuesheets_hb",100);
+ hb1=Banshee.Configuration.ConfigurationClient.Get<int>("cuesheets_hb1",200);
+ vp=Banshee.Configuration.ConfigurationClient.Get<int>("cuesheets_vp",200);
}
public string getCueSheetDir() {
@@ -181,6 +224,8 @@ namespace Banshee.CueSheets
//Console.WriteLine ("setcuesheetdir:"+dir);
//Properties.SetString ("cuesheets_dir",dir);
Banshee.Configuration.ConfigurationClient.Set<string>("cuesheets_dir",dir);
+ _view.fill ();
+ //_view.reLoad ();
}
private class CueSheetsConfigDialog : Gtk.Dialog {
@@ -195,17 +240,17 @@ namespace Banshee.CueSheets
box.Add (btn);
box.ShowAll ();
- double d=src.getPbSize ();
- Gtk.HScale hs=new Gtk.HScale(1.0,3.0,0.25);
+ /*double d=src.getPbSize ();
+ Gtk.HScale hs=new Gtk.HScale(1.0,5.0,0.25);
hs.Value=d;
Gtk.Label lbl1=new Gtk.Label("Size of music icons:");
Gtk.HBox box1=new Gtk.HBox();
box1.Add (lbl1);
box1.Add (hs);
- box1.ShowAll ();
+ box1.ShowAll ();*/
this.VBox.Add (box);
- this.VBox.Add (box1);
+ //this.VBox.Add (box1);
this.AddButton (Gtk.Stock.Ok,1);
this.AddButton (Gtk.Stock.Cancel,2);
this.Title="CueSheets Preferences";
@@ -213,7 +258,7 @@ namespace Banshee.CueSheets
if (result==1) {
dir=btn.Filename;
src.setCueSheetDir(dir);
- src.setPbSize (hs.Value);
+ //src.setPbSize (hs.Value);
}
this.Destroy ();
}
@@ -221,53 +266,24 @@ namespace Banshee.CueSheets
private class CustomView : ISourceContents
{
- //Gtk.Button up;
- Gtk.ListStore store;
- Gtk.TreeView view;
- //Gtk.Image img;
- Gtk.VBox box;
- string type="directory";
- CueSheet sheet;
- //Gtk.Table table;
- Gtk.ScrolledWindow scroll;
- int index=-1;
+ Gtk.ListStore store;
+ Gtk.VBox box;
+ string type="directory";
+ Gtk.ScrolledWindow ascroll,tscroll,aascroll,gscroll;
+ int index=-1;
private CueSheetsSource MySource=null;
+ AlbumListView aview;
+ Gtk.TreeView view;
+ ArtistListView aaview;
+ GenreListView gview;
+ Gtk.HPaned hb;
+ Gtk.HPaned hb1;
+ Gtk.VPaned vp;
- uint _position=0;
- bool _set_position=false;
-
- const int IMG_NOIMAGE=0;
- const int IMG_NOIMAGE_DIR=1;
- const int IMG_DIRECTORY=2;
-
- Gdk.Pixbuf _img_dir=null;
- Gdk.Pixbuf _img_playlist=null;
- Gdk.Pixbuf _pb_size=null;
-
-
- private Gdk.Pixbuf GetDefaultPixBuf(int type) {
- Gdk.Pixbuf img=_img_playlist;
- if (type==1000) { img=_pb_size; }
- if (type==IMG_DIRECTORY) {
- img=_img_dir;
- }
- return img;
- }
-
- private int getPixbufWidth() {
- return (int) (_pb_size.Width*MySource.getPbSize());
- }
-
- private int getPixbufHeight() {
- return (int) (_pb_size.Height*MySource.getPbSize());
- }
-
- public CueSheet getSheet() {
- return sheet;
- }
-
- private String basedir=null;
- private String cwdir=null;
+ uint _position=0;
+ bool _set_position=false;
+ private String basedir=null;
+ private CueSheet _selected=null;
public string basename(string f) {
string bn=Regex.Replace (f,"^([^/]*[/])+","");
@@ -279,70 +295,91 @@ namespace Banshee.CueSheets
return cn;
}
- public void fill(Gtk.ListStore store) {
- type="directory";
- store.Clear ();
- if (basedir==null) {
- basedir=MySource.getCueSheetDir ();
- }
- if (cwdir==null) { cwdir=basedir; }
- string [] dirs=Directory.GetDirectories(cwdir, "*");
- string [] sheets=Directory.GetFiles (cwdir,"*.cue");
- int i=0;
- foreach (string file in sheets) {
- i=i+1;
- string name=cuename(file);
- CueSheet s=new CueSheet(file,cwdir);
- Gdk.Pixbuf pb;
- if (s.imageFileName ()!="") {
- string imgf=cwdir+"/"+s.imageFileName ();
- pb=new Gdk.Pixbuf(imgf,getPixbufWidth(),getPixbufHeight());
- } else {
- pb=GetDefaultPixBuf(IMG_NOIMAGE_DIR);
- }
- store.AppendValues(i,pb,name);
- }
+ public List<CueSheet> getSheets() {
+ return MySource.getSheets ();
+ }
+
+
+ private void fill(string cwd) {
+ //Console.WriteLine ("fill:"+cwd);
+ string [] dirs=Directory.GetDirectories(cwd, "*");
+ string [] sheets=Directory.GetFiles (cwd,"*.cue");
foreach (string dir in dirs) {
- string name=basename (dir);
- if (name.Substring (0,1)!=".") {
- i=i+1;
- Gdk.Pixbuf pb=GetDefaultPixBuf(IMG_DIRECTORY);
- store.AppendValues(i,pb,name);
+ if (dir.Substring (0,1)!=".") {
+ fill (dir);
+ }
+ }
+ foreach (string sheet in sheets) {
+ if (sheet.Substring (0,1)!=".") {
+ CueSheet cs=new CueSheet(sheet,cwd,basedir);
+ getSheets().Add (cs);
}
}
}
+ public void fill() {
+ getSheets().Clear ();
+ basedir=MySource.getCueSheetDir();
+ fill (basedir);
+ Console.WriteLine ("Filled");
+ try {
+ Console.WriteLine ("Reload albums");
+ MySource.getAlbumModel ().Reload ();
+ Console.WriteLine ("Reload artists");
+ MySource.getArtistModel ().Reload ();
+ Console.WriteLine ("Reload genres");
+ MySource.getGenreModel ().Reload ();
+ Console.WriteLine ("Reload tracks");
+ MySource.getTrackModel ().Reload ();
+ Console.WriteLine ("Reloaded all");
+ Console.WriteLine (MySource.getAlbumModel ().Count);
+ Console.WriteLine (MySource.getArtistModel ().Count);
+ Console.WriteLine (MySource.getGenreModel ().Count);
+ } catch(System.Exception e) {
+ Console.WriteLine (e.ToString());
+ }
+ Console.WriteLine ("Reloaded");
+ }
+
public void seekSong(int i) {
- CueSheetEntry e=sheet.entry (i);
- double offset=e.offset ();
- //Console.WriteLine ("Offset="+offset+", current="+ServiceManager.PlayerEngine.Position+
- // ", msecs="+offset*1000.0
- // );
- //ServiceManager.PlayerEngine.SetNextTrack (e);
- //ServiceManager.PlayerEngine.Open(e);
- ServiceManager.PlayerEngine.SetCurrentTrack(e);
- _position=(uint) (offset*1000.0);
- _set_position=true;
- mscount=chgcount-(1000/timeout);
- //ServiceManager.PlayerEngine.PlayAt((uint) (offset*1000.0));
- //ServiceManager.PlayerEngine.Position=_position;
-
+ Console.WriteLine ("SeekSong called "+i);
+ try {
+ CueSheet sheet=MySource.getSheet ();
+ if (sheet.Count==0) {
+ if (_selected!=null) {
+ loadCueSheet (_selected);
+ }
+ }
+ CueSheetEntry e=sheet.entry (i);
+ double offset=e.offset ();
+ ServiceManager.PlayerEngine.SetCurrentTrack(e);
+ _position=(uint) (offset*1000.0);
+ _set_position=true;
+ mscount=chgcount-(1000/timeout);
+ } catch (SystemException ex) {
+ Console.WriteLine (ex);
+ }
}
public void reLoad() {
index=0;
- ServiceManager.PlayerEngine.SetAccurateSeek(true);
- CueSheetEntry e=sheet.entry(index);
- ServiceManager.PlayerEngine.Open (e);
- ServiceManager.PlayerEngine.Play ();
- //ServiceManager.PlayerEngine.PlayAt ((uint) (e.offset ()*1000.0));
- if (ServiceManager.PlaybackController.Source!=MySource) {
- ServiceManager.PlaybackController.Source=MySource;
- }
- if (ServiceManager.PlaybackController.NextSource!=MySource) {
- ServiceManager.PlaybackController.NextSource=MySource;
+ try {
+ CueSheet sheet=MySource.getSheet ();
+ ServiceManager.PlayerEngine.SetAccurateSeek(true);
+ CueSheetEntry e=sheet.entry(index);
+ //Console.WriteLine (e.ToString ());
+ ServiceManager.PlayerEngine.Open (e);
+ ServiceManager.PlayerEngine.Play ();
+ if (ServiceManager.PlaybackController.Source!=MySource) {
+ ServiceManager.PlaybackController.Source=MySource;
+ }
+ if (ServiceManager.PlaybackController.NextSource!=MySource) {
+ ServiceManager.PlaybackController.NextSource=MySource;
+ }
+ ServiceManager.PlaybackController.SetSeekMode (true);
+ } catch (SystemException ex) {
+ Console.WriteLine (ex);
}
- ServiceManager.PlaybackController.SetSeekMode (true);
mscount=chgcount-1;
}
@@ -352,6 +389,7 @@ namespace Banshee.CueSheets
private int chgcount=3000/100; // every 3 seconds
public bool PositionDisplay() {
+ CueSheet sheet=MySource.getSheet ();
if (ServiceManager.PlaybackController.Source==MySource) {
if (sheet!=null) {
mscount+=1;
@@ -401,6 +439,7 @@ namespace Banshee.CueSheets
}
public Boolean next() {
+ CueSheet sheet=MySource.getSheet ();
if (sheet==null) { return false; }
if (index<sheet.nEntries ()-1) {
index+=1;
@@ -412,6 +451,7 @@ namespace Banshee.CueSheets
}
public Boolean previous() {
+ CueSheet sheet=MySource.getSheet ();
if (sheet==null) { return false; }
if (index>0) {
index-=1;
@@ -422,155 +462,201 @@ namespace Banshee.CueSheets
return true;
}
- public void loadCueSheet(string file,Gtk.ListStore store) {
+ public void loadCueSheet(CueSheet s) { //,Gtk.ListStore store) {
+ CueSheet sheet=MySource.getSheet ();
type="cuesheet";
- //Console.WriteLine ("loadCueSheet:"+file);
+ sheet.Clear ();
+ sheet.load (s);
store.Clear ();
- sheet=new CueSheet(file,cwdir);
- Gdk.Pixbuf pb;
- /*if (sheet.imageFileName ()!="") {
- string imgf=cwdir+"/"+sheet.imageFileName ();
- pb=new Gdk.Pixbuf(imgf,getPixbufWidth(),getPixbufHeight());
- } else {*/
- pb=GetDefaultPixBuf(IMG_NOIMAGE);
- /*}*/
int i=0;
for(i=0;i<sheet.nEntries ();i++) {
- store.AppendValues (i+1,pb,sheet.entry (i).title ());
+ store.AppendValues (i+1,sheet.entry (i).title ());
}
- //Console.WriteLine (type+", image="+sheet.imageFileName ());
-
- /*if (File.Exists (imgf)) {
- Gdk.Rectangle a=img.Allocation;
- Gdk.Pixbuf pb=new Gdk.Pixbuf(imgf,a.Width,a.Height);
- img.Pixbuf=pb;
- }*/
reLoad ();
}
+
+ public void loadCueSheet(int i) {
+ loadCueSheet (MySource.getSheets ()[i]);
+ }
+
+ internal class MyAlbumListView : AlbumListView {
+ private CustomView _view;
+
+ public MyAlbumListView(CustomView view) : base() {
+ _view=view;
+ }
+
+ protected override bool OnPopupMenu () {
+ Gtk.Menu mnu=new Gtk.Menu();
+ Gtk.ImageMenuItem play=new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay,null);
+ play.Activated+=delegate(object sender,EventArgs a) {
+ _view.PlayAlbum((CS_AlbumInfo) this.Model[Selection.FirstIndex]);
+ };
+ mnu.Append (play);
+ mnu.ShowAll ();
+ mnu.Popup();
+ return false;
+ }
+ }
+
public CustomView(CueSheetsSource ms) {
MySource=ms;
- {
- Gtk.Label w=new Gtk.Label();
- _pb_size=w.RenderIcon (Gtk.Stock.Index.ToString (),Gtk.IconSize.Button,null);
- _img_dir=w.RenderIcon (Gtk.Stock.Directory.ToString (),Gtk.IconSize.Button,null);
- _img_playlist=w.RenderIcon(Gtk.Stock.Index.ToString (),Gtk.IconSize.Button,null);
- }
-
- store = new Gtk.ListStore(typeof(int),typeof(Gdk.Pixbuf),typeof(string));
+ basedir=MySource.getCueSheetDir ();
+
+ store = new Gtk.ListStore(typeof(int),typeof(string));
view = new Gtk.TreeView();
- Gtk.CellRendererPixbuf cpb=new Gtk.CellRendererPixbuf();
view.AppendColumn ("Nr.", new Gtk.CellRendererText (), "text", 0);
- view.AppendColumn ("Icon.",cpb,"pixbuf",1);
- view.AppendColumn ("Track/Album", new Gtk.CellRendererText (), "text", 2);
+ view.AppendColumn ("Track", new Gtk.CellRendererText (), "text", 1);
view.CursorChanged += new EventHandler(EvtCursorChanged);
- view.RowActivated += new Gtk.RowActivatedHandler(EvtRowActivated);
+ view.RowActivated += new Gtk.RowActivatedHandler(EvtTrackRowActivated);
view.Model = store;
- scroll=new Gtk.ScrolledWindow();
- scroll.Add (view);
+
+ Console.WriteLine ("New albumlist");
+ aview=new MyAlbumListView(this);
+ aaview=new ArtistListView();
+ gview=new GenreListView();
+ Console.WriteLine ("init models");
+ aview.SetModel (MySource.getAlbumModel ());
+ aaview.SetModel (MySource.getArtistModel ());
+ gview.SetModel (MySource.getGenreModel ());
+ MySource.getGenreModel();
+ Console.WriteLine ("model albumlist");
+ Console.WriteLine ("albumlist initialized");
+
+ aview.RowActivated+=new Hyena.Data.Gui.RowActivatedHandler<AlbumInfo>(EvtRowActivated);
+ aview.Selection.Changed += HandleAviewSelectionChanged;
+ gview.RowActivated+=new Hyena.Data.Gui.RowActivatedHandler<GenreInfo>(EvtGenreActivated);
+ aaview.RowActivated+=new Hyena.Data.Gui.RowActivatedHandler<ArtistInfo>(EvtArtistActivated);
Gtk.Toolbar bar=new Gtk.Toolbar();
- Gtk.Image icn_up=new Gtk.Image(Gtk.Stock.GoUp,Gtk.IconSize.Button);
- Gtk.Button up=new Gtk.Button(icn_up);
- up.Clicked+=new EventHandler(handleUp);
- bar.Add (up);
+ fill ();
- Gtk.Image icn_set=new Gtk.Image(Gtk.Stock.Preferences,Gtk.IconSize.Button);
- Gtk.Button prefs=new Gtk.Button(icn_set);
- prefs.Clicked+=new EventHandler(handleSet);
- bar.Add (prefs);
+ ascroll=new Gtk.ScrolledWindow();
+ ascroll.Add (aview);
+ aascroll=new Gtk.ScrolledWindow();
+ aascroll.Add (aaview);
+ tscroll=new Gtk.ScrolledWindow();
+ tscroll.Add (view);
+ gscroll=new Gtk.ScrolledWindow();
+ gscroll.Add (gview);
- Gtk.Image icn_about=new Gtk.Image(Gtk.Stock.About,Gtk.IconSize.Button);
- Gtk.Button about=new Gtk.Button(icn_about);
- about.Clicked+=new EventHandler(handleAbout);
- bar.Add (about);
+ hb=new Gtk.HPaned();
+ hb.Add(gscroll);
+ hb.Add (aascroll);
+ hb1=new Gtk.HPaned();
+ hb1.Add (hb);
+ hb1.Add (ascroll);
+
+ vp=new Gtk.VPaned();
+ vp.Add (hb1);
+ vp.Add (tscroll);
+
+ {
+ int hb_p,hb1_p,vp_p;
+ MySource.getPositions (out hb_p,out hb1_p,out vp_p);
+ hb.Position=hb_p;
+ hb1.Position=hb1_p;
+ vp.Position=vp_p;
+ }
- fill(store);
box = new Gtk.VBox();
box.PackStart (bar,false,true,0);
- box.PackStart(scroll);
+ box.PackStart (vp);
box.ShowAll();
+ GLib.Timeout.Add ((uint) 1000,(GLib.TimeoutHandler) GardDividers);
GLib.Timeout.Add ((uint) timeout,(GLib.TimeoutHandler) PositionDisplay);
}
+
+ void HandleAviewSelectionChanged (object sender, EventArgs e) {
+ int index=((Selection) sender).FirstIndex;
+ CS_AlbumInfo a=(CS_AlbumInfo) MySource.getAlbumModel ()[index];
+ _selected=a.getSheet ();
+ //Console.WriteLine (_selected);
+ }
- public void handleUp(object sender,EventArgs a) {
- if (cwdir==basedir) {
- // do nothing
- } else {
- if (type!="cuesheet") {
- cwdir=Regex.Replace (cwdir,"[/][^/]*$","");
- }
- fill (store);
+ int hb_prev=-1;
+ int hb1_prev=-1;
+ int vp_prev=-1;
+
+ public bool GardDividers() {
+ if (hb_prev==-1) {
+ hb_prev=hb.Position;
+ hb1_prev=hb1.Position;
+ vp_prev=vp.Position;
+ }
+ bool changed=false;
+ if (hb_prev!=hb.Position) {
+ hb_prev=hb.Position;
+ changed=true;
+ }
+ if (hb1_prev!=hb1.Position) {
+ hb1_prev=hb1.Position;
+ changed=true;
+ }
+ if (vp_prev!=vp.Position) {
+ vp_prev=vp.Position;
+ changed=true;
}
+ if (changed) {
+ MySource.setPositions(hb_prev,hb1_prev,vp_prev);
+ }
+ return true;
}
- public void handleSet(object sender,EventArgs a) {
- MySource.OnConfigure (sender,a);
- string d=MySource.getCueSheetDir ();
- if (basedir!=d) {
- basedir=d;
- cwdir=d;
- fill (store);
- }
+
+ public void EvtCursorChanged(object sender,EventArgs a) {
+ mscount=0; // Reset cursor change timer
+ Console.WriteLine ("sender:"+sender+", "+a);
}
- public void handleAbout(object sender,EventArgs a) {
- Gtk.AboutDialog ab=new Gtk.AboutDialog();
- ab.Title="About the CueSheets extension";
- ab.Authors=new string[] {"Hans Oesterholt"};
- ab.Authors[0]="Hans Oesterholt";
- ab.Version="0.0.1";
- ab.Comments="CueSheets is an extension that allows you to play music from cuesheets in banshee";
- ab.Website="http://oesterholt.net?env=data&page=banshee-cuesheets";
- ab.Run ();
- ab.Destroy ();
+ public void PlayAlbum(CS_AlbumInfo a) {
+ loadCueSheet (a.getSheet ());
}
- public void EvtCursorChanged(object sender,EventArgs a) {
- mscount=0; // Reset cursor change timer
+ public void EvtRowActivated(object sender,RowActivatedArgs<AlbumInfo> args) {
+ //Console.WriteLine ("I'm here! "+sender+", "+args);
+ CS_AlbumInfo a=(CS_AlbumInfo) args.RowValue;
+ //Console.WriteLine ("sheet: "+a.getSheet ().ToString ());
+ PlayAlbum (a);
+ }
+
+ public void EvtGenreActivated(object sender,RowActivatedArgs<GenreInfo> args) {
+ //Console.WriteLine ("I'm here! "+sender+", "+args);
+ GenreInfo g=args.RowValue;
+ if (MySource.getGenreModel ().isNullGenre (g)) { g=null; }
+ MySource.getAlbumModel ().filterGenre(g);
+ MySource.getArtistModel ().filterGenre(g);
+ }
+
+ public void EvtArtistActivated(object sender,RowActivatedArgs<ArtistInfo> args) {
+ Console.WriteLine ("I'm here! "+sender+", "+args);
+ ArtistInfo a=args.RowValue;
+ if (MySource.getArtistModel ().isNullArtist (a)) { a=null; }
+ MySource.getAlbumModel ().filterArtist(a);
}
- public void EvtRowActivated(object sender, Gtk.RowActivatedArgs a) {
+ public void EvtTrackRowActivated(object sender,Gtk.RowActivatedArgs args) {
Gtk.TreeSelection selection = (sender as Gtk.TreeView).Selection;
Gtk.TreeModel model;
Gtk.TreeIter iter;
// THE ITER WILL POINT TO THE SELECTED ROW
- Console.WriteLine ("source="+ServiceManager.PlaybackController.Source);
- Console.WriteLine ("this="+this);
+ //Console.WriteLine ("source="+ServiceManager.PlaybackController.Source);
+ //Console.WriteLine ("this="+this);
if (selection.GetSelected(out model, out iter)) {
- if (this.type=="cuesheet") {
- if (ServiceManager.PlaybackController.Source != MySource) {
- reLoad ();
- //this.type="";
- //EvtRowActivated (sender,a);
- }
- int track=(int) model.GetValue (iter,0);
- int i=track-1;
- seekSong (i);
- index=i;
- } else {
- string name=model.GetValue (iter,2).ToString ();
- string file=cwdir+"/"+name;
- string cuef=file+".cue";
- Console.WriteLine ("File="+file);
- Console.WriteLine ("CueF="+cuef);
- if (Directory.Exists (file)) {
- Console.WriteLine ("Directory");
- cwdir=file;
- fill (store);
- } else {
- if (File.Exists (cuef)) {
- Console.WriteLine ("CueSheet");
- loadCueSheet(cuef,store);
- }
- }
- }
+ if (ServiceManager.PlaybackController.Source != MySource) {
+ reLoad ();
+ }
+ int track=(int) model.GetValue (iter,0);
+ int i=track-1;
+ seekSong (i);
+ index=i;
}
}
-
+
public bool SetSource (ISource source) { return true; }
public void ResetSource () { }
diff --git a/src/CueSheets/Banshee.CueSheets/GenreInfo.cs b/src/CueSheets/Banshee.CueSheets/GenreInfo.cs
new file mode 100644
index 0000000..094d3f3
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/GenreInfo.cs
@@ -0,0 +1,50 @@
+//
+// GenreInfo.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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
+//
+using System;
+
+namespace Banshee.CueSheets
+{
+ public class GenreInfo
+ {
+ private string _genre;
+
+ public GenreInfo ()
+ {
+ _genre="";
+ }
+
+ public GenreInfo(string s) {
+ _genre=s;
+ }
+
+ public string Genre {
+ get { return _genre; }
+ set { _genre=value; }
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/GenreListView.cs b/src/CueSheets/Banshee.CueSheets/GenreListView.cs
new file mode 100644
index 0000000..89f0b58
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/GenreListView.cs
@@ -0,0 +1,44 @@
+//
+// GenreListView.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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
+//
+using System;
+using Banshee.Collection.Gui;
+using Hyena.Data.Gui;
+
+namespace Banshee.CueSheets
+{
+ public class GenreListView : TrackFilterListView<GenreInfo>
+ {
+ protected GenreListView (IntPtr ptr) : base () {}
+
+ public GenreListView () : base ()
+ {
+ column_controller.Add (new Column ("Genre", new ColumnCellText ("Genre", true), 1.0));
+ ColumnController = column_controller;
+ }
+ }
+}
+
diff --git a/src/CueSheets/Banshee.CueSheets/Loosely.cs b/src/CueSheets/Banshee.CueSheets/Loosely.cs
new file mode 100644
index 0000000..4fd8a74
--- /dev/null
+++ b/src/CueSheets/Banshee.CueSheets/Loosely.cs
@@ -0,0 +1,57 @@
+//
+// Loosely.cs
+//
+// Authors:
+// Hans Oesterholt <hans@oesterholt.net>
+//
+// Copyright (C) 2013 Hans Oesterholt
+//
+// 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
+//
+using System;
+using System.Text.RegularExpressions;
+
+namespace Banshee.CueSheets
+{
+ public class Loosely
+ {
+
+ public Loosely () {
+ }
+
+ static Regex r1=new Regex(" and ");
+ static Regex r2=new Regex("[_-]+");
+ static Regex r3=new Regex("\\s+");
+
+ static public string prepare(string a) {
+ string aa=a.ToLower ().Trim ();
+ aa=r3.Replace (r2.Replace (r1.Replace (aa," & "),"-")," ");
+ return aa;
+ }
+
+ static public bool eq(string a,string b) {
+ return prepare (a)==prepare (b);
+ }
+
+ static public bool eqp(string prepared,string b) {
+ return prepared==prepare (b);
+ }
+ }
+}
+
diff --git a/src/CueSheets/Makefile.am b/src/CueSheets/Makefile.am
index bc4e196..52f5d46 100644
--- a/src/CueSheets/Makefile.am
+++ b/src/CueSheets/Makefile.am
@@ -2,9 +2,18 @@ ASSEMBLY = Banshee.CueSheets
LINK = $(BANSHEE_LIBS)
SOURCES = \
+ Banshee.CueSheets/CS_AlbumInfo.cs \
+ Banshee.CueSheets/CS_AlbumModel.cs \
+ Banshee.CueSheets/CS_ArtistInfo.cs \
+ Banshee.CueSheets/CS_ArtistModel.cs \
+ Banshee.CueSheets/CS_GenreModel.cs \
Banshee.CueSheets/CueSheet.cs \
Banshee.CueSheets/CueSheetEntry.cs \
- Banshee.CueSheets/CueSheetsSource.cs
+ Banshee.CueSheets/CueSheetsPrefs.cs \
+ Banshee.CueSheets/CueSheetsSource.cs \
+ Banshee.CueSheets/GenreInfo.cs \
+ Banshee.CueSheets/GenreListView.cs \
+ Banshee.CueSheets/Loosely.cs
RESOURCES = CueSheets.addin.xml